cloud.terraform icon indicating copy to clipboard operation
cloud.terraform copied to clipboard

Inventory/terraform_state - Support remote/cloud backends

Open abikouo opened this issue 1 year ago • 1 comments

SUMMARY

Closes #150

  • Support remote/cloud backends
  • Move all dict/list from backend_config parameter into dedicated file to be passed as backend_config_files terraform init supports -backend-config for key/value pair with value as string only, therefore when user specified some dict item (e.g. the workspace configuration for remote/cloud backend), we need to move that into file to be passed as backend-config=temp_file.
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

Inventory/terraform_state

abikouo avatar Aug 01 '24 10:08 abikouo

Build succeeded. https://ansible.softwarefactory-project.io/zuul/buildset/34ddad76ccf14c3c858667bc97cfefff

:heavy_check_mark: ansible-galaxy-importer SUCCESS in 4m 06s :heavy_check_mark: build-ansible-collection SUCCESS in 5m 58s

Any reason why this hasn't been merged? We are looking to validate integration support. Thanks

srlynch1 avatar Jun 10 '25 22:06 srlynch1

Codecov Report

Attention: Patch coverage is 99.23077% with 1 line in your changes missing coverage. Please review.

Project coverage is 81.02%. Comparing base (8c52bf2) to head (bcd0abc). Report is 36 commits behind head on main.

Files with missing lines Patch % Lines
plugins/inventory/terraform_state.py 96.15% 0 Missing and 1 partial :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #163      +/-   ##
==========================================
+ Coverage   73.00%   81.02%   +8.01%     
==========================================
  Files          16       23       +7     
  Lines        1015     1602     +587     
  Branches      182      308     +126     
==========================================
+ Hits          741     1298     +557     
- Misses        243      262      +19     
- Partials       31       42      +11     
Flag Coverage Δ
sanity ?
units 81.02% <99.23%> (+8.41%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Jun 23 '25 08:06 codecov[bot]

Build succeeded. https://ansible.softwarefactory-project.io/zuul/buildset/3701e3132259431d805cd5cd37d2f385

:heavy_check_mark: ansible-galaxy-importer SUCCESS in 3m 26s :heavy_check_mark: build-ansible-collection SUCCESS in 5m 51s

I am able to test out the functionality for TFC backend support as per https://issues.redhat.com/browse/AAP-47515 Steps to test: 1- terraform_state.yml: plugin: cloud.terraform.terraform_state name: Using the cloud block backend_type: cloud backend_config: hostname: "{{ hostname }}" organization: "{{ org_name }}" workspaces: name: "{{ workspace_name }}" 2- playbook.yml

  • name: Use Terraform state as dynamic inventory hosts: all gather_facts: false

    tasks:

    • name: Show host debug: msg: "{{ inventory_hostname }}"

    • name: Show attributes debug: var: hostvars[inventory_hostname]

image image image

kaushiki069 avatar Jun 23 '25 08:06 kaushiki069

Build succeeded. https://ansible.softwarefactory-project.io/zuul/buildset/3f3328e3694d432e90d0c43abdc90c7d

:heavy_check_mark: ansible-galaxy-importer SUCCESS in 3m 18s :heavy_check_mark: build-ansible-collection SUCCESS in 6m 10s

Build succeeded. https://ansible.softwarefactory-project.io/zuul/buildset/97900e2559e9473fb22af247bffa30a5

:heavy_check_mark: ansible-galaxy-importer SUCCESS in 3m 23s :heavy_check_mark: build-ansible-collection SUCCESS in 6m 30s

Build succeeded. https://ansible.softwarefactory-project.io/zuul/buildset/a277f49a4610451995a737e50ebd24f0

:heavy_check_mark: ansible-galaxy-importer SUCCESS in 4m 10s :heavy_check_mark: build-ansible-collection SUCCESS in 5m 55s

Build succeeded. https://ansible.softwarefactory-project.io/zuul/buildset/1a9d44b710d24488a2aae8ab94e5cc04

:heavy_check_mark: ansible-galaxy-importer SUCCESS in 3m 19s :heavy_check_mark: build-ansible-collection SUCCESS in 5m 56s

Backport to stable-4: 💔 cherry-picking failed — conflicts found

❌ Failed to cleanly apply 58eb522fbd1ac8cd42d6c3819c0abbfe548514b9 on top of patchback/backports/stable-4/58eb522fbd1ac8cd42d6c3819c0abbfe548514b9/pr-163

Backporting merged PR #163 into main

  1. Ensure you have a local repo clone of your fork. Unless you cloned it from the upstream, this would be your origin remote.
  2. Make sure you have an upstream repo added as a remote too. In these instructions you'll refer to it by the name upstream. If you don't have it, here's how you can add it:
    $ git remote add upstream https://github.com/ansible-collections/cloud.terraform.git
    
  3. Ensure you have the latest copy of upstream and prepare a branch that will hold the backported code:
    $ git fetch upstream
    $ git checkout -b patchback/backports/stable-4/58eb522fbd1ac8cd42d6c3819c0abbfe548514b9/pr-163 upstream/stable-4
    
  4. Now, cherry-pick PR #163 contents into that branch:
    $ git cherry-pick -x 58eb522fbd1ac8cd42d6c3819c0abbfe548514b9
    
    If it'll yell at you with something like fatal: Commit 58eb522fbd1ac8cd42d6c3819c0abbfe548514b9 is a merge but no -m option was given., add -m 1 as follows instead:
    $ git cherry-pick -m1 -x 58eb522fbd1ac8cd42d6c3819c0abbfe548514b9
    
  5. At this point, you'll probably encounter some merge conflicts. You must resolve them in to preserve the patch from PR #163 as close to the original as possible.
  6. Push this branch to your fork on GitHub:
    $ git push origin patchback/backports/stable-4/58eb522fbd1ac8cd42d6c3819c0abbfe548514b9/pr-163
    
  7. Create a PR, ensure that the CI is green. If it's not — update it so that the tests and any other checks pass. This is it! Now relax and wait for the maintainers to process your pull request when they have some cycles to do reviews. Don't worry — they'll tell you if any improvements are necessary when the time comes!

🤖 @patchback I'm built with octomachinery and my source is open — https://github.com/sanitizers/patchback-github-app.

patchback[bot] avatar Jul 10 '25 13:07 patchback[bot]