ansible報錯

報錯:
[root@jenkins ~]# ansible go_activity -m cron -a "name='log_clear' minute=0 hour=2 job=find /home/golanger/log/ -type f -name 'log$(date +\%d -d -1day)' -delete"golang

ERROR! this task 'cron' has extra params, which is only allowed in the following modules: command, win_command, shell, win_shell, script, include, include_vars, add_host, group_by, set_fact, raw, meta

解決:
這個須要在job上加引號,另外以下,若是有一些特殊符號的話,須要轉義
[root@jenkins ~]# ansible go_activity -m cron -a "name=log_clear minute=0 hour=2 job='find /home/golanger/log/ -type f -name \"log\$(date +%d -d -1day)\" -delete'"
雖然加了計劃任務,可是仍是須要刪除下今天的日誌,手動執行
[root@jenkins ~]# ansible go_weiai_project -m shell -a "find /home/golanger/log/ -type f -name \"log\$(date +%d -d -1day)\" -delete"shell

相關文章
相關標籤/搜索