2016-10-29 6 views
0

私は無責任なプレイブックを持っています。私がプレイブックを実行するときに、使用する環境ファイルを指定します。プレイブックをプレイブックに組み込んで環境ファイルを定義する

ansible-playbook playbooks/release-deploy.yaml -i env/LAB3 

私は別のプレイブックを呼び出していますが、同じ環境ファイルを使用したいと思います。

私の現在の設定は次のとおりです。

- include: tasks/replace_configs.yaml 

だから私は脚本を実行すると、私はエラーを取得:

TASK [include] ***************************************************************** 
fatal: [10.169.99.70]: FAILED! => {"failed": true, "reason": "no action detected in task. This often indicates a misspelled module name, or incorrect module path. 

The error appears to have been in '/home/ansible/playbooks/tasks/replace_configs.yaml': line 2, column 3, but may 
be elsewhere in the file depending on the exact syntax problem. 

The offending line appears to be: 

--- 
- hosts: cac 
^here 


The error appears to have been in '/home/ansible/playbooks/tasks/replace_configs.yaml': line 2, column 3, but may 
be elsewhere in the file depending on the exact syntax problem. 


The offending line appears to be: 

--- 
- hosts: cac 
^here 
"} 

tasks/replace_configs.yamlもそれはdoesnのようenv/LAB3

が見える使用する必要がありますどのようなcacが知っている。別の設定を行う必要がありますか?

+0

インクルードファイルとenvファイルを共有してください – Shasha99

答えて

2

My current config is:

- include: tasks/replace_configs.yaml 

これは、これはタスクを含むファイルが含まれる行で、任意の「設定」ではありません。

のは、以下の「タスク」を見てみましょう:

The offending line appears to be: 

--- 
- hosts: cac 
^here 

それは、タスク似ていない、それはプレイのように見えます。おそらく、モジュール指示文を含んでいない可能性が高いので、Anabilityは正しく、期待されるタスクにモジュール名が提供されていないことを告げる:no action detected in task

あなたはAnsibleでincludeディレクティブを使用する場合、それはincludeのインデントレベルで含まれたコンテンツを置きますので、あなたはタスクが含まれている場合、あなたはだけタスク

を含める必要があります

あなたのインクルードされたファイルは次のようになります。

--- 
- name: This is a task 
    debug: msg="One task" 

- name: This is another task 
    debug: msg="Another task" 

などの他の定義を含めることはできません。特に、上位レベルのものは含めないでください。

+0

詳細な回答ありがとうございます。私はhosts行を削除するとすぐに完璧に動作しました。 –

関連する問題