ansible報錯
阿新 • • 發佈:2019-02-19
project golang type group ext del %d ger -name 報錯:
[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" log\$(date +%d -d -1day)\" -delete"
[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"
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 \"
ansible報錯