Exercise 1.7: Using the bigip_config module to save running config

Objective

Demonstrate use of the BIG-IP config module to save the running configuration to disk

Guide

Step 1

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

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

``vim`` and ``nano`` are available on the control node

Step 2

Enter the following play definition into bigip-config.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: f5, indicates the play is run only on the F5 BIG-IP device
  • connection: local tells the Playbook to run locally (rather than SSHing to itself)
  • gather_facts: no disables facts gathering. We are not using any fact variables for this playbook.

Step 3

Next, add the task. This task will use the bigip-config to save the running configuration to disk

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

  tasks:

  - set_fact:
     provider:
      server: "{{private_ip}}"
      user: "{{ansible_user}}"
      password: "{{ansible_ssh_pass}}"
      server_port: 8443
      validate_certs: no

  - name: SAVE RUNNING CONFIG ON BIG-IP
    bigip_config:
      provider: "{{provider}}"
      save: yes
  • name: SAVE RUNNING CONFIG ON BIG-IP is a user defined description that will display in the terminal output.
  • bigip_config: tells the task which module to use.
  • The save: "yes"" parameter tells the module to save the running-config to startup-config. This operation is performed after any changes are made to the current running config. If no changes are made, the configuration is still saved to the startup config. This option will always cause the module to return changed

Step 4

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

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

Playbook Output

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

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

TASK [SAVE RUNNING CONFIG ON BIG-IP] ************************************************************************************************************************
changed: [f5]

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-config.yml.

You have finished this exercise.