For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

PG0581's avatar
PG0581
Icon for Cirrus rankCirrus
Aug 29, 2018

Ansible - Looping vars_prompt question to create LTM pool

I'm trying to create a playbook to create a pool, and the variables of the pool configuration are provided by the user.

I have it working configuring just one pool member, but in most cases, there are multiple pool members. Any ideas on how I could loop the below question, and exit the loop once the user has entered all of the pool members?

   - name: "pool_member"
      prompt: "Enter the pool member IP and port [enter as IP:Port]"
      private: no
    - name: "pool_address"
      prompt: "Enter the pool member address"

Also, once all of the user's input has been collected, how would you then pass it into the implementation? Here's what I have so far for that section:

 - name: Implementation
    bigip_command:
      server: "{{ inventory_hostname }}"
      user: "{{ remote_username }}"
      password: "{{ remote_passwd }}"
      commands:
        - "tmsh create ltm pool {{ pool_name }} { load-balancing-mode {{ pool_lb_mode }} members add { {{ pool_member }} { address {{ pool_address }} } } monitor {{ pool_monitor }} }"
      validate_certs: no
    delegate_to: localhost

1 Reply

  • Hello,

    One questions, why are not using the module bigip_pool_member?

    - name: ADD POOL MEMBER 
      bigip_pool_member:
        state: present
        server: "{{ f5_server }}"
        user: "{{ f5_user }}"
        password: "{{ f5_pass }}"
        partition: "{{ f5_partition }}"
        pool: "{{ f5_pool_name }}"
        host: "{{ item.f5_node_host }}"
        name: "{{ item.f5_node_name }}"
        port: "{{ f5_pool_port }}"
        validate_certs: no
      delegate_to: localhost
      with_items: "{{ f5_nodes_list }}" 
    

    You can use "with items" for looping and define a list with the nodes, example fo f5_nodes_list:

    f5_nodes_list:
      - f5_node_name: test_ansible-1
        f5_node_host: 1.1.1.3
      - f5_node_name: test_ansible-2
        f5_node_host: 1.1.1.4