2.2.3. Modify Pool Member State

It is a common task to modify pool member states to make application updates. You will pass variables using extra-vars to override playbook variables. Use the -e, or --extra-vars argument of ansible-playbook

Create pool member forced offline playbook

  1. Create a playbook offline.yaml.

    • Type nano playbooks/offline.yaml
    • Type the following into the playbooks/offline.yaml file.
    ---
    
    - name: "Pool member offline"
      hosts: bigips
      gather_facts: False
      connection: local
    
      vars:
        pool: ""
        pmhost: ""
        pmport: ""
        state: "present"
    
      environment: "{{ bigip_env }}"
    
      tasks:
        - name: Modify pool member state
          bigip_pool_member:
            state: "{{ state }}"
            session_state: "disabled"
            monitor_state: "disabled"
            host: "{{ pmhost }}"
            port: "{{ pmport }}"
            pool: "{{ pool }}"
    
  2. Run this playbook enable pool member.

    • Type ansible-playbook playbooks/offline.yaml -e @creds.yaml --ask-vault-pass -e pool="hack11_pl" -e pmhost="10.1.20.17" -e pmport="80"

    You will be prompted for a password before executing the playbook. Password is password. If successful, you should see config for virtual servers, pools and nodes.

    Note

    ansible-vault is used to store passwords and other sensitive info for use by ansible playbooks.

    Type cat creds.yaml to confirm vault file is encrypted. Type ansible-vault view creds.yaml to view the vault file. Type ansible-vault edit creds.yaml to modify the vault file.

  3. Verify if pool member 10.1.20.17 is forced offline

    • Select Local Traffic -> Pools -> Pool List -> hack11_pl -> Members
    ../../_images/image035.png

Create pool member enable playbook

  1. Create a playbook enable.yaml.

    • Type nano playbooks/enable.yaml
    • Type the following into the playbooks/enable.yaml file.
    ---
    
    - name: "Pool member enable"
      hosts: bigips
      gather_facts: False
      connection: local
    
      vars:
        pool: ""
        pmhost: ""
        pmport: ""
        state: "present"
    
      environment: "{{ bigip_env }}"
    
      tasks:
        - name: Modify pool member state
          bigip_pool_member:
            state: "{{ state }}"
            session_state: "enabled"
            monitor_state: "enabled"
            host: "{{ pmhost }}"
            port: "{{ pmport }}"
            pool: "{{ pool }}"
    
  2. Run this playbook enable pool member.

    • Type ansible-playbook playbooks/enable.yaml -e @creds.yaml --ask-vault-pass -e pool="hack11_pl" -e pmhost="10.1.20.17" -e pmport="80"
  3. Verify if pool member 10.1.20.17 is enabled

    • Select Local Traffic -> Pools -> Pool List -> hack11_pl -> Members