Thank you all for suggestions, I've played a bit with Michaels playbook and
considered it legit.
Tried to simulate all possible bad configurations and deceided to go with
more explicit playbooks.
четверг, 16 октября 2014 г., 19:54:28 UTC+3 пользователь Michael Hoglan
написал:
>
> I had a kind of similar thing I did yesterday, I wanted the ability to use
> a variable in the role parameters, all the examples online always show
> static values being based to the role, and show roles being done in one
> line syntax.
>
> You can specify a role in a longer (not one line) form that allows it.
>
> Playbook
>
> ---
> - name: Test Role Vars
> hosts: localhost
> user: root
> vars:
> role: testrole
> var1: 1
> var2: 2
> roles:
> - role: "{{ role }}"
> roleVar1: "{{ var1 }}"
> roleVar2: "{{ var2 }}"
>
>
> Then have a role
>
> ---
> - debug: var=roleVar1
> - debug: var=roleVar2
>
>
> Then output
>
> PLAY [Test Role Vars]
> *********************************************************
>
> GATHERING FACTS
> ***************************************************************
> ok: [localhost]
>
> TASK: [testrole | debug var=roleVar1]
> *****************************************
> ok: [localhost] => {
> "roleVar1": "1"
> }
>
> TASK: [testrole | debug var=roleVar2]
> *****************************************
> ok: [localhost] => {
> "roleVar2": "2"
> }
>
> PLAY RECAP
> ********************************************************************
> localhost : ok=3 changed=0 unreachable=0
> failed=0
>
>
>
> Enjoy :)
>
> Thanks!
> Michael
>
> On Wednesday, October 15, 2014 1:14:58 AM UTC-5, Denis J. Cirulis wrote:
>>
>> Hello,
>>
>> let's suppose I have multiple groups of virtual guests, all are split to
>> different environments and are running 2 kinds of applications but with
>> different configurations.
>> In /etc/environment there env variables APPENV and APPNAME which contain
>> belonging to env like
>> APPENV=test,APPENV=stage,APPENV=dev,APPNAME=app1,APPNAME=app2 and so on.
>> There is one common role 'common' where all the provisioning and initial
>> configuration tasks and files are stored (this works good).
>> I want to populate roles list in top main.yml playbook with registering
>> these env variables as Ansible vars and use it in
>>
>> roles:
>> - { common }
>> - { $appenv_$appname }
>>
>> Is it normal or I do have to think of something different ?
>>
>
--
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/09fb4cfc-0565-4013-bec6-8e9dc64a4907%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.