Forum Discussion
Ankur_Mathur
Oct 23, 2018Nimbostratus
Following is my playbook:
(f5_poc) -bash-4.2$ cat f5_upgrade.yaml-
hosts: f5
connection: local
gather_facts: False
vars_files:
- creds.yml
- "{{upgrade_info}}"
tasks:
Configure User
- name: Configure User
tags:
- run
set_fact:
provider:
user: "{{username}}"
password: "{{password}}"
validate_certs: no
admin_user:
user: admin
password: admin
timeout: 360
validate_certs: no
delegate_to: localhost
Fetch the master key from the vm
- name: Fetch the master key from vm
tags:
- run
bigip_command:
provider: "{{provider}}"
server: "{{ ip_addr }}"
commands: shell f5mku -K
register: cmd_output
delegate_to: localhost
- name : Setting the master key
tags:
- run
set_fact:
master_key : "{{ cmd_output.stdout | regex_replace('^..|..$', '') }}"
Download the software image on host
- name: Upload the software image on host
tags:
- dont
bigip_software_image:
image: /tmp/BIGIP-12.1.3.7-0.0.2.iso
provider: "{{provider}}"
server: 172.18.224.4
force: yes
state: present
server_port: 443
transport: cli
ssh_keyfile: /afs/athena.unimelb.edu.au/user/a/ankurm/.ssh/known_hosts
delegate_to: localhost
Set the hostname
- name: Set the hostname
tags:
- run
bigip_hostname:
provider: "{{provider}}"
server: "{{ip_addr}}"
hostname: "{{vm_to_upgrade}}.unimelb.net.au"
validate_certs: no
delegate_to: localhost
Create the UCS file to restore at the end
- name: Download a new UCS file
tags:
- run
bigip_ucs_fetch:
provider: "{{provider}}"
server: "{{server_name}}"
src: "{{ vm_to_upgrade }}-init.ucs"
dest: "/tmp/{{ vm_to_upgrade }}.ucs"
delegate_to: localhost
Shut down current Guest:
modify vcmp guest lb1-266-1-dev state configured
- name: Shut down current Guest
tags:
- run
bigip_vcmp_guest:
provider: "{{provider}}"
server: "{{server_name}}"
name: "{{vm_to_upgrade}}"
state: disabled
mgmt_address: "{{ ip_addr }}/{{ nw_bits }}"
mgmt_network: bridged
mgmt_route: "{{gateway}}"
delegate_to: localhost
Delete Guest:
delete vcmp guest lb3-396-2-dev
- name: Delete the vcmp guest & delete the virtual disk
tags:
- run
bigip_vcmp_guest:
provider: "{{provider}}"
server: "{{server_name}}"
name: "{{vm_to_upgrade}}"
state: absent
delete_virtual_disk: yes
delegate_to: localhost
Create new Guest:
- name: Create a new guest
tags:
- run
bigip_vcmp_guest:
provider: "{{provider}}"
server: "{{server_name}}"
name: "{{vm_to_upgrade}}"
state: configured
mgmt_address: "{{ ip_addr }}/{{ nw_bits }}"
mgmt_network: bridged
mgmt_route: "{{gateway}}"
allowed_slots: "{{allowed_slots}}"
number_of_slots: "{{number_of_slots}}"
min_number_of_slots: "{{min_number_of_slots}}"
cores_per_slot: "{{cores_per_slot}}"
initial_image: "{{sw_image}}"
vlans: "{{vlans}}"
delegate_to: localhost
Power up the Guest:
- name: Power Up new guest
tags:
- run
bigip_vcmp_guest:
provider: "{{provider}}"
server: "{{server_name}}"
name: "{{vm_to_upgrade}}"
state: present
mgmt_address: "{{ ip_addr }}/{{ nw_bits }}"
mgmt_network: bridged
mgmt_route: "{{gateway}}"
delegate_to: localhost
Set the hostname
- name: Set the hostname
tags:
- run
bigip_hostname:
provider: "{{admin_user}}"
server: "{{ip_addr}}"
hostname: "{{vm_to_upgrade}}.unimelb.net.au"
delegate_to: localhost
Disable Initial Setup of the guest
- name: Login and Disable initial config
tags:
- run
bigip_sys_global:
provider: "{{admin_user}}"
gui_setup: no
server: "{{ip_addr}}"
delegate_to: localhost
Save running Config
- name: Save the running configuration of the BIG-IP
tags:
- run
bigip_config:
provider: "{{admin_user}}"
save: yes
server: "{{ip_addr}}"
delegate_to: localhost
Provision Modules
- name: Provision modules
tags:
- run
bigip_provision:
provider: "{{admin_user}}"
server: "{{ip_addr}}"
module: "{{item}}"
state: present
level: nominal
loop: "{{provision_modules}}"
delegate_to: localhost
Reinstate the master key
- name: Reinstate the master key
tags:
- run
bigip_command:
provider: "{{admin_user}}"
server: "{{ip_addr}}"
commands: "shell f5mku -r {{master_key}}"
commands: shell f5mku -r GZIwzAaSeTu/EIcOHqT7FQ==
delegate_to: localhost
Upload and install the UCS file
- name: Upload the UCS file
tags:
- run
bigip_ucs:
provider: "{{admin_user}}"
server: "{{ip_addr}}"
force: yes
state: present
ucs: "/tmp/{{ vm_to_upgrade }}-init.ucs"
delegate_to: localhost
Upload and install the UCS file
- name: Install the UCS file
tags:
- run
bigip_ucs:
provider: "{{admin_user}}"
server: "{{ip_addr}}"
force: no
state: installed
ucs: "/tmp/{{ vm_to_upgrade }}-init.ucs"
no_license: yes
no_platform_check: yes
include_chassis_level_config: no
delegate_to: localhost
- name: Sync Group
tags:
- run
bigip_configsync_action:
provider: "{{provider}}"
device_group: "{{item}}"
sync_device_to_group: yes
server: "{{sync_device}}"
overwrite_config: yes
loop: "{{sync_groups}}"
delegate_to: localhost
Remove the uploaded UCS file
- name: Remove the uploaded UCS file
tags:
- run
bigip_ucs:
provider: "{{provider}}"
server: "{{ip_addr}}"
state: absent
ucs: "{{ vm_to_upgrade }}-init.ucs"
delegate_to: localhost