-
Notifications
You must be signed in to change notification settings - Fork 35
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 terraform_state - add support for backend_config_files and update backend_config #112
Inventory terraform_state - add support for backend_config_files and update backend_config #112
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## stable-statefile-inventory #112 +/- ##
=============================================================
Coverage ? 79.44%
=============================================================
Files ? 23
Lines ? 1430
Branches ? 249
=============================================================
Hits ? 1136
Misses ? 252
Partials ? 42
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Build succeeded. ✔️ ansible-galaxy-importer SUCCESS in 4m 33s |
202ba31
to
d3d9887
Compare
Build succeeded. ✔️ ansible-galaxy-importer SUCCESS in 3m 56s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple small comments but this looks good and works as expected!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested changes to backend_config
works as expected.
plugin: cloud.terraform.terraform_state
backend_type: s3
backend_config:
region: us-west-1
key: terraform/my.tfstate
bucket: mandkulk-tf-test
ansible-inventory -i terraform_state.yaml --graph --vars
returns
@all:
|--@ungrouped:
| |--aws_instance_example_server
| | |--{ami = ami-0353faff0d421c70e}
| | |--{arn = arn:aws:ec2:us-west-1:721012345678:instance/i-0bd1ca4a412345678}
| | |--{associate_public_ip_address = False}
| | |--{availability_zone = us-west-1a}
| | |--{capacity_reservation_specification = [{'capacity_reservation_preference': 'open', 'capacity_reservation_target': []}]}
| | |--{cpu_core_count = 1}
| | |--{cpu_options = [{'amd_sev_snp': '', 'core_count': 1, 'threads_per_core': 1}]}
| | |--{cpu_threads_per_core = 1}
...
...
Build succeeded. ✔️ ansible-galaxy-importer SUCCESS in 4m 17s |
Build succeeded. ✔️ ansible-galaxy-importer SUCCESS in 4m 33s |
5c5fb11
into
ansible-collections:stable-statefile-inventory
…update backend_config (#112) * add support for backend_config_files
…update backend_config (#112) * add support for backend_config_files
* terraform_state - New Inventory plugin (#107) * initial commit for terraform state inventory * code before unit and integration tests * adding extended unit tests * add integration tests * fix ansible-lint errors * fix CI issues * add changelog fragment * fix ansible-lint * fix another ansible-lint issue * code review * fix unit tests * fix ansible-lint indentation * Setting option backend_config as required * Inventory terraform_state - add support for backend_config_files and update backend_config (#112) * add support for backend_config_files * Support AzureRM and GCP instances types into Terraform state inventory (#110) --------- Co-authored-by: Bikouo Aubin <[email protected]>
…ections#116) * terraform_state - New Inventory plugin (ansible-collections#107) * initial commit for terraform state inventory * code before unit and integration tests * adding extended unit tests * add integration tests * fix ansible-lint errors * fix CI issues * add changelog fragment * fix ansible-lint * fix another ansible-lint issue * code review * fix unit tests * fix ansible-lint indentation * Setting option backend_config as required * Inventory terraform_state - add support for backend_config_files and update backend_config (ansible-collections#112) * add support for backend_config_files * Support AzureRM and GCP instances types into Terraform state inventory (ansible-collections#110) --------- Co-authored-by: Bikouo Aubin <[email protected]> (cherry picked from commit ad19e5b)
…ections#116) * terraform_state - New Inventory plugin (ansible-collections#107) * initial commit for terraform state inventory * code before unit and integration tests * adding extended unit tests * add integration tests * fix ansible-lint errors * fix CI issues * add changelog fragment * fix ansible-lint * fix another ansible-lint issue * code review * fix unit tests * fix ansible-lint indentation * Setting option backend_config as required * Inventory terraform_state - add support for backend_config_files and update backend_config (ansible-collections#112) * add support for backend_config_files * Support AzureRM and GCP instances types into Terraform state inventory (ansible-collections#110) --------- Co-authored-by: Bikouo Aubin <[email protected]> (cherry picked from commit ad19e5b)
[Manual backport stable-2] Patchback/backports/stable 2/ad19e5b33b15d566e2979aa471c71902bb9b588d/pr 116 terraform_state - New Inventory plugin (#107) initial commit for terraform state inventory code before unit and integration tests adding extended unit tests add integration tests fix ansible-lint errors fix CI issues add changelog fragment fix ansible-lint fix another ansible-lint issue code review fix unit tests fix ansible-lint indentation Setting option backend_config as required Inventory terraform_state - add support for backend_config_files and update backend_config (#112) add support for backend_config_files Support AzureRM and GCP instances types into Terraform state inventory (#110) Co-authored-by: Bikouo Aubin [email protected] (cherry picked from commit ad19e5b) SUMMARY ISSUE TYPE Bugfix Pull Request Docs Pull Request Feature Pull Request New Module Pull Request COMPONENT NAME ADDITIONAL INFORMATION Reviewed-by: Mike Graves <[email protected]>
This pull requests add support for the parameter
backend_config_files
to provide Terraform configuration into files, this could be useful when the backend configuration contains some secrets.To be aligned with the
terraform init
command, the backend configuration files should contain only key/values pair defining the configuration, here is an example of a s3 backend configurationHowever, as we are trying to read an existing Terraform state file from the provided backend, we need to generate a simple Terraform with the backend definition, this requires a new parameter
backend_type
The generated configuration will look like
We will also update the current
backend_config
parameter, which takes the full backend configuration by accepting only a dictionnary of key/values pairs to push as configuration to the backend when runningterraform init --backend-config
command.Here is an example of an inventory file with the new modifications
inventory_state.yaml
With
aws_secrets.hcl