ANSIBLE

Training Course for Ansible Automation

This project is maintained by DLT-Solutions-JBoss

Exercise 1.2 - Adding nodes to F5 BIG-IP

Table of Contents

Objective

Demonstrate use of the BIG-IP node module to add two RHEL (Red Hat Enterprise Linux) web servers as nodes for the BIG-IP load balancer.

Guide

Step 1:

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

[student1@ansible ~]$ nano bigip-node.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-node.yml:

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

Step 3

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

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

  tasks:

  - name: CREATE NODES
    bigip_node:
      server: "{{private_ip}}"
      user: "{{ansible_user}}"
      password: "{{ansible_ssh_pass}}"
      server_port: "8443"
      host: "{{hostvars[item].ansible_host}}"
      name: "{{hostvars[item].inventory_hostname}}"
      validate_certs: "no"
    loop: "{{ groups['webservers'] }}"

A loop will repeat a task on a list provided to the task. In this case it will loop twice, once for each of the two web servers.

Step 4

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

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

Playbook Output

The output will look as follows.

[student1@ansible]$ ansible-playbook bigip-node.yml

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

TASK [CREATE NODES] ************************************************************
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-node.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 list of nodes can be found by navigating the menu on the left. Click on Local Traffic-> then click on Nodes. f5web

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