theforeman / foreman-ansible-modules

Ansible modules for interacting with the Foreman API and various plugin APIs such as Katello
GNU General Public License v3.0
149 stars 166 forks source link

managing repository_sets fails with a 404 on satellite 6.3 and 6.4 #262

Closed dabelenda closed 5 years ago

dabelenda commented 5 years ago
SUMMARY

Trying to enable repository_sets on Satellite 6.4 and 6.3 I get a 404 error in a python stack trace.

From debugging on our side, apparently it tries to contact the API endpoint katello/api/v2/repository_sets/2456/available_repositories without providing the product_id parameter. So maybe nailgun (?) should use the API endpoint used by the web interface katello/api/v2/products/28/repository_sets/2456 instead.

ISSUE TYPE
ANSIBLE VERSION
ansible 2.7.10
  config file = None
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.15 (default, Feb  6 2019, 12:35:55) [GCC 6.3.0 20170516]
KATELLO/FOREMAN VERSION
tfm-rubygem-katello-3.7.0.46-1.el7sat.noarch
foreman-1.18.0.40-1.el7sat.noarch
NAILGUN VERSION
Version: 0.32.0
Also tried with branch 6.4.z (but hit https://github.com/theforeman/foreman-ansible-modules/issues/232 so I cherry-picked the fix).
Version: 0.30.2
STEPS TO REPRODUCE

Using the following ansible action definition:

- name: 'Enable RHEL7 Server Repositories'
  katello_repository_set:
    username: "{{ satellite_user }}"
    password: "{{ satellite_pwd }}"
    server_url: "{{ satellite_url }}"
    verify_ssl: false
    name: 'Red Hat Enterprise Linux 7 Server (RPMs)'
    organization: Test
    product: 'Red Hat Enterprise Linux Server'
    repositories:
    - releasever: "7Server"
      basearch: "x86_64"
    state: enabled

I get a 404 error in the ansible log.

EXPECTED RESULTS

Should either work, or tell what parameter is wrong.

ACTUAL RESULTS
TASK [satellite : Enable RHEL7 Server Repositories] *******************************************************************************************************************************************************************************************
task path: /home/user/ansible/roles/satellite/tasks/main.yml:2
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: user
<127.0.0.1> EXEC /bin/sh -c 'echo ~user && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/user/.ansible/tmp/ansible-tmp-1554456799.04-105447384786059 `" && echo ansible-tmp-1554456799.04-105447384786059="` echo /home/user/.ansible/tmp/ansible-tmp-1554456799.04-105447384786059 `" ) && sleep 0'
Using module file /home/user/ansible/foreman-ansible-modules/modules/katello_repository_set.py
<127.0.0.1> PUT /home/user/ansible/.ansible/tmp/ansible-local-14e3XHh/tmp7G_1q5 TO /home/user/.ansible/tmp/ansible-tmp-1554456799.04-105447384786059/AnsiballZ_katello_repository_set.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/user/.ansible/tmp/ansible-tmp-1554456799.04-105447384786059/ /home/user/.ansible/tmp/ansible-tmp-1554456799.04-105447384786059/AnsiballZ_katello_repository_set.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/local/bin/python /home/user/.ansible/tmp/ansible-tmp-1554456799.04-105447384786059/AnsiballZ_katello_repository_set.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/user/.ansible/tmp/ansible-tmp-1554456799.04-105447384786059/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {
    "changed": false, 
    "module_stderr": "WARNING:nailgun.client:Received HTTP 404 response: <!DOCTYPE html>\n<html>\n<head>\n  <title>The page you were looking for doesn't exist (404)</title>\n  <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n  <style>\n  body {\n    background-color: #EFEFEF;\n    color: #2E2F30;\n    text-align: center;\n    font-family: arial, sans-serif;\n    margin: 0;\n  }\n\n  div.dialog {\n    width: 95%;\n    max-width: 33em;\n    margin: 4em auto 0;\n  }\n\n  div.dialog > div {\n    border: 1px solid #CCC;\n    border-right-color: #999;\n    border-left-color: #999;\n    border-bottom-color: #BBB;\n    border-top: #B00100 solid 4px;\n    border-top-left-radius: 9px;\n    border-top-right-radius: 9px;\n    background-color: white;\n    padding: 7px 12% 0;\n    box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);\n  }\n\n  h1 {\n    font-size: 100%;\n    color: #730E15;\n    line-height: 1.5em;\n  }\n\n  div.dialog > p {\n    margin: 0 0 1em;\n    padding: 1em;\n    background-color: #F7F7F7;\n    border: 1px solid #CCC;\n    border-right-color: #999;\n    border-left-color: #999;\n    border-bottom-color: #999;\n    border-bottom-left-radius: 4px;\n    border-bottom-right-radius: 4px;\n    border-top-color: #DADADA;\n    color: #666;\n    box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);\n  }\n  </style>\n</head>\n\n<body>\n  <!-- This file lives in public/404.html -->\n  <div class=\"dialog\">\n    <div>\n      <h1>The page you were looking for doesn't exist.</h1>\n      <p>You may have mistyped the address or the page may have moved.</p>\n    </div>\n    <p>If you are the application owner check the logs for more information.</p>\n  </div>\n</body>\n</html>\n\nTraceback (most recent call last):\n  File \"/home/user/.ansible/tmp/ansible-tmp-1554456799.04-105447384786059/AnsiballZ_katello_repository_set.py\", line 113, in <module>\n    _ansiballz_main()\n  File \"/home/user/.ansible/tmp/ansible-tmp-1554456799.04-105447384786059/AnsiballZ_katello_repository_set.py\", line 105, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/user/.ansible/tmp/ansible-tmp-1554456799.04-105447384786059/AnsiballZ_katello_repository_set.py\", line 48, in invoke_module\n    imp.load_module('__main__', mod, module, MOD_DESC)\n  File \"/tmp/ansible_katello_repository_set_payload_8DeM6v/__main__.py\", line 215, in <module>\n  File \"/tmp/ansible_katello_repository_set_payload_8DeM6v/__main__.py\", line 211, in main\n  File \"/tmp/ansible_katello_repository_set_payload_8DeM6v/ansible_katello_repository_set_payload.zip/ansible/module_utils/basic.py\", line 2369, in fail_json\n  File \"/tmp/ansible_katello_repository_set_payload_8DeM6v/ansible_katello_repository_set_payload.zip/ansible/module_utils/basic.py\", line 2341, in _return_formatted\n  File \"/tmp/ansible_katello_repository_set_payload_8DeM6v/ansible_katello_repository_set_payload.zip/ansible/module_utils/basic.py\", line 522, in remove_values\n  File \"/tmp/ansible_katello_repository_set_payload_8DeM6v/ansible_katello_repository_set_payload.zip/ansible/module_utils/basic.py\", line 505, in _remove_values_conditions\nTypeError: Value of unknown type: <class 'requests.exceptions.HTTPError'>, 404 Client Error: Not Found for url: https://my.redacted.but.working.satellite.fqdn/katello/api/v2/repository_sets/2456/available_repositories\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", 
    "rc": 1
}
dabelenda commented 5 years ago

Fixed with Satellite 6.5 and nailgun@master foreman-ansible-modules@master.