I gotta random both the hosts and the roles.
I successfully randomed the hosts, but I not getting the roles to random.
Here is what I got
Are you trying to randomly select a role, randomly select a host, then run the selected role on the selected host?
No, the picture is that the role is not on the hosts.
First I random a host (that script does that).
Once a host is selected then the role is randomized.
I figured out.
I came with this:
- hosts: “{{ (groups[‘foo’] | shuffle)[0:1] }}” #THIS SCRIPT RANDOMS THE HOST
become: true
vars:
- ansible_sudo_pass: *******
roles:
- role: “{{ [‘reboot’,‘shutdown’] | random }}” #THIS SCRIPT RANDOMS THE ROLE
So I guess we can consider this issue solved.
Thanks anyways, guys