Answer the question
In order to leave comments, you need to log in
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
ssh_team:
- { user: "ololo", key: "ssh-rsa pupkin_pub_key", shell: /bin/zsh, group: sudo}
---
- hosts: 10.1.1.19
sudo: yes
user: admin
roles:
- useradd
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question