The Wayback Machine - https://web.archive.org/web/20220706183524/https://github.com/ansible/awx/issues/11954
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

awx.awx.group option preserve hosts fails when there are no hosts. #11954

Open
3 of 6 tasks
sean-m-sullivan opened this issue Mar 24, 2022 · 4 comments
Open
3 of 6 tasks

awx.awx.group option preserve hosts fails when there are no hosts. #11954

sean-m-sullivan opened this issue Mar 24, 2022 · 4 comments
Labels
component:awx_collection good first issue type:bug

Comments

@sean-m-sullivan
Copy link
Contributor

@sean-m-sullivan sean-m-sullivan commented Mar 24, 2022

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that AWX is open source software provided for free and that I might not receive a timely response.

Summary

when using awx.awx.groups the preserve hosts/groups options fails if there are no groups/hosts.

AWX version

19.4.0

Select the relevant components

  • UI
  • API
  • Docs

Installation method

minikube

Modifications

no

Ansible version

No response

Operating system

No response

Web browser

No response

Steps to reproduce

    - name: Add host to temporary group for new vms
      awx.awx.group:
        name: new_vms
        inventory: "Temporary Inventory"
        hosts:
          - "{{ name }}"
        validate_certs: false
        preserve_existing_hosts: True
      when:
        - use_aap_inventory
        - vm is succeeded

Expected results

It runs and adds the host to the empty group

Actual results

TypeError: 'NoneType' object is not subscriptabl

Additional information

Because This line returns NoneType when there are no hosts in the group.

module needs to be updated to fix this issue.

@ikke-t
Copy link
Contributor

@ikke-t ikke-t commented Mar 24, 2022

Thanks for creating the issue. I verified now that the task works if I have the group and an existing host in the group.

So some error while doing it for a totally new group.

@ikke-t
Copy link
Contributor

@ikke-t ikke-t commented Mar 24, 2022

it works if the group is there but empty

@ikke-t
Copy link
Contributor

@ikke-t ikke-t commented Mar 24, 2022

so it fails only in the first ever run: there is no group.

@fosterseth fosterseth added good first issue component:awx_collection labels Mar 24, 2022
@ikke-t
Copy link
Contributor

@ikke-t ikke-t commented Mar 24, 2022

just for reference, here are the steps after creating the vm

        - name: Create tower inventory
          awx.awx.inventory:
            name: "Temporary Inventory"
            description: "Temporary inventory for hosts to be created"
            organization: "Default"
            state: present
            validate_certs: false
          when:
            - use_aap_inventory
            - vm is succeeded

        - name: Add tower host
          awx.awx.host:
            name: "{{ vm_name }}"
            inventory: "Temporary Inventory"
            state: present
            validate_certs: false
            variables:
              ansible_host: "{{ vm.instance.ipv4 }}"
          when:
            - use_aap_inventory
            - vm is succeeded

        - name: Add host to temporary group for new vms
          awx.awx.group:
            name: new_vms
            inventory: "Temporary Inventory"
            hosts:
              - "{{ vm_name }}"
            validate_certs: false
            preserve_existing_hosts: True
          when:
            - use_aap_inventory
            - vm is succeeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:awx_collection good first issue type:bug
4 participants