ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
14.11k stars 3.43k forks source link

awx.awx.import / awx import issue with inventories: #13996

Open pombaer opened 1 year ago

pombaer commented 1 year ago

Please confirm the following

Bug Summary

I have an inventory called "empty" without source, very basic, only "localhost" is defined:

inventory:
- description: 'empty inv'
  host_filter: null
  kind: ''
  name: empty
  natural_key:
    name: empty
    organization:
      name: Default
      type: organization
    type: inventory
  organization:
    name: Default
    type: organization
  prevent_instance_group_fallback: false
  related:
    groups: []
    hosts:
    - description: ''
      enabled: true
      instance_id: ''
      inventory:
        name: empty
        organization:
          name: Default
          type: organization
        type: inventory
      name: localhost
      natural_key:
        inventory:
          name: empty
          organization:
            name: Default
            type: organization
          type: inventory
        name: localhost
        type: host
      related:
        groups: []
      variables: '---'
    labels: []
  variables: '---'

Running following command does not raise an error but also does not import the inventory:

awx import -k -f yaml < empty.yml

Same behavior with awx.awx.import:

- name: "create empty inventory"
  awx.awx.import:
    assets: "{{ empty_inventory }}"
  environment:
    CONTROLLER_VERIFY_SSL: "{{ awx_cli_verify_ssl }}"
    CONTROLLER_HOST: "{{ awx_hostname | default(inventory_hostname) }}"
    CONTROLLER_USERNAME: "{{ awx_username | default(awx_admin_username) }}"
    CONTROLLER_PASSWORD: "{{ awx_password | default(awx_admin_password) }}"

This worked on a previous version, dont know which, but it was a recent version 21.x or so.

If i have a clean installation of AWX, only containing Organizations i have to create a dummy project and a dummy inventory before issuing the command, otherwise i get an error:

awx import -k -f yaml < empty.yml
Insufficient privileges on /api/v2/inventory_sources/, inferring POST fields from description.
Insufficient privileges on /api/v2/job_templates/, inferring POST fields from description.

I think this is also an error but i can work around it, so i can live with it.

May the behavior is intended since newer versions of awx, but cannot imagine.

AWX version

22.2.0

Select the relevant components

Installation method

kubernetes

Modifications

no

Ansible version

No response

Operating system

Debian 11.4

Web browser

No response

Steps to reproduce

Run the commands above.

Expected results

Inventory should be created

Actual results

Inventoy is not created, no error occurs, in case of playbook "OK" is returned by the awx.awx.import task.

Additional information

awxkit: 22.2.0 awx.awx collection: 22.2.0

pombaer commented 1 year ago

By the way, i now tried awxkit version 21.13.0, this version works as expected, inventory is created, looks like an cli issue, not awx since i still use latest awx 22.2.0.

john-westcott-iv commented 1 year ago

See #13967, should be fixed by #13977

john-westcott-iv commented 1 year ago

The fixes mentioned above have been released today with AWX. Please try with the new version and let us know if its working now.

smokes2345 commented 11 months ago

i'm getting this error on the inventory_sources endpoint. IDK if it matters, but i'm running this against a fresh stack, installed using the awx-operator, using the operator installed admin credentials. I have tried installing the version of awxkit @pombaer says they are using (21.13.0), the latest version of awxkit, and the latest version of awxkit with the diff from the mentioned PR applied. I get the same error with all of them.