Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module vmware_vcenter_settings bug and functionality #66713

Closed
nicholasrodriguez opened this issue Jan 23, 2020 · 6 comments · Fixed by ansible-collections/community.vmware#225
Labels
affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. cloud collection:community.vmware collection Related to Ansible Collections work has_pr This issue has an associated PR. module This issue/PR relates to a module. needs_collection_redirect https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md support:community This issue/PR relates to code supported by the Ansible community. traceback This issue/PR includes a traceback. vmware VMware community

Comments

@nicholasrodriguez
Copy link

SUMMARY

This module still dosen't function correctly if runtime_settings isn't specified but has potential for misconfiguration in general.

For runtime_settings there is no default dict defined in argument_spec.update(...) in main() so if the runtime_settings key isn't defined then the module fails with the error in ACTUAL RESULTS section.

In the documentation these keys aren't specified as required.

In general the functionality of this module should be that only a subset or all of the available options should be configured if declared.

It appears that if you don't specify options then the defaults built into the module for each of the options are used and will overwrite anything currently configured on the target vCenter. This is potentially dangerous and could cause issues.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

vmware_vcenter_settings

ANSIBLE VERSION

The latest devel version of vmware_vcenter_settings has been used

ansible 2.8.0
  config file = None
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Jun 11 2019, 14:33:56) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
CONFIGURATION
DEFAULT_MANAGED_STR(/<PATH>/vmware-ansible/ansible.cfg) = This file is managed by Ansible
HOST_KEY_CHECKING(/<PATH>/vmware-ansible/ansible.cfg) = False
RETRY_FILES_ENABLED(/<PATH>/vmware-ansible/ansible.cfg) = False
OS / ENVIRONMENT

Ansible controller CentOS 7.5, RedHat 7.6
vSphere all 6.7

STEPS TO REPRODUCE
- name: 'Configure the vCenter settings'
  connection: 'local'
  vmware_vcenter_settings:
    hostname: '{{ ansible_host }}'
    username: '{{ ansible_vcenter_username }}'
    password: '{{ ansible_vcenter_password }}'
    snmp_receivers:
      snmp_receiver_1_url: "{{ snmp_destination }}"
      snmp_receiver_1_enabled: true
      snmp_receiver_1_port: 162
      snmp_receiver_1_community: "{{ snmp_string }}"
    logging_options: info
    validate_certs: '{{ validate_certs }}'
EXPECTED RESULTS

Only the options specified are configured

ACTUAL RESULTS
The full traceback is:
Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-tmp-1579533439.33-60520445339576/AnsiballZ_vmware_vcenter_settings.py", line 114, in <module>
    _ansiballz_main()
  File "/root/.ansible/tmp/ansible-tmp-1579533439.33-60520445339576/AnsiballZ_vmware_vcenter_settings.py", line 106, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/root/.ansible/tmp/ansible-tmp-1579533439.33-60520445339576/AnsiballZ_vmware_vcenter_settings.py", line 49, in invoke_module
    imp.load_module('__main__', mod, module, MOD_DESC)
  File "/tmp/ansible_vmware_vcenter_settings_payload_GqX7zC/__main__.py", line 696, in <module>
  File "/tmp/ansible_vmware_vcenter_settings_payload_GqX7zC/__main__.py", line 692, in main
  File "/tmp/ansible_vmware_vcenter_settings_payload_GqX7zC/__main__.py", line 240, in ensure
AttributeError: 'NoneType' object has no attribute 'get'

fatal: [<VCENTER FQDN>]: FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-tmp-1579533439.33-60520445339576/AnsiballZ_vmware_vcenter_settings.py\", line 114, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-tmp-1579533439.33-60520445339576/AnsiballZ_vmware_vcenter_settings.py\", line 106, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-tmp-1579533439.33-60520445339576/AnsiballZ_vmware_vcenter_settings.py\", line 49, in invoke_module\n    imp.load_module('__main__', mod, module, MOD_DESC)\n  File \"/tmp/ansible_vmware_vcenter_settings_payload_GqX7zC/__main__.py\", line 696, in <module>\n  File \"/tmp/ansible_vmware_vcenter_settings_payload_GqX7zC/__main__.py\", line 692, in main\n  File \"/tmp/ansible_vmware_vcenter_settings_payload_GqX7zC/__main__.py\", line 240, in ensure\nAttributeError: 'NoneType' object has no attribute 'get'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
@ansibot
Copy link
Contributor

ansibot commented Jan 23, 2020

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Jan 23, 2020

@ansibot
Copy link
Contributor

ansibot commented Jan 23, 2020

@nicholasrodriguez, just so you are aware we have a dedicated Working Group for vmware.
You can find other people interested in this in #ansible-vmware on Freenode IRC
For more information about communities, meetings and agendas see https://github.com/ansible/community

click here for bot help

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. cloud module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. traceback This issue/PR includes a traceback. vmware VMware community labels Jan 23, 2020
sky-joker added a commit to sky-joker/ansible that referenced this issue Feb 22, 2020
sky-joker added a commit to sky-joker/ansible that referenced this issue Feb 22, 2020
sky-joker added a commit to sky-joker/ansible that referenced this issue Feb 23, 2020
…ngs ansible#66713

add fragments file

small fix

Refactoring the vmware_vcenter_settngs.py file for optimize
@sky-joker
Copy link
Contributor

@nicholasrodriguez
Copy link
Author

nicholasrodriguez commented Mar 5, 2020

Thanks @sky-joker and @goneri
I've installed the module locally and if I run the following

ansible-doc -t module vmware_vcenter_settings

I get the following error

ERROR! module vmware_vcenter_settings has a documentation error formatting or is missing documentation.

@nicholasrodriguez
Copy link
Author

I've run with the module version in bdcaf4a using the following config

- name: 'Configure the vCenter settings'
  connection: 'local'
  vmware_vcenter_settings:
    hostname: '{{ ansible_host }}'
    username: '{{ ansible_vcenter_username }}'
    password: '{{ ansible_vcenter_password }}'
    snmp_receivers:
      snmp_receiver_1_url: "{{ snmp_destination }}"
      snmp_receiver_1_enabled: true
      snmp_receiver_1_port: 162
      snmp_receiver_1_community: "{{ snmp_string }}"
    logging_options: info
    validate_certs: '{{ validate_certs }}'

I get the following traceback

The full traceback is:
Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-tmp-1583426855.9080684-79788441564163/AnsiballZ_vmware_vcenter_settings.py", line 114, in <module>
    _ansiballz_main()
  File "/root/.ansible/tmp/ansible-tmp-1583426855.9080684-79788441564163/AnsiballZ_vmware_vcenter_settings.py", line 106, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/root/.ansible/tmp/ansible-tmp-1583426855.9080684-79788441564163/AnsiballZ_vmware_vcenter_settings.py", line 49, in invoke_module
    imp.load_module('__main__', mod, module, MOD_DESC)
  File "/tmp/ansible_vmware_vcenter_settings_payload_cZWeEf/__main__.py", line 688, in <module>
  File "/tmp/ansible_vmware_vcenter_settings_payload_cZWeEf/__main__.py", line 684, in main
  File "/tmp/ansible_vmware_vcenter_settings_payload_cZWeEf/__main__.py", line 236, in ensure
AttributeError: 'NoneType' object has no attribute 'get'

fatal: [<VCENTER FQDN>]: FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-tmp-1583426855.9080684-79788441564163/AnsiballZ_vmware_vcenter_settings.py\", line 114, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-tmp-1583426855.9080684-79788441564163/AnsiballZ_vmware_vcenter_settings.py\", line 106, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-tmp-1583426855.9080684-79788441564163/AnsiballZ_vmware_vcenter_settings.py\", line 49, in invoke_module\n    imp.load_module('__main__', mod, module, MOD_DESC)\n  File \"/tmp/ansible_vmware_vcenter_settings_payload_cZWeEf/__main__.py\", line 688, in <module>\n  File \"/tmp/ansible_vmware_vcenter_settings_payload_cZWeEf/__main__.py\", line 684, in main\n  File \"/tmp/ansible_vmware_vcenter_settings_payload_cZWeEf/__main__.py\", line 236, in ensure\nAttributeError: 'NoneType' object has no attribute 'get'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

@ansibot ansibot added collection Related to Ansible Collections work collection:community.vmware needs_collection_redirect https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md labels Apr 29, 2020
@sivel sivel removed the needs_triage Needs a first human triage before being processed. label Jun 22, 2020
@ansible ansible locked and limited conversation to collaborators Jul 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. cloud collection:community.vmware collection Related to Ansible Collections work has_pr This issue has an associated PR. module This issue/PR relates to a module. needs_collection_redirect https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md support:community This issue/PR relates to code supported by the Ansible community. traceback This issue/PR includes a traceback. vmware VMware community
Projects
None yet
4 participants