foreman-ansible-modules icon indicating copy to clipboard operation
foreman-ansible-modules copied to clipboard

theforeman.foreman.setting exception on some settings

Open gvde opened this issue 2 years ago • 0 comments

SUMMARY

theforeman.foreman.setting in 3.4.0 throws an exception for some settings with default setting, e.g. foreman_ansible_proxy_batch_size:

TASK [theforeman.foreman.settings : Create Settings] **************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ValueError: invalid literal for int() with base 10: ''
failed: [foreman8.example.com] (item={'name': 'foreman_ansible_proxy_batch_size'}) => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3.8"}, "ansible_loop_var": "item", "changed": false, "item": {"name": "foreman_ansible_proxy_batch_size"}, "module_stderr": "Traceback (most recent call last):\n  File \"/home/k/k202081/.ansible/tmp/ansible-tmp-1655283088.5066955-976725-10731515661137/AnsiballZ_setting.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/home/k/k202081/.ansible/tmp/ansible-tmp-1655283088.5066955-976725-10731515661137/AnsiballZ_setting.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/k/k202081/.ansible/tmp/ansible-tmp-1655283088.5066955-976725-10731515661137/AnsiballZ_setting.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.theforeman.foreman.plugins.modules.setting', init_globals=dict(_module_fqn='ansible_collections.theforeman.foreman.plugins.modules.setting', _modlib_path=modlib_path),\n  File \"/usr/lib64/python3.8/runpy.py\", line 207, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib64/python3.8/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib64/python3.8/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_theforeman.foreman.setting_payload_cixya1us/ansible_theforeman.foreman.setting_payload.zip/ansible_collections/theforeman/foreman/plugins/modules/setting.py\", line 112, in <module>\n  File \"/tmp/ansible_theforeman.foreman.setting_payload_cixya1us/ansible_theforeman.foreman.setting_payload.zip/ansible_collections/theforeman/foreman/plugins/modules/setting.py\", line 97, in main\nValueError: invalid literal for int() with base 10: ''\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

Same applies to audits_period. So it looks like settings with integer values and default null are affected.

ISSUE TYPE
  • Bug Report
ANSIBLE VERSION
ansible [core 2.12.2]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/k/k111111/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.8/site-packages/ansible
  ansible collection location = /home/k/k111111/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.8.12 (default, Apr 21 2022, 07:55:08) [GCC 8.5.0 20210514 (Red Hat 8.5.0-10)]
  jinja version = 3.0.2
  libyaml = False
COLLECTION VERSION
$ ansible-galaxy collection list

# /usr/share/ansible/collections/ansible_collections
Collection         Version
------------------ -------
redhat.rhel_mgmt   1.0.0  
theforeman.foreman 3.1.0  

# /home/k/k111111/.ansible/collections/ansible_collections
Collection         Version
------------------ -------
theforeman.foreman 3.4.0  

KATELLO/FOREMAN VERSION
$ rpm -q katello foreman
katello-4.4.1-1.el8.noarch
foreman-3.2.1-1.el8.noarch
STEPS TO REPRODUCE
---
- name: configure foreman server
  hosts: foreman
  gather_facts: false

  roles:
    - role: theforeman.foreman.settings
      vars:
        foreman_settings:
          - name: "foreman_ansible_proxy_batch_size"

No value parameter set!

EXPECTED RESULTS

No error.

ACTUAL RESULTS
ansible-playbook [core 2.12.2]
  config file = /home/k/k111111/git/foreman-ansible/ansible.cfg
  configured module search path = ['/home/k/k111111/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.8/site-packages/ansible
  ansible collection location = /home/k/k111111/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible-playbook
  python version = 3.8.12 (default, Apr 21 2022, 07:55:08) [GCC 8.5.0 20210514 (Red Hat 8.5.0-10)]
  jinja version = 3.0.2
  libyaml = False
Using /home/k/k111111/git/foreman-ansible/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /home/k/k111111/git/foreman-ansible/hosts as it did not pass its verify_file() method
script declined parsing /home/k/k111111/git/foreman-ansible/hosts as it did not pass its verify_file() method
auto declined parsing /home/k/k111111/git/foreman-ansible/hosts as it did not pass its verify_file() method
Parsed /home/k/k111111/git/foreman-ansible/hosts inventory source with ini plugin
Loading collection theforeman.foreman from /home/k/k111111/.ansible/collections/ansible_collections/theforeman/foreman
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python3.8/site-packages/ansible/plugins/callback/default.py
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: test3.yaml ***********************************************************
Positional arguments: test3.yaml
verbosity: 4
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
check: True
diff: True
inventory: ('/home/k/k111111/git/foreman-ansible/hosts',)
subset: foreman8.example.com
forks: 5
1 plays in test3.yaml

PLAY [configure foreman server] ************************************************
META: ran handlers

TASK [theforeman.foreman.settings : Create Settings] ***************************
task path: /home/k/k111111/.ansible/collections/ansible_collections/theforeman/foreman/roles/settings/tasks/main.yml:2
<foreman8.example.com> ESTABLISH LOCAL CONNECTION FOR USER: k111111
<foreman8.example.com> EXEC /bin/sh -c 'echo ~k111111 && sleep 0'
<foreman8.example.com> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/k/k111111/.ansible/tmp `"&& mkdir "` echo /home/k/k111111/.ansible/tmp/ansible-tmp-1655283234.5635326-976928-83894853356087 `" && echo ansible-tmp-1655283234.5635326-976928-83894853356087="` echo /home/k/k111111/.ansible/tmp/ansible-tmp-1655283234.5635326-976928-83894853356087 `" ) && sleep 0'
<foreman8.example.com> Attempting python interpreter discovery
<foreman8.example.com> 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 '"'"'python2.6'"'"'; command -v '"'"'/usr/bin/python'"'"'; command -v '"'"'python'"'"'; echo ENDFOUND && sleep 0'
<foreman8.example.com> EXEC /bin/sh -c '/usr/bin/python3.8 && sleep 0'
<foreman8.example.com> Python interpreter discovery fallback (unsupported Linux distribution: almalinux)
Using module file /home/k/k111111/.ansible/collections/ansible_collections/theforeman/foreman/plugins/modules/setting.py
<foreman8.example.com> PUT /home/k/k111111/.ansible/tmp/ansible-local-976922fmbw5qj5/tmpys9s__9l TO /home/k/k111111/.ansible/tmp/ansible-tmp-1655283234.5635326-976928-83894853356087/AnsiballZ_setting.py
<foreman8.example.com> EXEC /bin/sh -c 'chmod u+x /home/k/k111111/.ansible/tmp/ansible-tmp-1655283234.5635326-976928-83894853356087/ /home/k/k111111/.ansible/tmp/ansible-tmp-1655283234.5635326-976928-83894853356087/AnsiballZ_setting.py && sleep 0'
<foreman8.example.com> EXEC /bin/sh -c '/usr/bin/python3.8 /home/k/k111111/.ansible/tmp/ansible-tmp-1655283234.5635326-976928-83894853356087/AnsiballZ_setting.py && sleep 0'
<foreman8.example.com> EXEC /bin/sh -c 'rm -f -r /home/k/k111111/.ansible/tmp/ansible-tmp-1655283234.5635326-976928-83894853356087/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/home/k/k111111/.ansible/tmp/ansible-tmp-1655283234.5635326-976928-83894853356087/AnsiballZ_setting.py", line 107, in <module>
    _ansiballz_main()
  File "/home/k/k111111/.ansible/tmp/ansible-tmp-1655283234.5635326-976928-83894853356087/AnsiballZ_setting.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/k/k111111/.ansible/tmp/ansible-tmp-1655283234.5635326-976928-83894853356087/AnsiballZ_setting.py", line 47, in invoke_module
    runpy.run_module(mod_name='ansible_collections.theforeman.foreman.plugins.modules.setting', init_globals=dict(_module_fqn='ansible_collections.theforeman.foreman.plugins.modules.setting', _modlib_path=modlib_path),
  File "/usr/lib64/python3.8/runpy.py", line 207, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib64/python3.8/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib64/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_theforeman.foreman.setting_payload_60_v8b3l/ansible_theforeman.foreman.setting_payload.zip/ansible_collections/theforeman/foreman/plugins/modules/setting.py", line 112, in <module>
  File "/tmp/ansible_theforeman.foreman.setting_payload_60_v8b3l/ansible_theforeman.foreman.setting_payload.zip/ansible_collections/theforeman/foreman/plugins/modules/setting.py", line 97, in main
ValueError: invalid literal for int() with base 10: ''
failed: [foreman8.example.com] (item={'name': 'foreman_ansible_proxy_batch_size'}) => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3.8"
    },
    "ansible_loop_var": "item",
    "changed": false,
    "item": {
        "name": "foreman_ansible_proxy_batch_size"
    },
    "module_stderr": "Traceback (most recent call last):\n  File \"/home/k/k111111/.ansible/tmp/ansible-tmp-1655283234.5635326-976928-83894853356087/AnsiballZ_setting.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/home/k/k111111/.ansible/tmp/ansible-tmp-1655283234.5635326-976928-83894853356087/AnsiballZ_setting.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/k/k111111/.ansible/tmp/ansible-tmp-1655283234.5635326-976928-83894853356087/AnsiballZ_setting.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.theforeman.foreman.plugins.modules.setting', init_globals=dict(_module_fqn='ansible_collections.theforeman.foreman.plugins.modules.setting', _modlib_path=modlib_path),\n  File \"/usr/lib64/python3.8/runpy.py\", line 207, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib64/python3.8/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib64/python3.8/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_theforeman.foreman.setting_payload_60_v8b3l/ansible_theforeman.foreman.setting_payload.zip/ansible_collections/theforeman/foreman/plugins/modules/setting.py\", line 112, in <module>\n  File \"/tmp/ansible_theforeman.foreman.setting_payload_60_v8b3l/ansible_theforeman.foreman.setting_payload.zip/ansible_collections/theforeman/foreman/plugins/modules/setting.py\", line 97, in main\nValueError: invalid literal for int() with base 10: ''\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

PLAY RECAP *********************************************************************
foreman8.example.com           : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

gvde avatar Jun 15 '22 08:06 gvde