Forum Discussion
Unable to use ansible playbook to upgrade BIGIP - VE to 15.1.6.1 from 15.1.5.1
- Oct 27, 2022
Just for anyone else who read this, the issue was a local execution
connection: local
this causes the system to SSH to itself and there is no tmsh on the ansible host. removing this line and then adding delegate_to: localhost when calling a BIG-IP module solved this issue. it allows the playbook to remote execute the code via SSH
After removing it and fixing a few code tweaks we were able to launch the code
So here is the code, when i was testing it was an unlicensed VE so it failed on the " - name: Wait for all devices to be healthy before proceeding" section b/c the command it runs shows "No License" but if its a licensed system should work fine. But it gets to the point where it installs/reboots the VE, give it a look see how it is.
In my code it also takes an archive at the beginning and end of the run to ensure that you have backups before and after the upgrade. Also i upgraded the Collections to the latest to ensure i was running latest code.
upgrade.yaml
---
- name: Upgrade BIG-IP software
hosts: bigip_hosts
gather_facts: False
vars_files:
- vars/vars.yml
vars:
provider:
password: "{{ f5_pass }}"
server: "{{ ansible_host }}"
user: "{{ f5_user }}"
validate_certs: False
new_image_dir: "/mnt/apps/isos/VMware/Appliances/F5 Networks/15.x"
new_image: "BIGIP-15.1.6-0.0.8.iso"
backup_loc: "{{ playbook_dir }}/backups"
backup_pfx: "10-13-2022_"
tasks:
- name: Get available volume number to use
ansible.builtin.script: "{{ playbook_dir }}/files/cal_vol.sh"
register: vol
- debug:
var: vol
- name: Get Software Volume Information
f5networks.f5_modules.bigip_device_info:
gather_subset:
- software-volumes
provider: "{{ provider }}"
register: sv
delegate_to: localhost
- name: Get Current Version
set_fact:
current_version: "{{ item.version }}"
current_boot_loc: "{{ item.name }}"
when: item.active == "yes"
with_items: "{{ sv.software_volumes }}"
- name: Identify Hosts That Require Upgrade
set_fact:
wants_upgrade: True
when: not new_image.split("-")[1] == current_version
- name: Identify Hosts That Don't Require Upgrade
set_fact:
wants_upgrade: False
when: new_image.split("-")[1] == current_version
- name: Only Upgrading Devices Which Need It
block:
- name: Check For Only One Boot Location
set_fact:
dest_boot_loc: "{{vol.stdout}}"
when: (not dest_boot_loc is defined) and (sv.software_volumes|length == 1)
- name: Check First Boot Location
set_fact:
dest_boot_loc: "{{ sv.software_volumes.0.name }}"
when: (not dest_boot_loc is defined) and (sv.software_volumes.0.active != "yes")
- name: Check Second Boot Location
set_fact:
dest_boot_loc: "{{ sv.software_volumes.1.name }}"
when: (not dest_boot_loc is defined) and (sv.software_volumes.1.active != "yes")
when: wants_upgrade
- name: Device Version Status
debug:
msg:
- "Current version: {{ current_version }}"
- "Desired image: {{ new_image }}"
- "Upgrade needed: {{ wants_upgrade }}"
- name: Print Upgrade Information
debug:
msg:
- "Current version: {{ current_version }} booting from {{ current_boot_loc }}"
- "New Image '{{ new_image }}' will be uploaded from '{{ new_image_dir }}'"
- "It will be installed to boot location '{{ dest_boot_loc }}'"
when: wants_upgrade
- name: Wait For Confirmation
pause:
prompt: "Press a key to continue..."
- name: Save the running configuration of the BIG-IP
f5networks.f5_modules.bigip_config:
provider: "{{ provider }}"
save: yes
when: wants_upgrade
delegate_to: localhost
- name: Ensure backup directory exists
file:
path: "{{ backup_loc }}/{{ inventory_hostname_short }}"
state: directory
delegate_to: localhost
- name: Get Pre-Upgrade UCS Backup
f5networks.f5_modules.bigip_ucs_fetch:
create_on_missing: yes
src: "{{ backup_pfx }}_pre-upgrade.ucs"
dest: "{{ backup_loc }}/{{ inventory_hostname_short }}/{{ backup_pfx }}_pre-upgrade.ucs"
provider: "{{ provider }}"
when: wants_upgrade
delegate_to: localhost
- name: Upload image
f5networks.f5_modules.bigip_software_image:
provider: "{{ provider }}"
image: "{{ new_image_dir }}/{{ new_image }}"
when: wants_upgrade
delegate_to: localhost
- name: Group 1 Activate Image (Will Cause Reboot)
f5networks.f5_modules.bigip_software_install:
provider: "{{ provider }}"
image: "{{ new_image }}"
state: activated
volume: "{{ vol.stdout }}"
when: (reboot_group == 1) and (wants_upgrade)
delegate_to: localhost
- name: Wait for all devices to be healthy before proceeding
f5networks.f5_modules.bigip_command:
provider: "{{ provider }}"
match: "any"
warn: no
commands:
- bash -c "cat /var/prompt/ps1"
wait_for:
- result[0] contains Active
- result[0] contains Standby
retries: 12
interval: 10
register: result
any_errors_fatal: true
when: wants_upgrade
delegate_to: localhost
- name: Group 2 Activate Image (Will Cause Reboot)
f5networks.f5_modules.bigip_software_install:
provider: "{{ provider }}"
image: "{{ new_image }}"
state: activated
volume: "{{ dest_boot_loc }}"
when: (reboot_group == 2) and (wants_upgrade)
# any_errors_fatal: true
delegate_to: localhost
- name: Get Post-Upgrade UCS Backup
f5networks.f5_modules.bigip_ucs_fetch:
create_on_missing: yes
src: "{{ backup_pfx }}_post-upgrade.ucs"
dest: "{{ backup_loc }}/{{ inventory_hostname_short }}/{{ backup_pfx }}_post-upgrade.ucs"
provider: "{{ provider }}"
when: wants_upgrade
delegate_to: localhost
vars/vars.yml
---
###F5_ENV
#BIG-IP
f5_user: admin
f5_pass: "*******"
f5_admin_port: 443
files/cal_vol.sh
#!/bin/bash
OLDIFS="$IFS"
IFS=$'\n'
disk=$(/bin/tmsh show sys sof status | awk '/.D[1-9]/{print substr($1,1,4)}' | head -n1)
maxvnumber=0
for vnumber in $(/bin/tmsh show sys sof status | grep complete)
do
vnumber=${vnumber:4:2}
vnumber=${vnumber// /}
if (( vnumber > maxvnumber )); then
maxvnumber=$vnumber
fi
done
volume=$disk$((maxvnumber + 3))
echo -n $volume
IFS="$OLDIFS"
inventory/inventory.yml
[bigip_hosts]
test-bip ansible_host=xxx.xxx.xxx.xxx ansible_user=root ansible_password=******* reboot_group=1
I updated the configuration.
Now I'm noticing the following the error message:
FAILED! => {"changed": false, "msg": "01070945:3: Invalid volume name (2)"}
- Matt_MabisOct 17, 2022Employee
Do you have a debug to the VAR variable (volume) like i do in my playbook? if so what is the output, to me it sounds like its not running that script.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com