BigD_300005
Feb 09, 2018Cirrostratus
Ansible Dynamic node tasks
Is there a way in Ansible to get the node task to spin off multiple times without having to manually create 3 node tasks? I'd like to just have one playbook instead of multiple depending on how many nodes you need.
server_count = 3
i = 1
while i <= server_count:
node task stuff here
i = i + 1
- name: Create server [i]
bigip_node:
password: "{{ bigip_password }}"
server: "{{ ansible_host }}"
user: "{{ bigip_username }}"
partition: "{{ partition }}"
host: "{{ server[i]_ip }}"
name: "{{ server[i]_name }}"
validate_certs: "false"
state: "present"
delegate_to: localhost