Hi,
I want ot call the same role several time with different parameters in a playbook.
the variables I use are a dictionnary defined in group_vars.
I cannot use these variables defined in a group_vars file when listing roles in a playbook.
Is it a normal behaviour? How should I do in order to achieve it?
Thanks,
Regards.
group_vars/all
---
web_project:
user: 'existinguser'
repo: g...@gitrepo.com:examplecom.git
root: /var/www/virtualhosts/examplecom/
playbook.yml
---
# file: queueservers.yml
- name: Configure all MessageQueue servers
hosts: queueservers
sudo: yes
roles:
- { role: django, test: fakeuser', project: web_project }
roles/django/tasks/main.yml:
---
- name: test
shell: 'echo foobar'
sudo_user: "{{project.user}}"
--> It tries to execute the shell command as {{project.user}}'s user (in spite of 'existinguser').
and when I try with:
roles/django/tasks/main.yml:
---
- name: test
shell: 'echo foobar'
sudo_user: "{{test}}"
--> It tries to execute the shell command as 'fakeuser''s user, as expected.
The expected behaviour also happens when I use the following:
roles/django/tasks/main.yml:
---
- name: test
shell: 'echo foobar'
sudo_user: "{{web_project.user}}"