Hi all,

I've got a playbook that uses variables to create a load balanced pool and 
the required members on our test F5 BigIP.

I've got the basics working without issue, however, the number of members 
of a pool for any given run is not a fixed number and could range from 1 up 
to say 10.

I'm running Ansible Tower and invoking the template via tower-cli. I'm 
using extra-vars to provide realip and realserver and looped through. The 
default values are set to null so I was hoping to loop through the list 
until a null value for item.host is observed. I'm not sure if this is the 
best way to deal with this, it's the first time that I've tried to deal 
with variable lists that are not fixed in number.

Here's my current code, any help would be greatly appreciated.

Cheers
Spence

---

- name: Create a VIP, pool and pool members
 hosts: all
 connection: local

  vars:
   provider:
     password: Password
     server: IP
     user: username
     validate_certs: no
     server_port: port

  tasks:
   - name: Create a pool
     bigip_pool:
       provider: "{{ provider }}"
       lb_method: ratio-member
       name: "{{ service }}"
       slow_ramp_time: 120
     delegate_to: localhost

    - name: Add members to pool
     bigip_pool_member:
       provider: "{{ provider }}"
       description: "webserver {{ item.name }}"
       host: "{{ item.host }}"
       name: "{{ item.name }}"
       pool: "{{ service }}"
       port: "{{ lbport }}"
     loop:
       - { host: "{{ realip1 }}",  name: "{{ realserver1 }}" }
       - { host: "{{ realip2 }}",  name: "{{ realserver2 }}" }
       - { host: "{{ realip3 }}",  name: "{{ realserver3 }}" }
       - { host: "{{ realip4 }}",  name: "{{ realserver4 }}" }
       - { host: "{{ realip5 }}",  name: "{{ realserver5 }}" }
       - { host: "{{ realip6 }}",  name: "{{ realserver6 }}" }
       - { host: "{{ realip7 }}",  name: "{{ realserver7 }}" }
       - { host: "{{ realip8 }}",  name: "{{ realserver8 }}" }
       - when: item.host != ""
       - delegate_to: localhost


-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/cf8e3969-eeaf-422b-9fbd-4ca36d19d660%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to