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

ImportError: cannot import name ContentCredentia #269

Closed itewk closed 5 years ago

itewk commented 5 years ago
SUMMARY

When I try to use these modules I get ImportError: cannot import name ContentCredentia

ISSUE TYPE
ANSIBLE VERSION
ansible 2.7.8
  config file = /root/domino/ansible.cfg
  configured module search path = [u'/root/domino/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, Sep 12 2018, 05:31:16) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
KATELLO/FOREMAN VERSION
tfm-rubygem-katello-3.4.5.74-1.el7sat.noarch
foreman-1.15.6.45-1.el7sat.noarch
NAILGUN VERSION
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Version: 0.31.0
STEPS TO REPRODUCE
- name: Test
  hosts: localhost
  gather_facts: False
  vars:
    satellite_url: xxxx
    satellite_username: xxx
    satellite_password: xxxx
    satellite_verify_ssl: False
    satellite_organization:
      name: rhc-lab
    satellite_products:
    - Red Hat Enterprise Linux Server
    #- Red Hat Satellite
    #- Red Hat Satellite Capsule
    #- Red Hat OpenShift Container Platform
    #- Red Hat CloudForms
    #- Red Hat Ansible Engine
    satellite_api_basion: localhost
  tasks:
  - name: Satellite | Sync Products
    katello_sync:
      server_url: "{{ satellite_url }}"
      username: "{{ satellite_username }}"
      password: "{{ satellite_password }}"
      verify_ssl: "{{ satellite_verify_ssl }}"
      organization: "{{ satellite_organization['name'] }}"
      product: "{{ immediate_sync_product }}"
    loop: "{{ satellite_products }}"
    loop_control:
      loop_var: immediate_sync_product
    delegate_to: "{{ satellite_api_basion }}"
    register: immediate_sync_products_results
    #async: 3600
    #poll: 0

  - name: Satellite | Sync Products | Wait for async tasks
    async_status:
      jid: "{{ immediate_sync_products_result.ansible_job_id }}"
    loop: "{{ immediate_sync_products_results.results }}"
    loop_control:
      loop_var: "immediate_sync_products_result"
    delegate_to: localhost
    register: async_immediate_sync_products_results
    until: async_immediate_sync_products_results.finished
    retries: 120
    delay: 30
EXPECTED RESULTS

For products to sync

ACTUAL RESULTS
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_katello_sync_payload_R7E_UH/ansible_katello_sync_payload.zip/ansible/module_utils/foreman_helper.py", line 11, in <module>
    import ansible.module_utils.ansible_nailgun_cement
  File "/tmp/ansible_katello_sync_payload_R7E_UH/ansible_katello_sync_payload.zip/ansible/module_utils/ansible_nailgun_cement.py", line 9, in <module>

▽
[defaults]
ImportError: cannot import name ContentCredential

failed: [localhost -> localhost] (item=Red Hat Enterprise Linux Server) => {
    "changed": false,
    "immediate_sync_product": "Red Hat Enterprise Linux Server",
    "invocation": {
        "module_args": {
            "organization": "rhc-lab",
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "product": "Red Hat Enterprise Linux Server",
            "repository": null,
            "server_url": "https://satellite.rhc-lab.iad.redhat.com",
            "synchronous": true,
            "username": "itewk",
            "verify_ssl": false
        }
    },
    "msg": "The nailgun Python module is required"
}
mdellweg commented 5 years ago

Pretty sure, this module is only compatible to nailgun >= 0.32.0

https://github.com/SatelliteQE/nailgun/commit/8b2fe0eaf4d542153658fe64ce742d75545ed902

itewk commented 5 years ago

@mdellweg that was problem. Might be nice to have that on the README.

mdellweg commented 5 years ago

Well, yes. But at least it is here: https://github.com/theforeman/foreman-ansible-modules/blob/0817fc5b29edf430cb6c9d7785e9753163c981ad/modules/katello_content_credential.py#L28

itewk commented 5 years ago

@mdellweg nice and visible it is there indeed :)

Thanks for the help.