I would like to insert some hosts dynamically at the runtime of playbook/template execution.
At the moment, I can use the survey, however, I can only successfully insert just one server. When I try to put more than 1 server (list of 2 or more hosts), the playbook does not understand.
How can I dynamically place more than one server, at template runtime?
Just ie:
> ---
> - hosts: localhost
connection: local
gather_facts: false
>
> tasks:
> - name: add hosts from extra-vars to "temp" group
> add_host:
> name: "{{ item }}"
> groups: temp
>
> - hosts: temp
gather_facts: true
>
> tasks:
>
> - name: Show uptime
> shell: uptime
> register: uptime
>
> - name: Show results
> debug:
> msg: "{{ uptime.stdout }}"
>
>
var item = host1 host2 host3
Assuming you have an inventory that contains all the dynamic hosts, one "cleaner" way to do it is :
Now when you launch your template it will ask you to enter the targets hosts dynamically. Enter the needed hosts separated by comma. It also acceptes host patterns.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.