I have eventually found out what was wrong.
The double {{ }} and the double quote were missing in the playbook.yml, I 
didn't notice at first.


playbook.yml
---
# file: queueservers.yml
- name: Configure all MessageQueue servers
  hosts: queueservers
  sudo: yes
  roles:
    - { role: django, test: fakeuser', project:* "{{web_project}}"* }
 

Le mercredi 16 avril 2014 06:07:13 UTC+8, Rémy Saissy a écrit :
>
> 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: [email protected]: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}}"
>
>
>
>

-- 
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/23475205-df66-496f-90f6-477ff73013ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to