add support to generate a random host to run on

This commit is contained in:
Chris Hammer
2022-03-01 01:21:05 -05:00
parent 05f1a5992f
commit c4380dedb3
3 changed files with 34 additions and 4 deletions

24
pick-a-host.yml Normal file
View File

@ -0,0 +1,24 @@
---
- name: get random host to run on
hosts: all
connection: local
gather_facts: no
become: no
tasks:
- name: Show Ansible play hosts
debug:
var: play_hosts
run_once : yes
delegate_to : localhost
- name: Pick a random host
debug:
msg: "ansible-playbook job-launch.yml -u root -e tower_provision_host={{ play_hosts | random }}"
run_once : yes
delegate_to : localhost
...