Have a look at using separate group_vars files for common variables you can 
apply to more than one machine - see 
http://docs.ansible.com/ansible/intro_inventory.html#splitting-out-host-and-group-specific-data
Also, consider having different inventory files.  I have a different 
inventory for development, testing and each production environment.

Hope this helps,

Jon

On Monday, September 26, 2016 at 9:22:25 AM UTC+1, fanvalt wrote:
>
> Hello,
>
> I have an inventory file to install for one user many ways, it looks like 
> this:
>
> [USER1_DEV1]
> PARAM="[app1','1.0.1','1']"
>
> [USER1_DEV2]
> PARAM="['app1','1.1.0','5']"
>
> [USER1_REC1]
> PARAM="['app1','1.0.4','2']"
>
> [USER1_REC2]
> PARAM="['app1','1.1.0','6']"
>
> [USER1_PREREC1]
> PARAM="['app1','1.0.3','3']"
>
> [USER1_PREREC2]
> PARAM="['app1','1.0.3','7']"
>
> [USER1_DEV:children]
> USER1_DEV1
> USER1_DEV2
>
> [USER1_PREREC:children]
> USER1_PREREC1
> USER1_PREREC2
>
> [USER1_REC:children]
> USER1_REC1
> USER1_REC2
>
> [user1:children]
> USER1_DEV
> USER1_REC
> USER1_PREREC
>
> [linux1:children]
> user[1:10]
> produser[70:72]
>
> [user1:vars]
> ansible_user=user1
>
> [linux1:vars]
> ansible_host=linux1.fr.com
>
> [webservers:children]
> linux1
>
>
> So when running the ansible-playbook command, I do use the -l option to 
> decide what to deploy (-l USER1_REC in example).
> The issue is, that I have 10 users and 10 produsers, all working the same 
> way so I would have to duplicate all these lines again and again like:
> [user2:children]
> USER2_DEV
> USER2_REC
> USER2_PREREC
>
> etc ..
> but only the first lines are different:
> [USER1_DEV1]
> PARAM="[app1','1.0.1','1']"
>
> [USER2_DEV1]
> PARAM="[app1','2.0.1','1']"
>
> [USER1_DEV2]
> PARAM="[app1','1.0.1','1']"
>
> [USER2_DEV2]
> PARAM="[app1','1.1.1','1']"
>
> Is there a simple way to proceed for not writing all these lines ? Shall I 
> try to use a dynamic inventory file , could someone give me an example ?
> Regards
>

-- 
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/789d27bc-fcf8-4c18-a47f-90fbc6c19484%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to