Ansible シェルモジュールの問題

Ansible シェルモジュールの問題

Ansibleのシェルモジュールを使用してリモートホストのファイル内容を消去する必要があります。

---
 - 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

ベストアンサー1

@Jeff Schallerは問題を解決するのに役立ちます。

---
 - hosts: ansi2
   become: yes
   gather_facts: no
   tasks:
   - name: checking shell power
     shell:
             '>/tmp/1.txt'
     args:
      executable: /bin/bash

今実行するコマンドが複数ある場合はどうなりますか?

おすすめ記事