Skip to content

Commit

Permalink
Update CI config and fix linting errors
Browse files Browse the repository at this point in the history
- Update CI workflow files to match target file structure and versioning
- Update collection to reflect current supported Ansible and Python
  versions
- Fix linting and formatting errors
  • Loading branch information
hakbailey committed Nov 9, 2023
1 parent 8c52bf2 commit 50c5cde
Show file tree
Hide file tree
Showing 28 changed files with 331 additions and 296 deletions.
5 changes: 5 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
profile: production

exclude_paths:
- tests/integration
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
name: CI
---
name: Changelog

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
pull_request:
types:
Expand All @@ -10,9 +16,7 @@ on:
branches:
- main
- stable-*
tags:
- '*'

jobs:
changelog:
uses: ansible-network/github_actions/.github/workflows/changelog.yml@main
uses: ansible-network/github_actions/.github/workflows/changelog.yml@main
51 changes: 0 additions & 51 deletions .github/workflows/ci.yml

This file was deleted.

15 changes: 15 additions & 0 deletions .github/workflows/galaxy-import.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Galaxy import

concurrency:
group: ${{ github.head_ref }}
cancel-in-progress: true

on:
pull_request:
branches:
- main
- stable-*

jobs:
galaxy-import:
uses: ansible-network/github_actions/.github/workflows/galaxy_importer.yml@main
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: CI
name: Integration tests

on:
pull_request_target:
types:
Expand All @@ -10,37 +11,22 @@ on:
branches:
- main
- stable-*

jobs:
safe-to-test:
if: ${{ github.event.label.name == 'safe to test' }} || ${{ github.event.action != 'labeled' }}
uses: ansible-network/github_actions/.github/workflows/safe-to-test.yml@main
integration:

integration-tests:
needs:
- safe-to-test
runs-on: ubuntu-latest
name: Integration (Ⓐ${{ matrix.ansible }}+py${{ matrix.python }}+tf${{ matrix.terraform }})
env:
source: "./source"
aws_dir: "./amazon_aws"
strategy:
fail-fast: false
matrix:
ansible:
- stable-2.13
- stable-2.14
python:
- '3.8'
- '3.9'
- '3.10'
terraform:
- "1.3.4"
exclude:
# ansi2.14 requires py>=3.9
- ansible: stable-2.14
python: '3.8'
steps:
- name: Checkout collection
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: ${{ env.source }}
ref: ${{ github.event.pull_request.head.sha }}
Expand All @@ -56,20 +42,20 @@ jobs:
uses: ansible-network/github_actions/.github/actions/checkout_dependency@main
with:
repository: ansible-collections/amazon.aws
path: ${{ env.amazon_aws }}
path: ${{ env.aws_dir }}
ref: main

- name: install amazon.aws collection
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
with:
install_python_dependencies: true
source_path: ${{ env.amazon_aws }}
source_path: ${{ env.aws_dir }}

- name: Download terraform binary
run: >-
curl
-o terraform.zip
https://releases.hashicorp.com/terraform/${{ matrix.terraform }}/terraform_${{ matrix.terraform }}_linux_amd64.zip
https://releases.hashicorp.com/terraform/1.6.3/terraform_1.6.3_linux_amd64.zip
shell: bash

- name: Install terraform binary
Expand Down Expand Up @@ -98,5 +84,5 @@ jobs:
uses: ansible-network/github_actions/.github/actions/ansible_test_integration@main
with:
collection_path: ${{ steps.install-collection.outputs.collection_path }}
python_version: ${{ matrix.python }}
ansible_version: ${{ matrix.ansible }}
python_version: "3.12"
ansible_version: stable-2.16
22 changes: 22 additions & 0 deletions .github/workflows/linters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Linters

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
pull_request:
branches:
- main
- stable-*

jobs:
ansible-lint:
runs-on: ubuntu-latest
steps:
- name: Run ansible-lint
uses: ansible/[email protected]

tox-linters:
uses: ansible-network/github_actions/.github/workflows/tox-linters.yml@main
16 changes: 16 additions & 0 deletions .github/workflows/sanity-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: Sanity tests

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
pull_request:
branches:
- main
- stable-*

jobs:
sanity-tests:
uses: ansible-network/github_actions/.github/workflows/sanity.yml@main
14 changes: 14 additions & 0 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Unit tests
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
pull_request:
branches:
- main
- stable-*

jobs:
unit-tests:
uses: ansible-network/github_actions/.github/workflows/unit_source.yml@main
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Terraform Collection for Ansible Automation Platform

The `cloud.terraform` automates the management and provisioning of infrastructure as code using Terraform CLI tool within Ansible playbooks and Execution Environment runtimes.
The `cloud.terraform` automates the management and provisioning of infrastructure as code using Terraform CLI tool within Ansible playbooks and Execution Environment runtimes.

It is intended to support similar automation capabilities consistent with other cloud provisioning tool integrations for Ansible such as AWS Cloudformation, Azure Resource Manager and Helm with the added challenge of effectively managing a state file.

Expand All @@ -22,7 +22,7 @@ This collection is not intended to manage the installation, configuration and op

## Ansible version compatibility

This collection requires Ansible Core 2.13 or later and thus Python 3.8 or later.
This collection requires Ansible Core 2.14 or later and thus Python 3.9 or later.

## Included content
<!--start collection content-->
Expand Down Expand Up @@ -132,5 +132,3 @@ ansible-doc --list | grep cloud.terraform | cut -d " " -f 1 | xargs -I {} antsib
GNU General Public License v3.0 or later.

See [LICENSE](https://github.com/ansible-collections/cloud.terraform/blob/main/LICENSE) to see the full text.


120 changes: 60 additions & 60 deletions changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,70 @@ releases:
1.1.0:
changes:
bugfixes:
- Integration tests to test support of AWS, Azure and GCP.
- Major refactoring of the cloud.terraform collection, restructuring and compartmentalizing
code.
- Removed "mutually exclusive" condition for state_file and project_path in
inventory_from_outputs role, since terraform_output module doesn't require
this. (https://github.com/ansible-collections/cloud.terraform/pull/39)
- Several integration tests were added to test end-to-end behaviour.
- Terraform module - fix now allows the possibility that the key "value" is
not always present in the terraform plan thus avoiding KeyError. (https://github.com/ansible-collections/cloud.terraform/pull/45)
- Terraform module - fix now expands the providers schema with block_types section
so when checking if (block) attribute is sensitive in providers schema KeyError
is now avoided. (https://github.com/ansible-collections/cloud.terraform/pull/46)
- Terraform_output - fix now sets "outputs" variable to None in case of TerraformWarning
to avoid undefined variable error. (https://github.com/ansible-collections/cloud.terraform/pull/31)
- Type hints added to the cloud.terraform collection for easier future maintenance
and reliability.
- Updated host and group name in cloud.terraform.terraform_provider inventory
plugin. (https://github.com/ansible-collections/cloud.terraform/pull/34)
- terraform_output module - when providing name and state_file parameters, the
value of the requested output wasn't returned. This issue was solved by changing
the order of the name and state parameters in the invoked Terraform command
(https://github.com/ansible-collections/cloud.terraform/pull/19).
- Integration tests to test support of AWS, Azure and GCP.
- Major refactoring of the cloud.terraform collection, restructuring and compartmentalizing
code.
- Removed "mutually exclusive" condition for state_file and project_path in
inventory_from_outputs role, since terraform_output module doesn't require
this. (https://github.com/ansible-collections/cloud.terraform/pull/39)
- Several integration tests were added to test end-to-end behaviour.
- Terraform module - fix now allows the possibility that the key "value" is
not always present in the terraform plan thus avoiding KeyError. (https://github.com/ansible-collections/cloud.terraform/pull/45)
- Terraform module - fix now expands the providers schema with block_types section
so when checking if (block) attribute is sensitive in providers schema KeyError
is now avoided. (https://github.com/ansible-collections/cloud.terraform/pull/46)
- Terraform_output - fix now sets "outputs" variable to None in case of TerraformWarning
to avoid undefined variable error. (https://github.com/ansible-collections/cloud.terraform/pull/31)
- Type hints added to the cloud.terraform collection for easier future maintenance
and reliability.
- Updated host and group name in cloud.terraform.terraform_provider inventory
plugin. (https://github.com/ansible-collections/cloud.terraform/pull/34)
- terraform_output module - when providing name and state_file parameters, the
value of the requested output wasn't returned. This issue was solved by changing
the order of the name and state parameters in the invoked Terraform command
(https://github.com/ansible-collections/cloud.terraform/pull/19).
deprecated_features:
- state=planned is deprecated. Use check_mode=true at the module level instead.
- state=planned is deprecated. Use check_mode=true at the module level instead.
major_changes:
- Added the git_plan role to apply a Terraform plan stored in a Git repository.
- Added the inventory_from_outputs role to construct an in-memory inventory
from Terraform outputs.
- Added the terraform_output module which parses values from terraform outputs.
- Check mode now works as intended and produces correct "changed" output and
results.
- Inventory plugin cloud.terraform.terraform_provider added. (https://github.com/ansible-collections/cloud.terraform/pull/22)
- Support diff mode in cloud.terraform.terraform both in check mode and in non-check
mode. (https://github.com/ansible-collections/cloud.terraform/pull/11)
- Terraform output lookup module added (https://github.com/ansible-collections/cloud.terraform/pull/12).
- Added the git_plan role to apply a Terraform plan stored in a Git repository.
- Added the inventory_from_outputs role to construct an in-memory inventory
from Terraform outputs.
- Added the terraform_output module which parses values from terraform outputs.
- Check mode now works as intended and produces correct "changed" output and
results.
- Inventory plugin cloud.terraform.terraform_provider added. (https://github.com/ansible-collections/cloud.terraform/pull/22)
- Support diff mode in cloud.terraform.terraform both in check mode and in non-check
mode. (https://github.com/ansible-collections/cloud.terraform/pull/11)
- Terraform output lookup module added (https://github.com/ansible-collections/cloud.terraform/pull/12).
minor_changes:
- Removed "required_one_of" condition from terraform_output module. (https://github.com/ansible-collections/cloud.terraform/pull/31).
- Slight code reorganization to always run terraform plan, and then optionally
apply the generated plan.
- Terraform output lookup module - documentation for state_file option updated.
(https://github.com/ansible-collections/cloud.terraform/pull/29).
- git_plan and inventory_from_outputs role's argument_spec.yml updated to be
able to generate documentation (https://github.com/ansible-collections/cloud.terraform/pull/28)
- meta/runtime.yml - Drop space in requires_ansible that was preventing the
upload on Galaxy (https://github.com/ansible-collections/cloud.terraform/pull/8).
- Removed "required_one_of" condition from terraform_output module. (https://github.com/ansible-collections/cloud.terraform/pull/31).
- Slight code reorganization to always run terraform plan, and then optionally
apply the generated plan.
- Terraform output lookup module - documentation for state_file option updated.
(https://github.com/ansible-collections/cloud.terraform/pull/29).
- git_plan and inventory_from_outputs role's argument_spec.yml updated to be
able to generate documentation (https://github.com/ansible-collections/cloud.terraform/pull/28)
- meta/runtime.yml - Drop space in requires_ansible that was preventing the
upload on Galaxy (https://github.com/ansible-collections/cloud.terraform/pull/8).
fragments:
- 0001-initial.yml
- 10-zuul-integration-tests.yml
- add_diff_mode_for_state_file.yaml
- change_name_and_state_order_in_terraform_command.yaml
- drop_sapce_in_requires_ansible.yaml
- inventory_from_outputs_bugfix.yaml
- refactoring.yaml
- terraform_module_sensitive_values_bugfix.yaml
- terraform_module_show_values_bugfix.yaml
- terraform_output_module.yaml
- terraform_provider_inventory_plugin.yaml
- terraform_provider_update_host_and_group_name.yaml
- tf_output_lookup_module.yaml
- tf_output_lookup_module_documentation_update.yaml
- update_documentation.yaml
- 0001-initial.yml
- 10-zuul-integration-tests.yml
- add_diff_mode_for_state_file.yaml
- change_name_and_state_order_in_terraform_command.yaml
- drop_sapce_in_requires_ansible.yaml
- inventory_from_outputs_bugfix.yaml
- refactoring.yaml
- terraform_module_sensitive_values_bugfix.yaml
- terraform_module_show_values_bugfix.yaml
- terraform_output_module.yaml
- terraform_provider_inventory_plugin.yaml
- terraform_provider_update_host_and_group_name.yaml
- tf_output_lookup_module.yaml
- tf_output_lookup_module_documentation_update.yaml
- update_documentation.yaml
plugins:
inventory:
- description: Builds an inventory from Terraform state file.
name: terraform_provider
namespace: null
- description: Builds an inventory from Terraform state file.
name: terraform_provider
namespace: null
release_date: '2023-03-23'
Loading

0 comments on commit 50c5cde

Please sign in to comment.