F5Networks / f5-ansible

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

bigip_lx_package - 'no_f5_teem' is of type <class 'NoneType'> found in 'provider #2372

Open VDI-Tech-Guy opened 12 months ago

VDI-Tech-Guy commented 12 months ago
COMPONENT NAME

f5networks.f5_modules.bigip_lx_package

Environment

ANSIBLE VERSION (Execution Environment)
bash-5.1$ ansible --version
ansible [core 2.15.3]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /runner/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.16 (main, May 29 2023, 00:00:00) [GCC 11.3.1 20221121 (Red Hat 11.3.1-4)] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True
Ansible Collection (Execution Environment)
# /usr/share/ansible/collections/ansible_collections
Collection            Version
--------------------- -------
ansible.netcommon     4.1.0
ansible.posix         1.5.4
ansible.utils         2.11.0
cloud.common          2.1.4
community.docker      3.4.8
community.general     7.4.0
community.vmware      3.9.0
containers.podman     1.10.3
f5networks.f5_bigip   3.1.1
f5networks.f5_modules 1.26.0
vmware.vmware_rest    2.3.1
BIGIP VERSION
17.1.0
CONFIGURATION
OS / ENVIRONMENT

Core Environment is Ansible Automation Platform 2.4 on RHEL 9 utilizing an Execution Environment - https://quay.io/repository/f5_business_development/day0-ee

SUMMARY

With installing AS3 get error from module that the no_f5_teem found in provider of the module bigip_lx_package is of type NoneType and not bool.

STEPS TO REPRODUCE
- hosts: dynamic_f5_vms
  connection: local
  gather_facts: false
  roles:
    - roles/F5-Roles/install_as3

#ROLE Install_as3
---
# tasks install Declaritive Onboarding Latest

  - name: Get latest AS3 RPM
    ansible.builtin.shell: curl -s {{as3_uri}} | grep -E rpm |grep -E browser_download_url | head -1 | cut -d "\"" -f 4
    register: as3_output
    delegate_to: localhost

  - debug:
      var: as3_output.stdout_lines[0]

  - ansible.builtin.set_fact:
      as3_download: "{{as3_output.stdout_lines[0]}}"
    delegate_to: localhost

  - name: Grab AS3 RPM from github
    ansible.builtin.get_url:
      url: "{{as3_download}}?raw=true"
      dest: "~/"
      validate_certs: false
    delegate_to: localhost

  - name: Grab the AS3 version from the home directory
    ansible.builtin.shell: ls -Art ~/*.rpm | tail -n 1 | rev | cut -d/ -f 1 | rev
    register: ls_output

  - ansible.builtin.set_fact:
      as3_rpm: "{{ls_output.stdout}}"
    delegate_to: localhost

  - name: Install AS3
    f5networks.f5_modules.bigip_lx_package:
      package: "~/{{as3_rpm}}"
      provider: "{{provider}}"
    register: install_as3
    delegate_to: localhost
    retries: 10
    until: install_as3 is not failed
EXPECTED RESULTS

AS3 installs correctly with no issues

ACTUAL RESULTS

FAILED - RETRYING: [Lab-BIP-BIGIP-17.1.0-002 -> localhost]: Install AS3 (6 retries left).
FAILED - RETRYING: [Lab-BIP-BIGIP-17.1.0-001 -> localhost]: Install AS3 (6 retries left).
FAILED - RETRYING: [Lab-BIP-BIGIP-17.1.0-001 -> localhost]: Install AS3 (5 retries left).
FAILED - RETRYING: [Lab-BIP-BIGIP-17.1.0-002 -> localhost]: Install AS3 (5 retries left).
FAILED - RETRYING: [Lab-BIP-BIGIP-17.1.0-002 -> localhost]: Install AS3 (4 retries left).
FAILED - RETRYING: [Lab-BIP-BIGIP-17.1.0-001 -> localhost]: Install AS3 (4 retries left).
FAILED - RETRYING: [Lab-BIP-BIGIP-17.1.0-002 -> localhost]: Install AS3 (3 retries left).
FAILED - RETRYING: [Lab-BIP-BIGIP-17.1.0-001 -> localhost]: Install AS3 (3 retries left).
FAILED - RETRYING: [Lab-BIP-BIGIP-17.1.0-002 -> localhost]: Install AS3 (2 retries left).
FAILED - RETRYING: [Lab-BIP-BIGIP-17.1.0-001 -> localhost]: Install AS3 (2 retries left).
FAILED - RETRYING: [Lab-BIP-BIGIP-17.1.0-002 -> localhost]: Install AS3 (1 retries left).
FAILED - RETRYING: [Lab-BIP-BIGIP-17.1.0-001 -> localhost]: Install AS3 (1 retries left).
fatal: [Lab-BIP-BIGIP-17.1.0-001 -> localhost]: FAILED! => {"attempts": 10, "changed": false, "msg": "argument 'no_f5_teem' is of type <class 'NoneType'> found in 'provider'. and we were unable to convert to bool: <class 'NoneType'> cannot be converted to a bool"}
fatal: [Lab-BIP-BIGIP-17.1.0-002 -> localhost]: FAILED! => {"attempts": 10, "changed": false, "msg": "argument 'no_f5_teem' is of type <class 'NoneType'> found in 'provider'. and we were unable to convert to bool: <class 'NoneType'> cannot be converted to a bool"}

{
  "msg": "argument 'no_f5_teem' is of type <class 'NoneType'> found in 'provider'. and we were unable to convert to bool: <class 'NoneType'> cannot be converted to a bool",
  "invocation": {
    "module_args": {
      "package": "/root/f5-appsvcs-3.47.0-8.noarch.rpm",
      "provider": {
        "server": "10.192.1.151",
        "user": "admin",
        "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
        "server_port": 443,
        "validate_certs": false,
        "transport": "rest",
        "timeout": null,
        "no_f5_teem": null,
        "auth_provider": null
      },
      "state": "present",
      "retain_package_file": false
    }
  },
  "_ansible_no_log": null,
  "attempts": 10,
  "changed": false,
  "_ansible_delegated_vars": {
    "ansible_host": "localhost",
    "ansible_port": null,
    "ansible_user": "root",
    "ansible_connection": "local"
  }
}
pgouband commented 12 months ago

Hi @VDI-Tech-Guy,

I think you just need to add "no_f5_teem: yes" in your provider.

VDI-Tech-Guy commented 12 months ago

Hey @pgouband

This hasn't been a requirement in the past, I've used this code for years and the documentation implies it's not required and should have a default answer.

Also no other module I call seems to have this same effect

pgouband commented 12 months ago

Hi,

Thanks for reporting. Added to the backlog and internal tracking ID for this request is: INFRAANO-1327.

VDI-Tech-Guy commented 12 months ago

I did validate putting in there did let me pass but because there should be a default behavior that shouldn't cause an error is why I created this ticket.

I think I did find other modules causing issues as well

pgouband commented 11 months ago

Hi @VDI-Tech-Guy,

could you upgrade ansible to 2.15.4 or later?

VDI-Tech-Guy commented 11 months ago

@pgouband - I tried 2.15.5 and same problem, the issue stems that the modules are requiring no_f5_teem to be part of the provider to be defined if it isn't it will fail. also, the documentation says it's a Boolean value and the default value is false (although it's weird the error indicates there is NO Value) instead of "False" But based on what we have learned so far it would seem the default value should be changed to Yes instead of false.

image

urohit011 commented 11 months ago

Hi @VDI-Tech-Guy , I have tried reproducing this issue with the same versions of BIGIP, python and ansible, and I did not see the issue in my case, could you please share the var file where you're setting the provider variable, so I could take a look.

jLemmings commented 10 months ago

I am facing exactly the same issue. Currently I am unable to check the previously used collection version. With the latest version it does not apply the documented default values.

fatal: [localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "data_increment": 10,
            "gather_subset": [
                "ltm-pools"
            ],
            "partition": "MY-PARTITION",
            "provider": {
                "auth_provider": null,
                "no_f5_teem": null,
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "server": "1.1.1.1",
                "server_port": 443,
                "timeout": null,
                "transport": "rest",
                "user": "SECRET_USER",
                "validate_certs": false
            }
        }
    },
    "msg": "argument 'no_f5_teem' is of type <class 'NoneType'> found in 'provider'. and we were unable to convert to bool: <class 'NoneType'> cannot be converted to a bool"
}
urohit011 commented 10 months ago

Hi @jLemmings , could you please share the ansible playbook and the version of python, bigip and ansible you are using.

VDI-Tech-Guy commented 10 months ago

@urohit011 - sorry for the delay i have been out, the original provider variable i was using never had the "no_f5_teem" variable in it as in earlier iterations it wasnt necessary. its the exclusion of this variable that causes the code to fail with a non-default value.

jboisdequin commented 7 months ago

Hello I'm also facing the same issue with: Ansible 9.1.0 Python 3.12.2 For 2 vars :

"msg": "argument 'server_port' is of type <class 'NoneType'> found in 'provider'. and we were unable to convert to int: <class 'NoneType'> cannot be converted to an int"}
"msg": "argument 'no_f5_teem' is of type <class 'NoneType'> found in 'provider'. and we were unable to convert to bool: <class 'NoneType'> cannot be converted to a bool"

I have to force the default values in order to make it work:

f5_modules_common_settings:
  provider:
    server: "{{ inventory_hostname }}"
    server_port: 443
    no_f5_teem: false

But we also found a workaround on a venv running ansible=7.7.0 and python=3.11 that works flawlessly

VDI-Tech-Guy commented 6 months ago

From what i have gathered from this issue, it seems like some of the modules do not provide a DEFAULT value for the no_f5_teem provider instance. My workaround was to just put it in all calls as a required variable as it acts like the no_f5_teem variable is required to be defined to work correctly with module execution. Either that or the python instance is not coding the module with a default boolean value correctly for other python versions to work appropriately .

i do think we should enforce it as a required variable as it acts like it or fix its default nature as it produces the error above when its not defined and by the documentation it says it's not a required variable but running the code contradicts that.