2016-07-22 5 views
1

私はリモートホスト(10.233.84.58)に対して起動される2つのプレイブックを持っています。スタンドアロン(ansible-playbook -i inventory.txt playbook.yml)を起動すると正常に動作します。スタンドアロンのプレイプレーブとプレイプレーブとの違いは?

最初のハンドブックは明らかincludeを除いて、同一である第二のものを含む:

--- 
- hosts: all 
    tasks: 
    - debug: msg="hello form playbook1" 
    # up to now the content is identical between playbook1.yaml and playbook2.yaml 
    # without the next line the playbook runs fine 
    - include: playbook2.yml 

Iはplaybook1.ymlを実行する:

# ansible-playbook -i inventory.txt playbook1.yml                (master✱) 

PLAY [all] ********************************************************************* 

TASK [setup] ******************************************************************* 
ok: [10.233.84.58] 

TASK [debug] ******************************************************************* 
ok: [10.233.84.58] => { 
    "msg": "hello form playbook1" 
} 

TASK [include] ***************************************************************** 
fatal: [10.233.84.58]: FAILED! => {"failed": true, "reason": "no action detected in task. This often indicates a misspelled module name, or incorrect module path.\n\nThe error appears to have been in '/root/tests/playbook2.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- hosts: all\n^here\n\n\nThe error appears to have been in '/root/tests/playbook2.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- hosts: all\n^here\n"} 

NO MORE HOSTS LEFT ************************************************************* 
     to retry, use: --limit @playbook1.retry 

PLAY RECAP ********************************************************************* 
10.233.84.58    : ok=2 changed=0 unreachable=0 failed=1 

Iエラーからの "理由" を抽出上記のメッセージを読んで読みやすくしました:

no action detected in task. This often indicates a misspelled module name, or incorrect module path. 

The error appears to have been in '/root/tests/playbook2.yml': line 2, column 3, but may 
be elsewhere in the file depending on the exact syntax problem. 

The offending line appears to be: 

--- 
- hosts: all 
^here 

インクルードプレイブックはスタンドアロンとはどのように違いますか?

答えて

8

インクルードには2種類あります。プレイブックまたはタスクリストを含めることができます。

--- 
- hosts: all 
    tasks: 
    - include: list_of_tasks.yml 

- include: complete_playbook.yml 

例では、タスクのリストとしてplaybook2.ymlを含めるようにしてください。
- hostsと同じインデントでincludeを移動しても問題ありません。

+0

ありがとうございました - それでした。私が無責任なことを発見した限り、すべての助けにも感謝します。 – WoJ

関連する問題