Ansible
Ansible shell 模組問題
我需要使用ansible中的shell模組清除遠端主機上文件的內容,但無法這樣做
--- - hosts: ansi1 become: yes gather_facts: no tasks: - name: checking shell power shell: >/tmp/1.txt args: executable: /bin/bash
錯誤:
ERROR! Syntax Error while loading YAML. The error appears to have been in '/etc/ansible/shell.yml': line 8, column 10, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: shell: >/tmp/1.txt ^ here
@Jeff Schaller 這有助於解決問題,,
--- - hosts: ansi2 become: yes gather_facts: no tasks: - name: checking shell power shell: '>/tmp/1.txt' args: executable: /bin/bash
現在如果我有多個命令要執行怎麼辦
您可以將其用於多個命令,如下所示:
- name: Copy var directory shell: | cmd1 cmd2 cmd3 args: executable: /bin/bash