[ansible-project] How to random roles

11 views
Skip to first unread message

Francis Santos

unread,
Jan 2, 2019, 8:53:44 AM1/2/19
to ansible...@googlegroups.com
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

---
- hosts: "{{ (groups['foo'] | shuffle)[0:1] }}"
  become: yes
  vars:
   - ansible_sudo_pass: ******
  roles: 
   - reboot  #one of the roles are reboot, but there are a few more and must be randomized

Any suggestions?
--

Atenciosamente/ Regards/ Mit freundlichen Grüßen

_________________________________
Frank Santos

Phone:

skav...@gmail.com

Francis Santos

unread,
Jan 3, 2019, 11:55:26 AM1/3/19
to Ansible Project
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
Reply all
Reply to author
Forward
0 new messages