Hi all,
New to the list. Been playing with Ansible for a few hours and I could
use a hand in getting a task going. I've not figured out any of the YAML
magic so please excuse the undoubtedly spectacular errors :)
Goal: create a task that installs a couple of directories in
/home/patrick and /root.
---
# file: roles/common/tasks/main.yml
- name: dirs | Include vars
include_vars: main.yml
- name: dirs | Create some directories
file:
dest: "{{ item.base }}/{{ item.usr }}/{{ item.dirs }}"
mode: 0750
owner: "{{ item.usr }}"
group: "{{ item.usr }}"
state: directory
with_items: test
---
# file: roles/common/vars/main.yml
test:
- usr: patrick
base: /home
- usr: root
base: /
- dirs: test1
- dirs: test2
When I run this with:
$ ansible-playbook -v -i stage site.yml
I get:
TASK: [common | dirs | Create some directories]
*******************************
fatal: [test.local] => One or more undefined variables: 'str object' has
no attribute 'base'
I'm guessing that the issue is in vars/main.yml file but lots of
Googling and staring at Github/Galaxy examples did not reveal a
solution. Can anyone please enlighten me a bit?
Thanks,
Patrick
--
You received this message because you are subscribed to the Google Groups "Ansible
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/540F8975.4090403%40puzzled.xs4all.nl.
For more options, visit https://groups.google.com/d/optout.