Re: [ansible-project] Question: How to use the same host for multiple groups?
Hello, Finally we made it work using the following approach: Inventory file: Host1 mygroups='["groupA","groupB"]' Created two playbook files one with the tasks (PlaybookTasks.yml) and one that does an iteration (Playbook.yml) Playbook.yml: --- - hosts: all tasks: - include: PlaybookTasks.yml mygroup="{{ item }}" with_items: "{{ mygroups}}" PlaybookTasks.yml: - name: Include vars include: "group_vars/{{ group}}/vars.yml" - name: Download application . The structure of the host_vars and group_vars remained as I initially explained. Thank you all for the support and your prompt answers. Best Regards, Konstantinos -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/9837e3b6-5cc7-4189-9491-a5789133a7aa%40googlegroups.com.
Re: [ansible-project] Question: How to use the same host for multiple groups?
using group_vars in vars_files is confusing as those are already loaded and might produce unintended consequences, what you really want is per play vars instead of inventory vars that relate to your application -- -- Brian Coca -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CACVha7fq0%3DvCwr2vKWom%3DpySdGS%3DV8_AbfzaWHi5AgFQsx%3DuKA%40mail.gmail.com.
Re: [ansible-project] Question: How to use the same host for multiple groups?
sorry, second host should be 'GroupB' in the playbook On Mon, Jan 13, 2020 at 10:21 AM Austin Wolfson wrote: > This is how i've been doing it (not sure if you can implement) > > inventory: > > [GroupA] > host1 > [GroupB] > host1 > > [Groups:children] . #throw all your vars that are the same for each group > here > GroupA > GroupB > > - > * make group_vars for each group name with specific variables and then > calli in your playbook: > > - hosts: 'GroupA' > vars_files: > - ../group_vars/GroupA > roles: > - blah blah blah > > - hosts: 'GroupA' > vars_files: > - ../group_vars/GroupB > roles: > - blah blah blah > > On Mon, Jan 13, 2020 at 10:11 AM Konstantinos Tzevelekidis < > ktzeveleki...@trading-point.com> wrote: > >> Hello, >> >> This is what I did and it didn't work. Different groups mean different >> configuration for my application (that is the reason of such distinction), >> so if I use HostA under both groups, it doesn't do the deployment twice in >> the same host but only for the last one. >> >> Best Regards, >> Konstantinos >> >> -- >> 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 ansible-project+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/ansible-project/d3e09cc9-e792-4c63-8077-35be809ee8f2%40googlegroups.com >> . >> > > > -- > Austin Wolfson > DevOps Engineer, CEH > Interactions, LLC > -- Austin Wolfson DevOps Engineer, CEH Interactions, LLC -- *** This e-mail and any of its attachments may contain Interactions LLC proprietary information, which is privileged, confidential, or subject to copyright belonging to the Interactions LLC. This e-mail is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution, copying, or action taken in relation to the contents of and attachments to this e-mail is strictly prohibited and may be unlawful. If you have received this e-mail in error, please notify the sender immediately and permanently delete the original and any copy of this e-mail and any printout. Thank You. *** -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAP6t4MsekHBBwoB_pHnrzu6KpTW6Ei4qF6vUuRTKVahEGGTVuA%40mail.gmail.com.
Re: [ansible-project] Question: How to use the same host for multiple groups?
This is how i've been doing it (not sure if you can implement) inventory: [GroupA] host1 [GroupB] host1 [Groups:children] . #throw all your vars that are the same for each group here GroupA GroupB - * make group_vars for each group name with specific variables and then calli in your playbook: - hosts: 'GroupA' vars_files: - ../group_vars/GroupA roles: - blah blah blah - hosts: 'GroupA' vars_files: - ../group_vars/GroupB roles: - blah blah blah On Mon, Jan 13, 2020 at 10:11 AM Konstantinos Tzevelekidis < ktzeveleki...@trading-point.com> wrote: > Hello, > > This is what I did and it didn't work. Different groups mean different > configuration for my application (that is the reason of such distinction), > so if I use HostA under both groups, it doesn't do the deployment twice in > the same host but only for the last one. > > Best Regards, > Konstantinos > > -- > 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 ansible-project+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/d3e09cc9-e792-4c63-8077-35be809ee8f2%40googlegroups.com > . > -- Austin Wolfson DevOps Engineer, CEH Interactions, LLC -- *** This e-mail and any of its attachments may contain Interactions LLC proprietary information, which is privileged, confidential, or subject to copyright belonging to the Interactions LLC. This e-mail is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution, copying, or action taken in relation to the contents of and attachments to this e-mail is strictly prohibited and may be unlawful. If you have received this e-mail in error, please notify the sender immediately and permanently delete the original and any copy of this e-mail and any printout. Thank You. *** -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAP6t4Mv_dw-P5vqKQ5NA4J%2BjspVV6jwhsbb36WVpHaziU%3DA0eQ%40mail.gmail.com.
Re: [ansible-project] Question: How to use the same host for multiple groups?
Hello, This is what I did and it didn't work. Different groups mean different configuration for my application (that is the reason of such distinction), so if I use HostA under both groups, it doesn't do the deployment twice in the same host but only for the last one. Best Regards, Konstantinos -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d3e09cc9-e792-4c63-8077-35be809ee8f2%40googlegroups.com.
Re: [ansible-project] Question: How to use the same host for multiple groups?
that is kind of like making 4 left turns to go straight, unsure why you would have the distinction in the first place, ... just use hostA throughout. -- -- Brian Coca -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CACVha7eRPqixRq%3Dzx0Wi9nSVbOVobu8vrQ5qC%3DA8%3D8ZHQZrgVQ%40mail.gmail.com.
Re: [ansible-project] Question: How to use the same host for multiple groups?
Hello, What I want to have is one host folder (i.e. Host1) which will contain a vars.yml that will define the actual ansible_host (i.e. "1.2.3.4"). So, in the inventory I will need to have: [GroupA] host1A ansible_host=Host1 [GroupB] host1B ansible_host=Host1 where the ansible_host will take the name of the host folder (i.e. Host1) and will find the actual value for the ansible_host (i.e. "1.2.3.4") from the vars.yml. What I understood is that by using the ansible_host variable in the inventory I have to give the actual value (i.e. "1.2.3.4") and it cannot take let's say a host alias (i.e. Host1). Is there any other way to define which host folder to check in order to retrieve the ansible_host variable? Best Regards, Konstantinos -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/6672d0f9-a84a-4e99-8602-05e31a1b089c%40googlegroups.com.
Re: [ansible-project] Question: How to use the same host for multiple groups?
ansible_host is just a variable, you can define it anywhere you want. -- -- Brian Coca -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CACVha7e_JY4LHOs6On%3D5vaWTK6se%3Dj47z5_fUmywfG2wyrUeFw%40mail.gmail.com.
Re: [ansible-project] Question: How to use the same host for multiple groups?
Hello, Thanks a lot for your help! From what I understand is that the ansible_host should be the actual hostname (dns entry). Is there any way to pass the to the ansible_host the name of an entry in the host_vars? For example, I have in the host_vars directory, the folder Host1 where it has a vars.yml where one of the variables is ansible_host: "1.2.3.4". In order to use your approach I will need to add the ansible_host inline in the inventory like this: [GroupA] host1A ansible_host="1.2.3.4" [GroupB] host1B ansible_host="1.2.3.4" What I would like to do is to have something like this [GroupA] host1A ansible_host=Host1 [GroupB] host1B ansible_host=Host1 Is this feasible? If it is not feasible, I will have to add all the variables in the inventory and this will not be so clean. Best Regards, Konstantinos -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/3f453be4-1f87-48f3-bd80-95d679787761%40googlegroups.com.
Re: [ansible-project] Question: How to use the same host for multiple groups?
sorry, second entry should be: host1B ansible_host=hosta -- -- Brian Coca -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CACVha7cym_d-S8wqn2ZkqhZNA2yzc4oCx27sujv7re1eMNLmXw%40mail.gmail.com.
Re: [ansible-project] Question: How to use the same host for multiple groups?
There are many ways, simplest might be using host aliases, but this might be inefficient: [GroupA] host1A ansible_host=hosta [GroupB] host1A ansible_host=hosta Setting up the variables at play/role level might make more sense, Ansible's inventory is meant to give a 'full picture' of the host and any duplicate variables will be merged, groups are just a tag and convenience to assign variables and select hosts, not a real entity in a playbook, at that point there is only Hosts and Tasks, it doesn't matter that you use GroupA to target a host, the host is still a member of all the groups it is a member of. -- -- Brian Coca -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CACVha7cTpe6c9eA69wPmT%2BhQ3S5X3jQT9Oudv%2BiqYxNWFc_2%3DQ%40mail.gmail.com.
[ansible-project] Question: How to use the same host for multiple groups?
Hello, I have the following inventory: Test.inventory [GroupA] Host1 [GroupB] Host1 GroupA and GroupB contain the same variables but with different values (e.g. filename). It seems that every time the playbook runs for this inventory, it does the steps once for the host (i.e. only for one of the groups). What I want to achieve, is to run the playbook for Host1 twice (once for each group). Is there any way to achieve this (maybe via roles)? Am I misusing the groups module? The Ansible version I am using is 2.3. Best Regards, Konstantinos -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c03ae460-f1ea-4023-881a-ae80364aeaa1%40googlegroups.com.