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

modules/terraform: Add workspace support #43489

Merged
merged 3 commits into from Aug 2, 2018
Merged

modules/terraform: Add workspace support #43489

merged 3 commits into from Aug 2, 2018

Conversation

rrey
Copy link
Contributor

@rrey rrey commented Jul 31, 2018

SUMMARY

From terraform documentation:

The persistent data stored in the backend belongs to a workspace. Initially the backend has only one workspace, called "default", and thus there is only one Terraform state associated with that configuration.

Certain backends support multiple named workspaces, allowing multiple states to be associated with a single configuration. The configuration still has only one backend, but multiple distinct instances of that configuration to be deployed without configuring a new backend or changing authentication credentials.

This patch introduces the workspace parameter in the terraform module. The module will create
the workspace is it does not exists, or simply select it if it exists.

Fixes #43134

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

terraform

ANSIBLE VERSION
ansible 2.6.0
  config file = None
  configured module search path = [u'/Users/remirey/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/remirey/.virtualenvs/avignon/lib/python2.7/site-packages/ansible
  executable location = /Users/remirey/.virtualenvs/avignon/bin/ansible
  python version = 2.7.13 (default, Jul 18 2017, 09:17:00) [GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)]

rrey added 2 commits July 31, 2018 10:17
From terraform documentation:
```
The persistent data stored in the backend belongs to a workspace. Initially the backend has only one workspace, called "default", and thus there is only one Terraform state associated with that configuration.

Certain backends support multiple named workspaces, allowing multiple states to be associated with a single configuration. The configuration still has only one backend, but multiple distinct instances of that configuration to be deployed without configuring a new backend or changing authentication credentials.
```

This patch introduces the `workspace` parameter in the terraform module. The module will select
the workspace is it does not exists, or simply select it if it exists.

Fixes #43134
…kspace context

The `purge_workspace` parameter allows to remove a workspace when asking for state = absent.
It allows to leave a clean state file without empty workspaces if the parameter is true.

Also adding the support of a workspace context that allows to restore the workspace
when that was active when the module started.
@rrey
Copy link
Contributor Author

rrey commented Jul 31, 2018

cc @ryansb

@ansibot ansibot added affects_2.7 This issue/PR affects Ansible v2.7 cloud community_review In order to be merged, this PR must follow the community review workflow. feature This issue/PR relates to a feature request. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. labels Jul 31, 2018
@ansibot
Copy link
Contributor

ansibot commented Jul 31, 2018

The test ansible-test sanity --test pep8 [explain] failed with 7 errors:

lib/ansible/modules/cloud/misc/terraform.py:183:1: E302 expected 2 blank lines, found 1
lib/ansible/modules/cloud/misc/terraform.py:199:1: E302 expected 2 blank lines, found 1
lib/ansible/modules/cloud/misc/terraform.py:199:51: E241 multiple spaces after ','
lib/ansible/modules/cloud/misc/terraform.py:206:1: E302 expected 2 blank lines, found 1
lib/ansible/modules/cloud/misc/terraform.py:209:1: E302 expected 2 blank lines, found 1
lib/ansible/modules/cloud/misc/terraform.py:212:1: E302 expected 2 blank lines, found 1
lib/ansible/modules/cloud/misc/terraform.py:215:1: E302 expected 2 blank lines, found 1

click here for bot help

@ansibot ansibot added ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed community_review In order to be merged, this PR must follow the community review workflow. labels Jul 31, 2018
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Jul 31, 2018
@webknjaz webknjaz requested a review from ryansb July 31, 2018 14:55
@webknjaz webknjaz removed the needs_triage Needs a first human triage before being processed. label Jul 31, 2018
@ansibot ansibot added community_review In order to be merged, this PR must follow the community review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jul 31, 2018
@rrey
Copy link
Contributor Author

rrey commented Aug 2, 2018

@ryansb shall we merge ?

@ryansb ryansb merged commit 0461620 into ansible:devel Aug 2, 2018
@ryansb
Copy link
Contributor

ryansb commented Aug 2, 2018

@rrey thank you for contributing this feature!

@rrey rrey deleted the add-terraform-workspace branch August 2, 2018 16:53
@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.7 This issue/PR affects Ansible v2.7 cloud community_review In order to be merged, this PR must follow the community review workflow. feature This issue/PR relates to a feature request. module This issue/PR relates to a module. support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support of workspaces in terraform module
4 participants