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
...

View File

@ -1,8 +1,7 @@
#!/bin/bash
CONC="100"
REQU="100"
SLEEP_SECS="400"
CONC="200"
REQU="200"
BASE_URL="tower2.thezengarden.net"
AAP_JOB_ID="9"

View File

@ -1,8 +1,15 @@
---
tower_lab_hosts:
- lab-dev-1
- lab-dev-2
- lab-prod-1
- lab-prod-2
tower_launch_jobs:
- name: inmem_test
extra_vars:
tower_provision_host : "{{ tower_provision_host | default('localhost') }}"
tower_provision_host : "{{ tower_provision_host | default(tower_lab_hosts | random) }}"
...