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 collection: support for 'Terraform State' inventory source #15252

Closed
4 of 9 tasks
vvarga007 opened this issue Jun 4, 2024 · 4 comments · Fixed by #15258
Closed
4 of 9 tasks

awx.awx collection: support for 'Terraform State' inventory source #15252

vvarga007 opened this issue Jun 4, 2024 · 4 comments · Fixed by #15258
Labels
community component:awx_collection issues related to the collection for controlling AWX help wanted type:enhancement

Comments

@vvarga007
Copy link
Contributor

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.

Feature type

Enhancement to Existing Feature

Feature Summary

AWX 24.0.0 introduced a terraform state inventory source.
It would be great to create this inventory source with the 'awx.awx' ansible collection, which is currently not supported.
It is the same with the 'Terraform backend configuration' credential type.

Select the relevant components

  • UI
  • API
  • Docs
  • Collection
  • CLI
  • Other

Steps to reproduce

N/A

Current results

N/A

Sugested feature result

N/A

Additional information

No response

@github-actions github-actions bot added component:awx_collection issues related to the collection for controlling AWX needs_triage type:enhancement community labels Jun 4, 2024
@thedoubl3j
Copy link
Member

Reasonable request, my guess is it would take some work in https://github.com/ansible/awx/blob/devel/awx_collection/plugins/modules/inventory_source.py. If someone has time, feel free to take a crack, might be a bit before we can get to it though @vvarga007 but very doable/in scope I think.

@vvarga007
Copy link
Contributor Author

vvarga007 commented Jun 6, 2024

@thedoubl3j I took a quick look at this. To create a terraform state inventory source, the only thing that we have to do is to add 'terraform' as a valid choice.( https://github.com/ansible/awx/blob/devel/awx_collection/plugins/modules/inventory_source.py)
I changed it to this:

source=dict(choices=["scm", "ec2", "gce", "azure_rm", "vmware", "satellite6", "openstack", "rhv", "controller", "insights", "terraform"]),

After this change, I was able to create an inventory source with the following task:

- name: Add an inventory source 'TF_source'
  awx.awx.inventory_source:
    inventory: Inventory_TEST_TF_SOURCE
    name: TF_source
    source: terraform
    source_vars:
      backend_type: s3
    credential: TF_TEST
    organization: Default
    state: present

@vvarga007
Copy link
Contributor Author

I checked the TF backend credential, too. It seems that works out of the box.
This combo works like a charm after that minor change in my previous comment.

- name: Add TF backend configuration
  awx.awx.credential:
    name: TF_TEST
    credential_type: Terraform backend configuration
    organization: Default
    inputs:
      configuration: |
        bucket = "example-tfstates"
        key = "aws-test-instance/tf_state.tfstate"
        region = "us-east-1"
        access_key = "CHANGEME"
        secret_key = "CHANGEME"

- name: Add an inventory source 'TF_source'
  awx.awx.inventory_source:
    inventory: Inventory_TEST_TF_SOURCE
    name: TF_soruce
    source: terraform
    source_vars:
      backend_type: s3
    credential: TF_TEST
    organization: Default
    overwrite: true
    overwrite_vars: true
    update_on_launch: true
    verbosity: 1
    state: present

@vvarga007
Copy link
Contributor Author

@thedoubl3j I created a PR for this. Please take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community component:awx_collection issues related to the collection for controlling AWX help wanted type:enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants