Skip to content

Latest commit

 

History

History
 
 

1.4-add-pool-members

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Exercise 1: Adding members to a pool on F5

Table of Contents

Objective

Demonstrate use of the BIG-IP pool member module to tie web server nodes into the load balancing pool http_pool created in the previous exercises.

Guide

Step 1:

Using your text editor of choice create a new file called bigip-pool-members.yml.

[student1@ansible ~]$ nano bigip-pool-members.yml

vim and nano are available on the control node, as well as Visual Studio and Atom via RDP

Step 2:

Enter the following play definition into bigip-pool-members.yml:

---
- name: BIG-IP SETUP
  hosts: lb
  connection: local
  gather_facts: false
  • The --- at the top of the file indicates that this is a YAML file.
  • The hosts: lb, indicates the play is run only on the lb group. Technically there only one F5 device but if there were multiple they would be configured simultaneously.
  • connection: local tells the Playbook to run locally (rather than SSHing to itself)
  • gather_facts: false disables facts gathering. We are not using any fact variables for this playbook.

Step 3

Next, add the first task. This task will use the bigip_pool_member module configure the two RHEL web servers as nodes on the BIG-IP F5 load balancer.

{% raw %}

- name: BIG-IP SETUP
  hosts: lb
  connection: local
  gather_facts: false

  tasks:

  - name: ADD POOL MEMBERS
    bigip_pool_member:
      server: "{{private_ip}}"
      user: "{{ansible_user}}"
      password: "{{ansible_ssh_pass}}"
      server_port: "8443"
      state: "present"
      name: "{{hostvars[item].inventory_hostname}}"
      host: "{{hostvars[item].ansible_host}}"
      port: "80"
      pool: "http_pool"
      validate_certs: "no"
    loop: "{{ groups['webservers'] }}"

{% endraw %}

Explanation of each line within the task:

  • name: ADD POOL MEMBERS is a user defined description that will display in the terminal output.
  • bigip_pool_member: tells the task which module to use.

Next we have module parameters

  • The server: "{{private_ip}}" parameter tells the module to connect to the F5 BIG-IP IP address, which is stored as a variable private_ip in inventory
  • The user: "{{ansible_user}}" parameter tells the module the username to login to the F5 BIG-IP device with
  • Thepassword: "{{ansible_ssh_pass}}" parameter tells the module the password to login to the F5 BIG-IP device with
  • The server_port: 8443 parameter tells the module the port to connect to the F5 BIG-IP device with
  • The state: "present" parameter tells the module we want this to be added rather than deleted.
  • The name: "{{hostvars[item].inventory_hostname}}" parameter tells the module to use the inventory_hostname as the name (which will be host1 and host2).
  • The host: "{{hostvars[item].ansible_host}}" parameter tells the module to add a web server IP address already defined in our inventory.
  • The pool: "http_pool" parameter tells the module to put this node into a pool named http_pool
  • The validate_certs: "no" parameter tells the module to not validate SSL certificates. This is just used for demonstration purposes since this is a lab. Finally there is a loop parameter which is at the task level (it is not a module parameter but a task level parameter:
  • loop: tells the task to loop over the provided list. The list in this case is the group webservers which includes two RHEL hosts.

Step 4

Run the playbook - exit back into the command line of the control host and execute the following:

[student1@ansible ~]$ ansible-playbook bigip-pool-members.yml

Playbook Output

The output will look as follows.

[student1@ansible ~]$ ansible-playbook bigip-pool-members.yml

PLAY [BIG-IP SETUP] ************************************************************

TASK [ADD POOL MEMBERS] ********************************************************
changed: [f5] => (item=host1)
changed: [f5] => (item=host2)

PLAY RECAP *********************************************************************
f5                         : ok=1    changed=1    unreachable=0    failed=0

Solution

The finished Ansible Playbook is provided here for an Answer key. Click here: bigip-pool-members.yml.

Verifying the Solution

Login to the F5 with your web browser to see what was configured. Grab the IP information for the F5 load balancer from the lab_inventory/hosts file, and type it in like so: https://X.X.X.X:8443/

The pool will now show two members (host1 and host2). Click on Local Traffic-> then click on Pools. Click on http_pool to get more granular information. Click on the Members tab in the middle to list all the Members. f5members

You have finished this exercise. Click here to return to the lab guide