ansible-inventory

Running a playbook on multiple host groups one at a time

元气小坏坏 提交于 2019-11-30 15:15:47
I want to run a playbook containing some roles on multiple host groups I create dynamically with the group_by module. I'm able to do it like the example below (ping replacing my actual role). I was wondering if there is a way to run each group separately in a loop instead of listing all instance ids. I don't want to create a duplicate line with every instance id. The purpose here is to deploy to one instance in every data center at a time instead of running all with a low serial which takes a long time. There might be a different way of doing it, I don't want to create static groups in the

Ansible - read inventory hosts and variables to group_vars/all file

女生的网名这么多〃 提交于 2019-11-29 22:20:35
I have a dummy doubt that keeps me stuck for a long time. I have a very banal inventory file with hosts and variables: [lb] 10.112.84.122 [tomcat] 10.112.84.124 [jboss5] 10.112.84.122 ... [tests:children] lb tomcat jboss5 [default:children] tests [tests:vars] data_base_user=NETWIN-4.3 data_base_password=NETWIN data_base_encrypted_password= data_base_host=10.112.69.48 data_base_port=1521 data_base_service=ssdenwdb data_base_url=jdbc:oracle:thin:@10.112.69.48:1521/ssdenwdb The problem is that I need to access all these hosts and variables, in the inventory file, from the group_vars/all file. I

Running a playbook on multiple host groups one at a time

China☆狼群 提交于 2019-11-29 21:56:16
问题 I want to run a playbook containing some roles on multiple host groups I create dynamically with the group_by module. I'm able to do it like the example below (ping replacing my actual role). I was wondering if there is a way to run each group separately in a loop instead of listing all instance ids. I don't want to create a duplicate line with every instance id. The purpose here is to deploy to one instance in every data center at a time instead of running all with a low serial which takes a

Ansible - read inventory hosts and variables to group_vars/all file

南楼画角 提交于 2019-11-28 18:58:00
问题 I have a dummy doubt that keeps me stuck for a long time. I have a very banal inventory file with hosts and variables: [lb] 10.112.84.122 [tomcat] 10.112.84.124 [jboss5] 10.112.84.122 ... [tests:children] lb tomcat jboss5 [default:children] tests [tests:vars] data_base_user=NETWIN-4.3 data_base_password=NETWIN data_base_encrypted_password= data_base_host=10.112.69.48 data_base_port=1521 data_base_service=ssdenwdb data_base_url=jdbc:oracle:thin:@10.112.69.48:1521/ssdenwdb The problem is that I

accessing inventory host variable in ansible playbook

好久不见. 提交于 2019-11-27 21:51:19
I am using ansible 2.1. I have the following inventory host file and a role being called by a play that needs access to the host file variable. Any thoughts on how to access it (currently getting an error): host file [test1] test-1 ansible_ssh_host=abc.def.ghi.jkl ansible_ssh_port=1212 [test2] test2-1 ansible_ssh_host=abc.def.ghi.mno ansible_ssh_port=1212 [test3] test3-1 ansible_ssh_host=abc.def.ghi.pqr ansible_ssh_port=1212 test3-2 ansible_ssh_host=abc.def.ghi.stu ansible_ssh_port=1212 [all:children] test1 test2 test3 role I have tried accessing the role in the following fashions: {{ hostvars

How to prompt user for a target host in Ansible?

孤人 提交于 2019-11-27 21:36:42
I want to write a bootstrapper playbook for new machines in Ansible which will reconfigure the network settings. At the time of the first execution target machines will have DHCP-assigned address. The user who is supposed to execute the playbook knows the assigned IP address of a new machine. I would like to prompt the user for is value. vars_prompt module allows getting input from the user, however it is defined under hosts section effectively preventing host address as the required value. Is it possible without using a wrapper script modifying inventory file? The right way to do this is to

Reload Ansible's dynamic inventory

笑着哭i 提交于 2019-11-27 19:36:21
I'm using Ansible to setup EC2 instances and deploy an app. There's a hosts script which gathers tags related servers and groups info. I'd like to run these actions as a single playbook, so New instances are created if needed Hosts script loads inventory (including servers' facts) Deployment playbook works However, inventory loaded in advance so there is no servers/groups data if servers created/updated during the play. I can 1) separate provision and deployment playbooks 2) use add_host trick to emulate dynamic inventory when servers are updated, but there are drawbacks in those approaches.

Is it possible to write Ansible hosts/inventory files in YAML?

旧城冷巷雨未停 提交于 2019-11-27 07:35:22
In the best practices page, there is an example that uses hosts.yml for hosts files: In the docs, however, I can only find the INI syntax for writing hosts files. What is the syntax for the inventory files in YAML? Yes. It's been deprecated in version 0.6 in 2012 and reintroduced in a commit first included in version 2.1 in 2016. The example file on GitHub contains the guidelines and examples: Comments begin with the '#' character Blank lines are ignored Top level entries are assumed to be groups Hosts must be specified in a group's hosts: and they must be a key (: terminated) groups can have

How to prompt user for a target host in Ansible?

£可爱£侵袭症+ 提交于 2019-11-26 20:43:08
问题 I want to write a bootstrapper playbook for new machines in Ansible which will reconfigure the network settings. At the time of the first execution target machines will have DHCP-assigned address. The user who is supposed to execute the playbook knows the assigned IP address of a new machine. I would like to prompt the user for is value. vars_prompt module allows getting input from the user, however it is defined under hosts section effectively preventing host address as the required value.

Reload Ansible's dynamic inventory

放肆的年华 提交于 2019-11-26 19:56:11
问题 I'm using Ansible to setup EC2 instances and deploy an app. There's a hosts script which gathers tags related servers and groups info. I'd like to run these actions as a single playbook, so New instances are created if needed Hosts script loads inventory (including servers' facts) Deployment playbook works However, inventory loaded in advance so there is no servers/groups data if servers created/updated during the play. I can 1) separate provision and deployment playbooks 2) use add_host