Read this in other languages: English, 日本語.
For this last exercise instead of prescriptive step-by-step walkthrough a framework of objectives with hints for each step will be provided.
Demonstrate the removal of a node from the pool. Build a Playbook that:
Using your text editor of choice create a new file called disable-pool-member.yml
.
[student1@ansible ~]$ nano disable-pool-member.yml
vim
andnano
are available on the control node, as well as Visual Studio and Atom via RDP
Enter the following play definition into disable-pool-member.yml
:
---
- name: Disabling a pool member
hosts: lb
connection: local
gather_facts: false
Add a tasks section and then set a fact for the provider. Once you set the provider you can re-use this key in future tasks instead of giving the server/user/password/server_port and validate_certs info to each task.
tasks:
- name: Setup provider
set_fact:
provider:
server: "{{private_ip}}"
user: "{{ansible_user}}"
password: "{{ansible_password}}"
server_port: 8443
validate_certs: false
Now in the next task you can use provider as follows:
f5networks.f5_modules.bigip_device_info:
provider: "{{provider}}"
gather_subset:
- ltm-pools
You DO NOT need to pass the server_ip/user/password etc. for each module going forward
---
- name: "Disabling a pool member"
hosts: lb
gather_facts: false
connection: local
Next, add a task for the objective listed below:
HINT: Try using the bigip_device_info module from Exercise 1.1
Next, add a task for the objective listed below:
HINT:
Find a way to loop
on the output from the above step. Remember to also use the debug module
Next, add a task for the objective listed below:
HINT: An easy way to set fact variables within a Playbook dynamically is using the set_fact module
Next, add a task for the objective listed below:
HINT: Remember to use the debug and refer Exercise 1.4
Next, add a task for the objective listed below:
HINT: Use the prompts module</a>
Next, add a task for the objective listed below:
HINT: Remember to use when conditions and loops and BIG-IP pool member module
Run the playbook - exit back into the command line of the control host and execute the following:
[student1@ansible ~]$ ansible-playbook disable-pool-member.yml
The output will look as follows.
[student1@ansible ~]$ ansible-playbook disable-pool-member.yml
PLAY [Disabling a pool member] *******************************************************************************
TASK [Setup provider] *******************************************************************************
ok: [f5]
TASK [Query BIG-IP facts] *****************************************************
changed: [f5]
TASK [Display Pools available] ************************************************
ok: [f5] => (item=http_pool) => {
"msg": "http_pool"
}
TASK [Store pool name in a variable] ******************************************
ok: [f5] => (item=None)
ok: [f5]
TASK [Show members belonging to pool http_pool] *******************************
ok: [f5] => (item=node1:80) => {
"msg": "node1:80"
}
ok: [f5] => (item=node2:80) => {
"msg": "node2:80"
}
TASK [pause] ******************************************************************
[pause]
To disable a particular member enter member with format member_name:port
To disable all members of the pool enter 'all':
node1:80
TASK [Disable ALL pool members] ***********************************************
skipping: [f5] => (item=node1:80)
skipping: [f5] => (item=node2:80)
TASK [Disable pool member node1:80] *******************************************************************************
changed: [f5]
PLAY RECAP *******************************************************************************
f5 : ok=7 changed=2 unreachable=0 failed=0
The solution will be provided by the instructor if you are stuck. The GUI should show something similar to the following with a black diamond indicating the specified node was forced offline.
– You have finished this exercise. Click here to return to the lab guide