F5Networks / f5-ansible

Imperative Ansible modules for F5 BIG-IP products
GNU General Public License v3.0
375 stars 229 forks source link

"bigip_ucs_fetch" module creating all backups on 1st LTM #2367

Open grmenon opened 1 year ago

grmenon commented 1 year ago
COMPONENT NAME

f5networks.f5_modules.bigip_ucs_fetch

Environment

ANSIBLE VERSION
ansible [core 2.13.3]
  config file = /Users/<user>/Documents/workspace/ansible/f5-ansible-operations/ansible.cfg
  configured module search path = ['/Users/<user>/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /Users/<user>/Documents/workspace/ansible/f5-ansible-operations/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.18 (main, Aug 24 2023, 21:32:48) [Clang 14.0.3 (clang-1403.0.22.14.1)]
  jinja version = 3.0.1
  libyaml = True
BIGIP VERSION
Sys::Version
Main Package
  Product     BIG-IP
  Version     15.1.8.2
  Build       0.111.17
  Edition     Engineering Hotfix
  Date        Tue Apr 25 12:25:04 PDT 2023
Hotfix List
ID1137485-3   ID1281637  ID1230753  ID1291993-1  ID1017841
CONFIGURATION
OS / ENVIRONMENT

I am getting errors when running the playbook on both Mac (my laptop) & Ansible Automation Platform (Ansible Automation Platform Controller 4.4.1)

SUMMARY

When executing the playbook on multiple hosts, all backups are stored on the 1st LTM in the list. That results in the space on the 1st LTM getting full resulting in errors.

STEPS TO REPRODUCE

Playbook shown below

---
# --- Backup Appliance ---
- name: Backup appliance
  hosts: all
  collections:
    - f5networks.f5_modules
  order: sorted
  gather_facts: false
  connection: local
  vars:
    # --- User Managed Variables ---
    bkup_path: "tmp/backup"
    # ------------------------------------------
    # --- System Variables ---
  # --- Execute pre-req tasks ---
  # --- Load the vaulted variables, get-auth, device-info etc ---
  pre_tasks:
    - name: Run Pre-Tasks
      tags: [always]
      block:
        - name: Gather date and time only
          setup:
            gather_subset:
              - "min"
          when: ansible_date_time is not defined
        # ------------------------------------------
        - name: Load Vault Variables
          include_vars: "{{item}}"
          with_first_found:
            - "vaults/{{vault_name}}"
            - "vaults/default.yml"
        # ------------------------------------------
        - name: Create backup location
          file:
            path: "{{bkup_path}}"
            state: directory
            mode: "4770"
        # ------------------------------------------
        - name: Set derived variables
          set_fact:
            override_host: "{{inventory_hostname}}"
          when: override_host is undefined
        # ------------------------------------------
        - name: Increase provider timeout
          set_fact:
            provider: "{{provider | combine ({'timeout': 1800})}}"
        # ------------------------------------------
        - name: Add no_f5_teem
          set_fact:
            provider: "{{provider | combine ({'no_f5_teem': false})}}"
          when:
            - ansible_facts.user_dir == "/home/runner"
        # ------------------------------------------
      run_once: true
  # ------------------------------------------
  tasks:
    - name: Backup F5 Appliance
      block:
        - name: Delete old backup
          f5networks.f5_modules.bigip_ucs:
            provider: "{{ provider }}"
            ucs: "{{shortName}}.ucs"
            state: absent
        # ------------------------------------------
        - name: Create backup on device, no download
          f5networks.f5_modules.bigip_ucs_fetch:
            provider: "{{ provider }}"
            src: "{{shortName}}.ucs"
            only_create_file: yes
            async_timeout: 1800
          register: bkup_task
          retries: 3
          delay: 10
          until: bkup_task is not failed
        # ------------------------------------------
        - name: Print backup status
          debug:
            var: bkup_task
        # ------------------------------------------
...
EXPECTED RESULTS

Backup file should be created on each F5 rather than on the 1st F5.

ACTUAL RESULTS

Ansible output attached below.

ansible-playbook [core 2.13.3]
  config file = /Users/<user>/Documents/workspace/ansible/f5-ansible-operations/ansible.cfg
  configured module search path = ['/Users/<user>/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /Users/<user>/Documents/workspace/ansible/f5-ansible-operations/collections
  executable location = /usr/local/bin/ansible-playbook
  python version = 3.9.18 (main, Aug 24 2023, 21:32:48) [Clang 14.0.3 (clang-1403.0.22.14.1)]
  jinja version = 3.0.1
  libyaml = True
Using /Users/<user>/Documents/workspace/ansible/f5-ansible-operations/ansible.cfg as config file
host_list declined parsing /Users/<user>/Documents/workspace/ansible/f5-ansible-operations/ext_repos/f5-ansible-inventories/hosts_ivt_tower.yml as it did not pass its verify_file() method
Parsed /Users/<user>/Documents/workspace/ansible/f5-ansible-operations/ext_repos/f5-ansible-inventories/hosts_ivt_tower.yml inventory source with yaml plugin
redirecting (type: callback) ansible.builtin.debug to ansible.posix.debug
redirecting (type: callback) ansible.builtin.debug to ansible.posix.debug
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: bkup_f5.yml **********************************************************
1 plays in bkup_f5.yml

PLAY [Backup appliance] ********************************************************

TASK [Gather date and time only] ***********************************************
task path: /Users/<user>/Documents/workspace/ansible/f5-ansible-operations/bkup_f5.yml:21
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: <user>
<127.0.0.1> EXEC /bin/sh -c 'echo ~<user> && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/<user>/.ansible/tmp `"&& mkdir "` echo /Users/<user>/.ansible/tmp/ansible-tmp-1694896573.8180249-10997-163097702674965 `" && echo ansible-tmp-1694896573.8180249-10997-163097702674965="` echo /Users/<user>/.ansible/tmp/ansible-tmp-1694896573.8180249-10997-163097702674965 `" ) && sleep 0'
<ltm001im.az1.mydomain> Attempting python interpreter discovery
<127.0.0.1> EXEC /bin/sh -c 'echo PLATFORM; uname; echo FOUND; command -v '"'"'python3.10'"'"'; command -v '"'"'python3.9'"'"'; command -v '"'"'python3.8'"'"'; command -v '"'"'python3.7'"'"'; command -v '"'"'python3.6'"'"'; command -v '"'"'python3.5'"'"'; command -v '"'"'/usr/bin/python3'"'"'; command -v '"'"'/usr/libexec/platform-python'"'"'; command -v '"'"'python2.7'"'"'; command -v '"'"'/usr/bin/python'"'"'; command -v '"'"'python'"'"'; echo ENDFOUND && sleep 0'
<ltm001im.az1.mydomain> Python interpreter discovery fallback (unsupported platform for extended discovery: darwin)
Using module file /usr/local/lib/python3.9/site-packages/ansible/modules/setup.py
<127.0.0.1> PUT /Users/<user>/.ansible/tmp/ansible-local-1099255c78ogu/tmp6n3ss_u3 TO /Users/<user>/.ansible/tmp/ansible-tmp-1694896573.8180249-10997-163097702674965/AnsiballZ_setup.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /Users/<user>/.ansible/tmp/ansible-tmp-1694896573.8180249-10997-163097702674965/ /Users/<user>/.ansible/tmp/ansible-tmp-1694896573.8180249-10997-163097702674965/AnsiballZ_setup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/local/bin/python3.9 /Users/<user>/.ansible/tmp/ansible-tmp-1694896573.8180249-10997-163097702674965/AnsiballZ_setup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /Users/<user>/.ansible/tmp/ansible-tmp-1694896573.8180249-10997-163097702674965/ > /dev/null 2>&1 && sleep 0'
ok: [ltm001im.az1.mydomain -> localhost(127.0.0.1)]

TASK [Load Vault Variables] ****************************************************
task path: /Users/<user>/Documents/workspace/ansible/f5-ansible-operations/bkup_f5.yml:27
ok: [ltm001im.az1.mydomain -> localhost(127.0.0.1)] => (item=/Users/<user>/Documents/workspace/ansible/f5-ansible-operations/vaults/my_vault.yml) => {
    "ansible_facts": {
        "iip_pwd": "XXX",
        "iip_user": "<f5-id>",
        "root_pwd": "YYY"
    },
    "ansible_included_var_files": [
        "/Users/<user>/Documents/workspace/ansible/f5-ansible-operations/vaults/my_vault.yml"
    ],
    "ansible_loop_var": "item",
    "changed": false,
    "item": "/Users/<user>/Documents/workspace/ansible/f5-ansible-operations/vaults/my_vault.yml"
}

TASK [Create backup location] **************************************************
task path: /Users/<user>/Documents/workspace/ansible/f5-ansible-operations/bkup_f5.yml:33
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: <user>
<127.0.0.1> EXEC /bin/sh -c 'echo ~<user> && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/<user>/.ansible/tmp `"&& mkdir "` echo /Users/<user>/.ansible/tmp/ansible-tmp-1694896574.7855098-11032-103898363991879 `" && echo ansible-tmp-1694896574.7855098-11032-103898363991879="` echo /Users/<user>/.ansible/tmp/ansible-tmp-1694896574.7855098-11032-103898363991879 `" ) && sleep 0'
<ltm001im.az1.mydomain> Attempting python interpreter discovery
<127.0.0.1> EXEC /bin/sh -c 'echo PLATFORM; uname; echo FOUND; command -v '"'"'python3.10'"'"'; command -v '"'"'python3.9'"'"'; command -v '"'"'python3.8'"'"'; command -v '"'"'python3.7'"'"'; command -v '"'"'python3.6'"'"'; command -v '"'"'python3.5'"'"'; command -v '"'"'/usr/bin/python3'"'"'; command -v '"'"'/usr/libexec/platform-python'"'"'; command -v '"'"'python2.7'"'"'; command -v '"'"'/usr/bin/python'"'"'; command -v '"'"'python'"'"'; echo ENDFOUND && sleep 0'
<ltm001im.az1.mydomain> Python interpreter discovery fallback (unsupported platform for extended discovery: darwin)
Using module file /usr/local/lib/python3.9/site-packages/ansible/modules/file.py
<127.0.0.1> PUT /Users/<user>/.ansible/tmp/ansible-local-1099255c78ogu/tmptbvf90at TO /Users/<user>/.ansible/tmp/ansible-tmp-1694896574.7855098-11032-103898363991879/AnsiballZ_file.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /Users/<user>/.ansible/tmp/ansible-tmp-1694896574.7855098-11032-103898363991879/ /Users/<user>/.ansible/tmp/ansible-tmp-1694896574.7855098-11032-103898363991879/AnsiballZ_file.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/local/bin/python3.9 /Users/<user>/.ansible/tmp/ansible-tmp-1694896574.7855098-11032-103898363991879/AnsiballZ_file.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /Users/<user>/.ansible/tmp/ansible-tmp-1694896574.7855098-11032-103898363991879/ > /dev/null 2>&1 && sleep 0'
ok: [ltm001im.az1.mydomain -> localhost(127.0.0.1)] => {
    "changed": false,
    "diff": {
        "after": {
            "path": "tmp/backup"
        },
        "before": {
            "path": "tmp/backup"
        }
    },
    "gid": 20,
    "group": "staff",
    "invocation": {
        "module_args": {
            "_diff_peek": null,
            "_original_basename": null,
            "access_time": null,
            "access_time_format": "%Y%m%d%H%M.%S",
            "attributes": null,
            "follow": true,
            "force": false,
            "group": null,
            "mode": "4770",
            "modification_time": null,
            "modification_time_format": "%Y%m%d%H%M.%S",
            "owner": null,
            "path": "tmp/backup",
            "recurse": false,
            "selevel": null,
            "serole": null,
            "setype": null,
            "seuser": null,
            "src": null,
            "state": "directory",
            "unsafe_writes": false
        }
    },
    "mode": "04770",
    "owner": "<user>",
    "path": "tmp/backup",
    "size": 160,
    "state": "directory",
    "uid": 501,
    "warnings": [
        "Platform darwin on host ltm001im.az1.mydomain is using the discovered Python interpreter at /usr/local/bin/python3.9, but future installation of another Python interpreter could change the meaning of that path. See https://docs.ansible.com/ansible-core/2.13/reference_appendices/interpreter_discovery.html for more information."
    ]
}

TASK [Set derived variables] ***************************************************
task path: /Users/<user>/Documents/workspace/ansible/f5-ansible-operations/bkup_f5.yml:39
ok: [ltm001im.az1.mydomain -> localhost(127.0.0.1)] => {
    "ansible_facts": {
        "override_host": "ltm001im.az1.mydomain"
    },
    "changed": false
}

TASK [Increase provider timeout] ***********************************************
task path: /Users/<user>/Documents/workspace/ansible/f5-ansible-operations/bkup_f5.yml:44
ok: [ltm001im.az1.mydomain -> localhost(127.0.0.1)] => {
    "ansible_facts": {
        "provider": {
            "password": "XXX",
            "server": "ltm001im.az1.mydomain",
            "server_port": 443,
            "timeout": 1800,
            "user": "<f5-id>",
            "validate_certs": false
        }
    },
    "changed": false
}

TASK [Add no_f5_teem] **********************************************************
task path: /Users/<user>/Documents/workspace/ansible/f5-ansible-operations/bkup_f5.yml:48
skipping: [ltm001im.az1.mydomain] => {
    "changed": false,
    "skip_reason": "Conditional result was False"
}
META: ran handlers

TASK [Delete old backup] *******************************************************
task path: /Users/<user>/Documents/workspace/ansible/f5-ansible-operations/bkup_f5.yml:60
<ltm001im.az1.mydomain> ESTABLISH LOCAL CONNECTION FOR USER: <user>
<ltm001im.az1.mydomain> EXEC /bin/sh -c 'echo ~<user> && sleep 0'
<ltm002im.az2.mydomain> ESTABLISH LOCAL CONNECTION FOR USER: <user>
<ltm002im.az2.mydomain> EXEC /bin/sh -c 'echo ~<user> && sleep 0'
<ltm001im.az1.mydomain> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/<user>/.ansible/tmp `"&& mkdir "` echo /Users/<user>/.ansible/tmp/ansible-tmp-1694896575.544332-11058-19763683543971 `" && echo ansible-tmp-1694896575.544332-11058-19763683543971="` echo /Users/<user>/.ansible/tmp/ansible-tmp-1694896575.544332-11058-19763683543971 `" ) && sleep 0'
<ltm002im.az2.mydomain> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/<user>/.ansible/tmp `"&& mkdir "` echo /Users/<user>/.ansible/tmp/ansible-tmp-1694896575.565251-11059-144979899042789 `" && echo ansible-tmp-1694896575.565251-11059-144979899042789="` echo /Users/<user>/.ansible/tmp/ansible-tmp-1694896575.565251-11059-144979899042789 `" ) && sleep 0'
<ltm001im.az1.mydomain> Attempting python interpreter discovery
<ltm001im.az1.mydomain> EXEC /bin/sh -c 'echo PLATFORM; uname; echo FOUND; command -v '"'"'python3.10'"'"'; command -v '"'"'python3.9'"'"'; command -v '"'"'python3.8'"'"'; command -v '"'"'python3.7'"'"'; command -v '"'"'python3.6'"'"'; command -v '"'"'python3.5'"'"'; command -v '"'"'/usr/bin/python3'"'"'; command -v '"'"'/usr/libexec/platform-python'"'"'; command -v '"'"'python2.7'"'"'; command -v '"'"'/usr/bin/python'"'"'; command -v '"'"'python'"'"'; echo ENDFOUND && sleep 0'
<ltm002im.az2.mydomain> Attempting python interpreter discovery
<ltm002im.az2.mydomain> EXEC /bin/sh -c 'echo PLATFORM; uname; echo FOUND; command -v '"'"'python3.10'"'"'; command -v '"'"'python3.9'"'"'; command -v '"'"'python3.8'"'"'; command -v '"'"'python3.7'"'"'; command -v '"'"'python3.6'"'"'; command -v '"'"'python3.5'"'"'; command -v '"'"'/usr/bin/python3'"'"'; command -v '"'"'/usr/libexec/platform-python'"'"'; command -v '"'"'python2.7'"'"'; command -v '"'"'/usr/bin/python'"'"'; command -v '"'"'python'"'"'; echo ENDFOUND && sleep 0'
<ltm001im.az1.mydomain> Python interpreter discovery fallback (unsupported platform for extended discovery: darwin)
<ltm002im.az2.mydomain> Python interpreter discovery fallback (unsupported platform for extended discovery: darwin)
Using module file /Users/<user>/Documents/workspace/ansible/f5-ansible-operations/collections/ansible_collections/f5networks/f5_modules/plugins/modules/bigip_ucs.py
Using module file /Users/<user>/Documents/workspace/ansible/f5-ansible-operations/collections/ansible_collections/f5networks/f5_modules/plugins/modules/bigip_ucs.py
<ltm001im.az1.mydomain> PUT /Users/<user>/.ansible/tmp/ansible-local-1099255c78ogu/tmpqlal372t TO /Users/<user>/.ansible/tmp/ansible-tmp-1694896575.544332-11058-19763683543971/AnsiballZ_bigip_ucs.py
<ltm002im.az2.mydomain> PUT /Users/<user>/.ansible/tmp/ansible-local-1099255c78ogu/tmp1263chu2 TO /Users/<user>/.ansible/tmp/ansible-tmp-1694896575.565251-11059-144979899042789/AnsiballZ_bigip_ucs.py
<ltm001im.az1.mydomain> EXEC /bin/sh -c 'chmod u+x /Users/<user>/.ansible/tmp/ansible-tmp-1694896575.544332-11058-19763683543971/ /Users/<user>/.ansible/tmp/ansible-tmp-1694896575.544332-11058-19763683543971/AnsiballZ_bigip_ucs.py && sleep 0'
<ltm002im.az2.mydomain> EXEC /bin/sh -c 'chmod u+x /Users/<user>/.ansible/tmp/ansible-tmp-1694896575.565251-11059-144979899042789/ /Users/<user>/.ansible/tmp/ansible-tmp-1694896575.565251-11059-144979899042789/AnsiballZ_bigip_ucs.py && sleep 0'
<ltm001im.az1.mydomain> EXEC /bin/sh -c '/usr/local/bin/python3.9 /Users/<user>/.ansible/tmp/ansible-tmp-1694896575.544332-11058-19763683543971/AnsiballZ_bigip_ucs.py && sleep 0'
<ltm002im.az2.mydomain> EXEC /bin/sh -c '/usr/local/bin/python3.9 /Users/<user>/.ansible/tmp/ansible-tmp-1694896575.565251-11059-144979899042789/AnsiballZ_bigip_ucs.py && sleep 0'
<ltm002im.az2.mydomain> EXEC /bin/sh -c 'rm -f -r /Users/<user>/.ansible/tmp/ansible-tmp-1694896575.565251-11059-144979899042789/ > /dev/null 2>&1 && sleep 0'
ok: [ltm002im.az2.mydomain] => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/local/bin/python3.9"
    },
    "changed": false,
    "invocation": {
        "module_args": {
            "force": false,
            "include_chassis_level_config": null,
            "no_license": null,
            "no_platform_check": null,
            "passphrase": null,
            "provider": {
                "auth_provider": null,
                "no_f5_teem": null,
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "server": "ltm001im.az1.mydomain",
                "server_port": 443,
                "timeout": 1800,
                "transport": "rest",
                "user": "<f5-id>",
                "validate_certs": false
            },
            "reset_trust": null,
            "state": "absent",
            "ucs": "ltm002im.ucs"
        }
    },
    "warnings": [
        "Platform darwin on host ltm002im.az2.mydomain is using the discovered Python interpreter at /usr/local/bin/python3.9, but future installation of another Python interpreter could change the meaning of that path. See https://docs.ansible.com/ansible-core/2.13/reference_appendices/interpreter_discovery.html for more information."
    ]
}
<ltm001im.az1.mydomain> EXEC /bin/sh -c 'rm -f -r /Users/<user>/.ansible/tmp/ansible-tmp-1694896575.544332-11058-19763683543971/ > /dev/null 2>&1 && sleep 0'
changed: [ltm001im.az1.mydomain] => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/local/bin/python3.9"
    },
    "changed": true,
    "invocation": {
        "module_args": {
            "force": false,
            "include_chassis_level_config": null,
            "no_license": null,
            "no_platform_check": null,
            "passphrase": null,
            "provider": {
                "auth_provider": null,
                "no_f5_teem": null,
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "server": "ltm001im.az1.mydomain",
                "server_port": 443,
                "timeout": 1800,
                "transport": "rest",
                "user": "<f5-id>",
                "validate_certs": false
            },
            "reset_trust": null,
            "state": "absent",
            "ucs": "ltm001im.ucs"
        }
    },
    "warnings": [
        "Platform darwin on host ltm001im.az1.mydomain is using the discovered Python interpreter at /usr/local/bin/python3.9, but future installation of another Python interpreter could change the meaning of that path. See https://docs.ansible.com/ansible-core/2.13/reference_appendices/interpreter_discovery.html for more information."
    ]
}

TASK [Create backup on device, no download] ************************************
task path: /Users/<user>/Documents/workspace/ansible/f5-ansible-operations/bkup_f5.yml:66
<ltm001im.az1.mydomain> ESTABLISH LOCAL CONNECTION FOR USER: <user>
<ltm001im.az1.mydomain> EXEC /bin/sh -c 'echo ~<user> && sleep 0'
<ltm002im.az2.mydomain> ESTABLISH LOCAL CONNECTION FOR USER: <user>
<ltm002im.az2.mydomain> EXEC /bin/sh -c 'echo ~<user> && sleep 0'
<ltm001im.az1.mydomain> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/<user>/.ansible/tmp `"&& mkdir "` echo /Users/<user>/.ansible/tmp/ansible-tmp-1694896583.109581-11109-48647462611092 `" && echo ansible-tmp-1694896583.109581-11109-48647462611092="` echo /Users/<user>/.ansible/tmp/ansible-tmp-1694896583.109581-11109-48647462611092 `" ) && sleep 0'
<ltm002im.az2.mydomain> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /Users/<user>/.ansible/tmp `"&& mkdir "` echo /Users/<user>/.ansible/tmp/ansible-tmp-1694896583.127489-11110-257676460216339 `" && echo ansible-tmp-1694896583.127489-11110-257676460216339="` echo /Users/<user>/.ansible/tmp/ansible-tmp-1694896583.127489-11110-257676460216339 `" ) && sleep 0'
Using module file /Users/<user>/Documents/workspace/ansible/f5-ansible-operations/collections/ansible_collections/f5networks/f5_modules/plugins/modules/bigip_ucs_fetch.py
Using module file /Users/<user>/Documents/workspace/ansible/f5-ansible-operations/collections/ansible_collections/f5networks/f5_modules/plugins/modules/bigip_ucs_fetch.py
<ltm001im.az1.mydomain> PUT /Users/<user>/.ansible/tmp/ansible-local-1099255c78ogu/tmp0_187rqi TO /Users/<user>/.ansible/tmp/ansible-tmp-1694896583.109581-11109-48647462611092/AnsiballZ_bigip_ucs_fetch.py
<ltm002im.az2.mydomain> PUT /Users/<user>/.ansible/tmp/ansible-local-1099255c78ogu/tmp5wyb98xp TO /Users/<user>/.ansible/tmp/ansible-tmp-1694896583.127489-11110-257676460216339/AnsiballZ_bigip_ucs_fetch.py
<ltm001im.az1.mydomain> EXEC /bin/sh -c 'chmod u+x /Users/<user>/.ansible/tmp/ansible-tmp-1694896583.109581-11109-48647462611092/ /Users/<user>/.ansible/tmp/ansible-tmp-1694896583.109581-11109-48647462611092/AnsiballZ_bigip_ucs_fetch.py && sleep 0'
<ltm002im.az2.mydomain> EXEC /bin/sh -c 'chmod u+x /Users/<user>/.ansible/tmp/ansible-tmp-1694896583.127489-11110-257676460216339/ /Users/<user>/.ansible/tmp/ansible-tmp-1694896583.127489-11110-257676460216339/AnsiballZ_bigip_ucs_fetch.py && sleep 0'
<ltm001im.az1.mydomain> EXEC /bin/sh -c '/usr/local/bin/python3.9 /Users/<user>/.ansible/tmp/ansible-tmp-1694896583.109581-11109-48647462611092/AnsiballZ_bigip_ucs_fetch.py && sleep 0'
<ltm002im.az2.mydomain> EXEC /bin/sh -c '/usr/local/bin/python3.9 /Users/<user>/.ansible/tmp/ansible-tmp-1694896583.127489-11110-257676460216339/AnsiballZ_bigip_ucs_fetch.py && sleep 0'
<ltm002im.az2.mydomain> EXEC /bin/sh -c 'rm -f -r /Users/<user>/.ansible/tmp/ansible-tmp-1694896583.127489-11110-257676460216339/ > /dev/null 2>&1 && sleep 0'
changed: [ltm002im.az2.mydomain] => {
    "attempts": 1,
    "changed": true,
    "invocation": {
        "module_args": {
            "async_timeout": 1800,
            "attributes": null,
            "backup": false,
            "create_on_missing": true,
            "dest": null,
            "encryption_password": null,
            "fail_on_missing": false,
            "force": true,
            "group": null,
            "mode": null,
            "only_create_file": true,
            "owner": null,
            "provider": {
                "auth_provider": null,
                "no_f5_teem": null,
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "server": "ltm001im.az1.mydomain",
                "server_port": 443,
                "timeout": 1800,
                "transport": "rest",
                "user": "<f5-id>",
                "validate_certs": false
            },
            "selevel": null,
            "serole": null,
            "setype": null,
            "seuser": null,
            "src": "ltm002im.ucs",
            "unsafe_writes": false
        }
    }
}
<ltm001im.az1.mydomain> EXEC /bin/sh -c 'rm -f -r /Users/<user>/.ansible/tmp/ansible-tmp-1694896583.109581-11109-48647462611092/ > /dev/null 2>&1 && sleep 0'
changed: [ltm001im.az1.mydomain] => {
    "attempts": 1,
    "changed": true,
    "invocation": {
        "module_args": {
            "async_timeout": 1800,
            "attributes": null,
            "backup": false,
            "create_on_missing": true,
            "dest": null,
            "encryption_password": null,
            "fail_on_missing": false,
            "force": true,
            "group": null,
            "mode": null,
            "only_create_file": true,
            "owner": null,
            "provider": {
                "auth_provider": null,
                "no_f5_teem": null,
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "server": "ltm001im.az1.mydomain",
                "server_port": 443,
                "timeout": 1800,
                "transport": "rest",
                "user": "<f5-id>",
                "validate_certs": false
            },
            "selevel": null,
            "serole": null,
            "setype": null,
            "seuser": null,
            "src": "ltm001im.ucs",
            "unsafe_writes": false
        }
    }
}

TASK [Print backup status] *****************************************************
task path: /Users/<user>/Documents/workspace/ansible/f5-ansible-operations/bkup_f5.yml:77
ok: [ltm001im.az1.mydomain] => {
    "bkup_task": {
        "attempts": 1,
        "changed": true,
        "failed": false
    }
}
ok: [ltm002im.az2.mydomain] => {
    "bkup_task": {
        "attempts": 1,
        "changed": true,
        "failed": false
    }
}
META: ran handlers
META: ran handlers

PLAY RECAP *********************************************************************
ltm001im.az1.mydomain : ok=8    changed=2    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0
ltm002im.az2.mydomain : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
pgouband commented 1 year ago

Hi @grmenon,

I tested the following example and one ucs was created on each device. In your playbook, there is a provider referenced. Could you check if the server is changed correctly for each device?

Inventory file:

F5:
  hosts:
    F501:
      ansible_host: X.X.X.X
      ucsname: F501.ucs
    F502:
      ansible_host: Y.Y.Y.Y
      ucsname: F502.ucs

Playbook:

- hosts: F5
  collections:
    - f5networks.f5_modules
  connection: local

  tasks:
     - name: Only create new UCS in Big-IP device, no download
       f5networks.f5_modules.bigip_ucs_fetch:
         provider:
           server: {{ ansible_host }}
           user: "admin"
           password: "mysecretpassword"
           server_port: 443
           validate_certs: no
           no_f5_teem: yes
         src: {{ ucsname }}
         only_create_file: yes
         async_timeout: 1800
       delegate_to: localhost
grmenon commented 1 year ago

Thank you for the response. I am using "{{inventory_host}}" for the server property in my provider. I am surprised and "ansible_host" is working for you with delegation to localhost. For me "{{ansible_host}} fails (testing on Mac). When I limit the backup to just 2 devices (as you have in the example above), it seems to be working. I see the issue when I have more than 2. As an alternative (I know this is not ideal), serializing the execution seems to be doing the trick as well. It does a little longer, but it works. For people using ansible AAP, you can run smaller groups (with serialization) in parallel using worflows.

pgouband commented 1 year ago

Hi @grmenon,

I tried with 3 devices and it works.

grmenon commented 1 year ago

Thank you Patrick for testing this. I ran a couple of tests & from what I can tell, this is working fine if the target is a VE. It is failing for me if

  1. Target is a physical box
  2. Backup is larger than 1G (I should mention that the error is not timeout)

For now, I am using a combination of tmsh & scp to take & download the backups for physical boxes.