Forum Discussion

vkrishna91's avatar
vkrishna91
Icon for Nimbostratus rankNimbostratus
Oct 10, 2022
Solved

Unable to use ansible playbook to upgrade BIGIP - VE to 15.1.6.1 from 15.1.5.1

Hi Team,

I'm trying to utilize ansible playbook to automate our F5 upgrade.
Current version: 15.1.5.1
New version: 15.1.6.1

I'm trying to utilize a bash script to dynamically identify the partition, create the partition if not available and install image and reboot. 
It looks like the bash script doesn't seem to work via ansible but works directly on the F5. 

bash script:

#!/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"


I have tried to use tmsh and /bin/tmsh - both seems to fail:
 "vol": {
        "changed": true,
        "failed": false,
        "rc": 0,
        "stderr": "/home/user/.ansible/tmp/ansible-local-61301srclvb76/ansible-tmp-1665415837.2614715-24184-40420301589164/cal_vol.sh: line 4: tmsh: command not found\n/home/user/.ansible/tmp/ansible-local-61301srclvb76/ansible-tmp-1665415837.2614715-24184-40420301589164/cal_vol.sh: line 16: tmsh: command not found\n",
        "stderr_lines": [
            "/home/user/.ansible/tmp/ansible-local-61301srclvb76/ansible-tmp-1665415837.2614715-24184-40420301589164/cal_vol.sh: line 4: tmsh: command not found",
            "/home/user/.ansible/tmp/ansible-local-61301srclvb76/ansible-tmp-1665415837.2614715-24184-40420301589164/cal_vol.sh: line 16: tmsh: command not found"
        ],
        "stdout": "3",
        "stdout_lines": [
            "3"
        ]
    }
}

I have tried to use the root account to login and still seem to throw the same error:

- name: Upload image
bigip_software_image:
provider: "{{ f5_provider }}"
image: "{{ new_image_dir }}/{{ new_image }}"

- name: Get available volume number to use
script: cal_vol.sh
register: vol
- debug:
var: vol

- name: Install Image and reboot
bigip_software_install:
provider: "{{ f5_provider }}"
image: "{{ new_image }}"
state: activated
volume: "HD1.{{ vol.stdout }}"
async: 45
poll: 0
any_errors_fatal: true

when: wants_upgrade

- name: Group 1 Upgrades
block:

- ansible.builtin.import_tasks: checks.yaml
vars:
stage: "pre"
when: check_virts or check_pools or check_ver

- name: Pausing execution to give device time to reboot (first time)
pause:
minutes: 10
when: wants_upgrade

- name: wait for ssh to come up
wait_for_connection:
connect_timeout: 120
sleep: 5
delay: 5
timeout: 300
when: wants_upgrade

Could someone assist us to resolve the issue?
We have close to 200 F5s, would not prefer to upgrade them manually. 




  • 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 

29 Replies