C
C
Ch00ee2015-10-15 12:39:33
Ansible
Ch00ee, 2015-10-15 12:39:33

Ansible-playbook what's wrong?

Hi all!
there is a simple playbook, how to make it work with with_items?
vars are added but not substituted into the {{ item.var }}
role

---

   - name: include default step variables
     include_vars: vars/main.yml 
   - name: Add user
     user: name="{{ item.user }}"
           shell="{{ item.shell }}"
           state=present
           group="{{ item.group }}"
     with_items:
       - ssh_team

vars/main.yml
ssh_team:
   - { user: "ololo", key: "ssh-rsa pupkin_pub_key", shell: /bin/zsh, group: sudo}

playbook
---
- hosts: 10.1.1.19
  sudo: yes
  user: admin

  roles:
    - useradd

conclusion
10.1.1.19> ESTABLISH CONNECTION FOR USER: admin
ok: [10.1.1.19] => {"ansible_facts": {"ssh_team": [{"group": "sudo", "key": "ssh-rsa pupkin_pub_key", "shell": "/bin/zsh", "user": "ololo"}]}}

<10.1.1.19> ESTABLISH CONNECTION FOR USER: admin
fatal: [10.1.1.19] => One or more undefined variables: 'unicode object' has no attribute 'user'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
newcode, 2015-10-15
@Ch00ee

with_items:
- {{ssh_team}}
forgot to indicate that this is a variable, ansible thinks it's a string

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question