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
147 stars 163 forks source link

redhat_manifest need to be updated to work with RHSM #300

Closed flyemsafe closed 5 years ago

flyemsafe commented 5 years ago
SUMMARY

redhat_manifest only works with RHN which is now replaced by RHSM. The portal URL is no longer https://subscription.rhn.redhat.com which means the API calls this module uses no longer works.

ISSUE TYPE
ANSIBLE VERSION
ansible 2.7.10
  config file = /home/rheron/LunchBoxAnsible/ansible.cfg
  configured module search path = [u'/home/rheron/LunchBoxAnsible/library/foreman-ansible-modules/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Mar 26 2019, 22:13:06) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
KATELLO/FOREMAN VERSION
[root@sat ~]# rpm -q tfm-rubygem-katello foreman
tfm-rubygem-katello-3.10.0.46-1.el7sat.noarch
foreman-1.20.1.34-1.el7sat.noarch
NAILGUN VERSION
Metadata-Version: 1.1
Version: 0.32.0
STEPS TO REPRODUCE
- name: create a subscription allocations and add subscritions to it
  redhat_manifest:
    name: ACME
    username: "{{ rhsm_user }}"
    password: "{{ rhsm_pass }}"
    portal: https://access.redhat.com
    pool_id: "{{ sub_pool_id }}"
    quantity: 7
    state: present
    validate_certs: yes
  tags: portal
EXPECTED RESULTS
ACTUAL RESULTS

Play failed to create subscription allocation.

<172.24.24.11> ESTABLISH SSH CONNECTION FOR USER: root
<172.24.24.11> SSH: EXEC sshpass -d8 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o User=root -o ConnectTimeout=10 -o ControlPath=/home/rheron/.ansible/cp/c6b9112b72 172.24.24.11 '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1559683111.07-226787251032963/ > /dev/null 2>&1 && sleep 0'"'"''
<172.24.24.11> (0, '', 'OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 58: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 65792\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
The full traceback is:
WARNING: The below traceback may *not* be related to the actual failure.
  File "/tmp/ansible_redhat_manifest_payload_Ck4rBJ/__main__.py", line 130, in fetch_portal
    error = json.loads(info['body'])['displayMessage']
  File "/usr/lib64/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")

fatal: [sat]: FAILED! => {
    "changed": false, 
    "invocation": {
        "module_args": {
            "force_basic_auth": true, 
            "name": "FedSI", 
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "path": null, 
            "pool_id": "8a85f99b6977b7c0016979464ee772cb", 
            "pool_state": "present", 
            "portal": "https://access.redhat.com", 
            "quantity": 7, 
            "state": "present", 
            "url_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "url_username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "uuid": null, 
            "validate_certs": true
        }
    }, 
    "msg": "GET to https://access.redhat.com/subscription/users/********/owners failed, got HTTP Error 404: Not Found"
}
evgeni commented 5 years ago

access.redhat.com is the wrong host for that. Can you please try setting portal: https://subscription.rhsm.redhat.com and see if that works?

evgeni commented 5 years ago

Also, https://subscription.rhn.redhat.com is RHSM, despite the RHN in its name, so it should still work just fine.

flyemsafe commented 5 years ago

Thanks @evgeni. You are correct.

sean797 commented 5 years ago

So do we need to change the default URL from subscription.rhn.redhat.com to subscription.rhsm.redhat.com ?

evgeni commented 5 years ago

Should, yes. Have? Not too much, both urls work today (even tho they land on different systems). But the modern RHEL default uses the rhsm url and so should we