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

Tower settings fails with stacktrace - expected to exit gracefully #7267

Closed
kedark3 opened this issue Jun 5, 2020 · 4 comments · Fixed by #7270
Closed

Tower settings fails with stacktrace - expected to exit gracefully #7267

kedark3 opened this issue Jun 5, 2020 · 4 comments · Fixed by #7270
Assignees
Labels
component:awx_collection issues related to the collection for controlling AWX type:bug

Comments

@kedark3
Copy link

kedark3 commented Jun 5, 2020

ISSUE TYPE
  • Bug Report
SUMMARY

Running awx.awx.settings module throws AttributeError: 'NoneType' object has no attribute 'startswith'

ENVIRONMENT
  • AWX version: 11.2.0
  • AWX install method: setup.sh
  • Ansible version: 2.9.7
  • Operating System: Tower on RHEL, Ansible on Fedora
STEPS TO REPRODUCE
---
# tasks file for ansible_tower_genie_settings- name: Update Ansible Tower Settings
  awx.awx.tower_settings:
    name:                "{{ tower_setting_item.name | default(omit) }}"
    value:               "{{ tower_setting_item.value | default(omit) }}"
    tower_config_file:   "{{ tower_config_file | default(omit) }}"
    tower_host:          "{{ tower_hostname | default(omit) }}"
    tower_password:      "{{ tower_password | default(omit) }}"
    tower_username:      "{{ tower_username | default(omit) }}"
    validate_certs:      "{{ validate_certs | default('false') }}"
  loop: "{{ tower_settings }}"
  loop_control:
    loop_var: tower_setting_item
...

Data:

---
tower_settings:
  - name: AWX_TASK_ENV
    setting: {'GIT_SSL_NO_VERIFY': 'True'}
EXPECTED RESULTS

Error should be more helpful, gracefully handled vs flat out traceback if possible.

ACTUAL RESULTS
The full traceback is:
Traceback (most recent call last):
  File "/home/kkulkarni/.ansible/tmp/ansible-tmp-1591366383.968238-878504-224766098821440/AnsiballZ_tower_settings.py", line 102, in <module>
    _ansiballz_main()
  File "/home/kkulkarni/.ansible/tmp/ansible-tmp-1591366383.968238-878504-224766098821440/AnsiballZ_tower_settings.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/kkulkarni/.ansible/tmp/ansible-tmp-1591366383.968238-878504-224766098821440/AnsiballZ_tower_settings.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.awx.awx.plugins.modules.tower_settings', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib64/python3.8/runpy.py", line 206, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib64/python3.8/runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib64/python3.8/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_awx.awx.tower_settings_payload_x13vlw6v/ansible_awx.awx.tower_settings_payload.zip/ansible_collections/awx/awx/plugins/modules/tower_settings.py", line 184, in <module>
  File "/tmp/ansible_awx.awx.tower_settings_payload_x13vlw6v/ansible_awx.awx.tower_settings_payload.zip/ansible_collections/awx/awx/plugins/modules/tower_settings.py", line 136, in main
  File "/tmp/ansible_awx.awx.tower_settings_payload_x13vlw6v/ansible_awx.awx.tower_settings_payload.zip/ansible_collections/awx/awx/plugins/modules/tower_settings.py", line 95, in coerce_type
AttributeError: 'NoneType' object has no attribute 'startswith'
failed: [localhost] (item={'name': 'AWX_TASK_ENV', 'setting': {'GIT_SSL_NO_VERIFY': 'True'}}) => {
    "ansible_loop_var": "tower_setting_item",
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/home/kkulkarni/.ansible/tmp/ansible-tmp-1591366383.968238-878504-224766098821440/AnsiballZ_tower_settings.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/home/kkulkarni/.ansible/tmp/ansible-tmp-1591366383.968238-878504-224766098821440/AnsiballZ_tower_settings.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/kkulkarni/.ansible/tmp/ansible-tmp-1591366383.968238-878504-224766098821440/AnsiballZ_tower_settings.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.awx.awx.plugins.modules.tower_settings', init_globals=None, run_name='__main__', alter_sys=True)\n  File \"/usr/lib64/python3.8/runpy.py\", line 206, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib64/python3.8/runpy.py\", line 96, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib64/python3.8/runpy.py\", line 86, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_awx.awx.tower_settings_payload_x13vlw6v/ansible_awx.awx.tower_settings_payload.zip/ansible_collections/awx/awx/plugins/modules/tower_settings.py\", line 184, in <module>\n  File \"/tmp/ansible_awx.awx.tower_settings_payload_x13vlw6v/ansible_awx.awx.tower_settings_payload.zip/ansible_collections/awx/awx/plugins/modules/tower_settings.py\", line 136, in main\n  File \"/tmp/ansible_awx.awx.tower_settings_payload_x13vlw6v/ansible_awx.awx.tower_settings_payload.zip/ansible_collections/awx/awx/plugins/modules/tower_settings.py\", line 95, in coerce_type\nAttributeError: 'NoneType' object has no attribute 'startswith'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1,
    "tower_setting_item": {
        "name": "AWX_TASK_ENV",
        "setting": {
            "GIT_SSL_NO_VERIFY": "True"
        }
    }
}
ADDITIONAL INFORMATION
@awxbot awxbot added the type:bug label Jun 5, 2020
@sumkincpp
Copy link
Contributor

You are using module incorrecly. See documentation at the top of module source.
Either name + value or settings properties should be used.

Perhaps, you mean:

tower_settings:
  - name: AWX_TASK_ENV
    value: "{'GIT_SSL_NO_VERIFY': 'True'}"

or

tower_settings:
  - settings:
      AWX_TASK_ENV: "{'GIT_SSL_NO_VERIFY': 'True'}"

Latest devel already have a requirement for one use case, though type for input value is not explicitly checked to be string.

https://github.com/ansible/awx/blob/devel/awx_collection/plugins/modules/tower_settings.py

@wenottingham wenottingham added component:awx_collection issues related to the collection for controlling AWX priority:low labels Jun 5, 2020
@wenottingham
Copy link
Contributor

wenottingham commented Jun 5, 2020

Marking as low, it's an incorrect invocation, but we may consider a nicer error.

@kedark3
Copy link
Author

kedark3 commented Jun 5, 2020

@wenottingham @sumkincpp I am aware that the invocation was wrong and I know the correct way but I pasted wrong version here so that you can see how to reproduce that error. Thanks.

@kdelee
Copy link
Member

kdelee commented Jul 7, 2020

Tried this out in a local playbook and this is working for me now. Let me know if you need something further @kedark3, closing for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:awx_collection issues related to the collection for controlling AWX type:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants