2017-02-07 7 views
-1

不可能なコレクションを繰り返し処理すると何が問題になりますか?ループを実行する可能性があります

ansible-playbook -i "localhost," -c local main.ymlエラーを実行

- name: echo kerberos 
     shell: echo "addprinc -pw {{ item.password }} {{ item.username }}" 
      ^here 
We could be wrong, but this one looks like it might be an issue with 
missing quotes. Always quote template expression brackets when they 
start a value. For instance: 

    with_items: 
     - {{ foo }} 

Should be written as: 

    with_items: 
     - "{{ foo }}" 

あるしかし、私はすでに正常にこれらのルールを次のようにしています私のために見えます。

ここに私の最小限の例:

main.yml

--- 
- hosts: all 
    tasks: 
    - name: echo kerberos 
     shell: echo "addprinc -pw {{ item.password }} {{ item.username }}" 
     with_items: "{{ users }}" 

users.yml

--- 
users: 
    - username: test_user 
    password: test_user 
    sn: User 
    uid: 50001 
    gid: 100 
    - username: test_user1 
    password: test_user 
    cn: Test User1 
    sn: User1 
    uid: 50002 
    gid: 100 

user_groups: 
    - cn: access1 
    gid: 100001 
    users: 
     - test_user1 

答えて

1

あなたはYAMLでパディングには注意する必要があります:

--- 
- hosts: all 
    tasks: 
    - name: echo kerberos 
     shell: echo "addprinc -pw {{ item.password }} {{ item.username }}" 
     with_items: "{{ users }}" 

shellおよびwith_itemsnameに揃えられています。

関連する問題