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

manifest role does not handle a changed manifest simply. #1585

Open parmstro opened 1 year ago

parmstro commented 1 year ago
SUMMARY

When uploading a manifest to a satellite/foreman server after updating it or redefining it, the manifest role appears to not automatically try to refresh the manifest and instead fails. Also, trying to write a recovery fails if the manifest has been deleted on the portal...

ISSUE TYPE
ANSIBLE VERSION
ansible --version
ansible [core 2.13.3]
  config file = /home/parmstro/.ansible.cfg
  configured module search path = ['/home/parmstro/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /home/parmstro/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.14 (main, Nov  7 2022, 00:00:00) [GCC 11.3.1 20220421 (Red Hat 11.3.1-2)]
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
redhat.satellite            3.9.0-dev
KATELLO/FOREMAN VERSION
satellite 6.12.3
STEPS TO REPRODUCE
  1. Create, download and upload a manifest to the satellite
  2. Change the manifest.
  3. Redownload the manifest and try to upload it
  4. "Owner has already imported from another subscription management application. [DISTRIBUTOR_CONFLICT]"
- name: "Upload the manifest"
  ansible.builtin.include_role:
    name: redhat.satellite.manifest
  vars:
    satellite_server_url: "{{ satellite_url }}"
    satellite_username: "{{ satellite_admin_username }}"
    satellite_password: "{{ satellite_admin_password }}"
    satellite_organization: "{{ satellite_initial_organization }}"
    satellite_manifest_path: "{{ manifest_path }}"
EXPECTED RESULTS

The subscription is refreshed or replaced.

ACTUAL RESULTS

Errors below...

TASK [satellite_post : Try to upload] ******************************************************************************
fatal: [sat.example.ca]: FAILED! => {"changed": false, "msg": "Upload of the manifest failed: Owner has already imported from another subscription management application. The following conflicts were found: [ DISTRIBUTOR_CONFLICT ]"}

TASK [satellite_post : Try to refresh existing] ********************************************************************
fatal: [sat.example.ca]: FAILED! => {"changed": false, "error": {"displayMessage": "The Subscription Allocation providing the imported manifest has been removed. Please create a new Subscription Allocation and import the new manifest.", "errors": ["The Subscription Allocation providing the imported manifest has been removed. Please create a new Subscription Allocation and import the new manifest."]}, "msg": "Error while performing refresh_manifest on subscriptions: 400 Client Error: Bad Request for url: https://sat.example.ca/katello/api/organizations/1/subscriptions/refresh_manifest"}
parmstro commented 1 year ago

I can understand why this may behave the way it does... avoiding the whole reattach all the subs thing. But a "force: true" parameter might be a nice add.