I think what you are looking for are parameterized roles.

http://docs.ansible.com/playbooks_roles.html#roles, look for "parameterized
roles".


- James


On Tue, Feb 25, 2014 at 6:08 PM, Mark Butler <[email protected]>wrote:

> I am generating some supervisor files from templates - but my services
> (roles) have dependencies on other services. So because the template uses
> the variable name instead of it picking "theServiceThatServiceADependsOn"
> and "ServiceA" as the names it picks "ServiceA" and "ServiceA" both times.
> I am guessing this is to do with variable scoping - that the var name in
> the dependent service is getting overridden?
>
> What's the easiest way around this? Is there some way to pass in variables
> when I call my template, just like a function call in a conventional
> language? I wondered whether I can just have a vars block in my action, but
> I checked out a load of Ansible scripts from github, so I can search them
> to find solutions to my problems, but I can't see anyone else doing that?
>
> Also I need to trigger supervisorctl in several different roles - we
> decided restarting supervisor was a bad idea because it will restart
> existing running services so I am doing this:
>
> - name: myservice | Get supervisor to re-read configs
>   action: command supervisorctl reread
>
> - name: myservice | Trigger a supervisor update
>   action: command supervisorctl update
>
> - name: myservice | Get supervisor to restart service
>   action: command supervisorctl restart {{ name }}
>
> Is there any way I can specify this in one place? A role ought to be able
> to do it but I need to pass an argument in (name) - I am thinking of this
> as a function?
>
> thanks!
>
> M
>
> --
> 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/CAC_tV5-ar9mnZgeV3ENj%3D1tNUnA0JuwUMo0KEaCdSCCZh5a_2w%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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/CAJvmrNN4MZ2pc_9AYJJ2_HRtfyi2UxhhsgZtR%2BnTbfkK9QLEQQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to