F5Networks / f5-ansible

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

bigip_device_certificate 'NoneType' object has no attribute 'lower' #1844

Closed dbarboza closed 3 years ago

dbarboza commented 3 years ago
ISSUE TYPE
COMPONENT NAME

bigip_device_certificate

ANSIBLE VERSION
ansible 2.9.13
  config file = /Users/dbarboza/go/src/github.com/bluearchive/main/infrastructure/ansible/ansible.cfg
  configured module search path = ['/Users/dbarboza/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.8.5 (default, Jul 21 2020, 10:48:26) [Clang 11.0.3 (clang-1103.0.32.62)]
PYTHON VERSION
Python 2.7.17 
but Ansible is using Python3
Python 3.8.5

I also tested on a 2.7.12 on Linux

BIGIP VERSION
Sys::Version
Main Package
  Product     BIG-IP
  Version     15.1.0.4
  Build       0.21.6
  Edition     Engineering Hotfix
  Date        Mon Jul  6 23:16:20 PDT 2020

Hotfix List
ID886841-1
CONFIGURATION
OS / ENVIRONMENT

MacOS 10.15.6

F5_USER, F5_PASSWORD, F5_VALIDATE_CERTS=no are set via environment variables

SUMMARY

When using the module as in the documentation example, it errors:

TASK [Update expired certificate] ***************************************************************************************************************************************
task path: /Users/dbarboza/go/src/github.com/bluearchive/main/infrastructure/ansible/testing/f5-pull.yml:21
using connection plugin network_cli
The full traceback is:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/ansible/executor/task_executor.py", line 147, in run
    res = self._execute()
  File "/usr/local/lib/python3.8/site-packages/ansible/executor/task_executor.py", line 665, in _execute
    result = self._handler.run(task_vars=variables)
  File "/usr/local/lib/python3.8/site-packages/ansible/plugins/action/bigip.py", line 94, in run
    out = conn.get_prompt()
  File "/usr/local/lib/python3.8/site-packages/ansible/module_utils/connection.py", line 185, in __rpc__
    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
ansible.module_utils.connection.ConnectionError: 'NoneType' object has no attribute 'lower'
fatal: [lb1.needham]: FAILED! => {
    "msg": "Unexpected failure during module execution.",
    "stdout": ""
}
STEPS TO REPRODUCE

Playbook:

- name: test f5 modules
  hosts: "lb1"
  serial: 1
  connection: local
  strategy: linear
  vars:
    provider:
      server: "{{ inventory_hostname }}"
  gather_facts: yes
  tasks:
  - name: Update expired certificate
    bigip_device_certificate:
      days_valid: 365
      provider:
        transport: cli
        server_port: 22
EXPECTED RESULTS
ACTUAL RESULTS
TASK [Update expired certificate] ********************************************************************************************
task path: /home/users/dbarboza/go/src/github.com/bluearchive/main/infrastructure/ansible/testf5.yml:21
<lb1.needham> connection transport is cli
using connection plugin network_cli
starting connection from persistent connection plugin
local domain socket does not exist, starting it
control socket path is /home/users/dbarboza/.ansible/pc/5c2d27f4eb
local domain socket listeners started successfully
unable to load cliconf for network_os bigip

local domain socket path is /home/users/dbarboza/.ansible/pc/5c2d27f4eb
socket_path: /home/users/dbarboza/.ansible/pc/5c2d27f4eb
The full traceback is:
Traceback (most recent call last):
  File "/home/users/dbarboza/.local/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 147, in run
    res = self._execute()
  File "/home/users/dbarboza/.local/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 665, in _execute
    result = self._handler.run(task_vars=variables)
  File "/home/users/dbarboza/.local/lib/python2.7/site-packages/ansible/plugins/action/bigip.py", line 94, in run
    out = conn.get_prompt()
  File "/home/users/dbarboza/.local/lib/python2.7/site-packages/ansible/module_utils/connection.py", line 185, in __rpc__
    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
ConnectionError: 'NoneType' object has no attribute 'lower'
fatal: [lb1.needham]: FAILED! => {
    "msg": "Unexpected failure during module execution.",
    "stdout": ""
}
nmenant commented 3 years ago

I tried the following and it works:

    - bigip_device_certificate:
        days_valid: 365
        force: yes
        provider: 
          password: xxx
          server: 192.168.143.153
          user: root
          transport: cli
          server_port: 22
      delegate_to: localhost

even if you create a provider variable, you're not using it in your bigip_device_certificate task.

focrensh commented 3 years ago

Please open a new issue if you are still experiencing a bug.