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

Inventory Source for Openstack does not have a region field #5080

Closed
vCra opened this issue Oct 23, 2019 · 12 comments
Closed

Inventory Source for Openstack does not have a region field #5080

vCra opened this issue Oct 23, 2019 · 12 comments

Comments

@vCra
Copy link

vCra commented Oct 23, 2019

ISSUE TYPE
  • Bug Report
SUMMARY

When creating an Openstack Credential, no field is provided to specify the region of the cluster. This results in Openstack using the default cluster. Additionally, specifying a region_name in the source variables section of the inventory source page does not work.

ENVIRONMENT
  • AWX version: 8.0.0.0 (but tried with 7.0.0.0 too)
  • AWX install method: docker-compose using playbook
  • Ansible version: 2.8.2
  • Operating System: Ubuntu 18.10 w/ 4.18.0-25-generic
  • Web Browser: Chrome 77
STEPS TO REPRODUCE

Part 1:
Go to Credentials. Hit Green Plus. Select OpenStack as Credential Type

Part 2:
Go to Existing Inventory. Select Sources tab. Hit Green Plus. Fill in name, select Openstack as Source. In source Variables, include the following (I wanted to try everything):

clouds:
  devstack:
    region_name: ABC
    region: ABC
    auth:
      region_name: ABC
      region: ABC
region_name: ABC
region: ABC
EXPECTED RESULTS

Part 1:
A Region field should be present.

Part 2:
The YML be added to the generated YML, and for data to be collected from the correct region, rather than the default

ACTUAL RESULTS

Part 1:
No region field is present

Part 2:
The Generated YML appears not to include the region_name key, but it does include any vars included under the ansible: key.

ADDITIONAL INFORMATION

The example at https://github.com/ansible/ansible/blob/devel/contrib/inventory/openstack.yml does not include a region for Openstack, but the code at https://github.com/ansible/ansible/blob/devel/contrib/inventory/openstack_inventory.py does make references to a region variable.

@vCra
Copy link
Author

vCra commented Oct 28, 2019

I might just be using the wrong variable - I've also just tried source_regions as referenced in awx/ui/client/src/inventories-hosts/inventories/related/sources/add/sources-add.controller.js, but again no luck. I noticed that openstack isn't referenced, but GCE, AWS, Azure etc are, so this might be an easy fix.

@vguillard
Copy link

vguillard commented Sep 8, 2020

I've got the same issue whith AWX 13.0.0 and my OVH Public Cloud

@ryanpetrello
Copy link
Contributor

@chrismeyersfsu @elyezer seems like this should be cleared up by your recent changes?

#5150
#7763

@chrismeyersfsu
Copy link
Member

Looks like the Ansible OpenStack inventory plugin configuration doesn't support region as a parameter https://docs.ansible.com/ansible/latest/plugins/inventory/openstack.html Thus, our transition to inventory plugins will not solve your problem. All hosts in all regions will be returned. However, I think you can still accomplish the end goal of filtering or grouping by region using inventory plugins constructed feature. https://docs.ansible.com/ansible/latest/plugins/inventory/constructed.html

groups:
  east: infra.openstack.location.region_name == "east"
  west: infra.openstack.location.region_name == "west"

Your inventory will still contain all hosts in all regions but you can use the limit feature on job templates to reference particular regions.

@vCra
Copy link
Author

vCra commented Sep 8, 2020

It's been a while since I last looked at this, but IIRC it did only use the default region at the time. We're no longer using OpenStack, so it's not too practical for me to test. But if all regions are returned, and regions are groupable, that seems like a good compromise. @vguillard are all vm's in all regions getting returned for you, or just for the default region?

@vguillard
Copy link

vguillard commented Sep 9, 2020

Inspired by https://github.com/openstack/ansible-collections-openstack/blob/master/scripts/inventory/openstack.yml, here is my necessary file:

clouds:
  devstack:
    auth:
      auth_url: <OS_AUTH_URL>
      username: <OS_USERNAME>
      password: <OS_PASSWORD>
      project_name: <OS_TENANT_NAME>
      project_domain_name: <OS_USER_DOMAIN_NAME>
      user_domain_name: <OS_USER_DOMAIN_NAME>
    private: true
    verify: true
    region_name: GRA3

region_name is not written by AWX.

I've hardcoded 'region_name' in awx/main/models/credential/injectors.py (in devel branch):

openstack_data = {
        'clouds': {
            'devstack': {
                'auth': openstack_auth,
                'verify': verify_state,
                'region_name': "GRA3",
            },
        },
    }

It works, my instances are listed by AWX.

@vCra, I've got instances only in one region (GRA3),
There is other region but I can't login.
I can only list instances in one region.
I don't know what is the default region, sorry

Checked manually by this way:

ANSIBLE_INVENTORY_ENABLED=auto \
OS_CLIENT_CONFIG_FILE=config_file \
ansible-inventory -i openstack.yml --list
  • It works when 'region_name' attribute is present in config_file
  • It doesn't work when 'region_name' attribute is omitted in config_file

@vguillard
Copy link

Hello all,

I did some changes in code and it works :

In the UI:
image

File generated:

clouds:
  devstack:
    auth:
      auth_url: http://localhost
      domain_name: domain_name
      password: password
      project_domain_name: project_domain_name
      project_name: tenant_name
      username: utilisateur
    private: true
    region_name: myregion
    verify: true

But I don't know how to submit my changes :'(
And I don't know if I should submit my changes.

@ryanpetrello : What do you thing ? Can you help me ?

@vguillard
Copy link

PR: #8880

@ryanpetrello
Copy link
Contributor

ryanpetrello commented Jan 8, 2021

cc @unlikelyzero I put this in needs_test so we can track it

@kdelee
Copy link
Member

kdelee commented Jan 26, 2021

api tests were added with the PR that are more than sufficient to test the api changes related to this PR. Going to call this good from the API perspective.

@unlikelyzero
Copy link

@akus062381 can you just check to see if the field appears in the UI? Not tests needed

@akus062381
Copy link
Member

The region field appears in the details screen for the credential. Verified manually.

AlanCoding pushed a commit to AlanCoding/awx that referenced this issue Jun 23, 2021
…it_reaper

Add a periodic task to reap unreleased receptor work units
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants