-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add role to configure terraform CLI - Update playbook.yml with the respective role - Update provisioners.md documentation
- Loading branch information
1 parent
108daa5
commit c1cc9dd
Showing
6 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
tf_version: '1.2.4' | ||
tf_install_dir: '/usr/local/bin' | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
- name: 'Check for existing terraform version' | ||
shell: '{{ tf_install_dir }}/terraform version -json' | ||
args: | ||
executable: '/bin/bash' | ||
changed_when: false | ||
failed_when: false | ||
register: 'tf_existing_version' | ||
|
||
- name: 'Define existing terraform version' | ||
set_fact: | ||
tf_installed_version: '{{ tf_existing_version.stdout | from_json }}' | ||
|
||
- name: 'Verify installed terraform version' | ||
assert: | ||
that: | ||
- 'tf_installed_version.terraform_version == tf_version' | ||
fail_msg: 'terraform installation failed, {{ tf_version }} != {{ tf_installed_version.terraform_version }}' | ||
success_msg: 'Installed terraform version is: {{ tf_version }}' | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
--- | ||
- name: 'Check if is already installed' | ||
stat: | ||
path: '{{ tf_install_dir }}/terraform' | ||
register: 'tf_path' | ||
|
||
- name: 'Check for existing version' | ||
shell: '{{ tf_install_dir }}/terraform version -json' | ||
args: | ||
executable: '/bin/bash' | ||
changed_when: false | ||
failed_when: false | ||
register: 'tf_existing_version' | ||
when: 'tf_path.stat.exists' | ||
|
||
- name: 'Define existing version' | ||
set_fact: | ||
tf_current_version: '{{ tf_existing_version.stdout | from_json }}' | ||
when: 'tf_path.stat.exists' | ||
|
||
- name: 'Retrieve zip checksums' | ||
set_fact: | ||
tf_zip_checksums: '{{ lookup("url", tf_checksums_url) }}' | ||
when: > | ||
not tf_path.stat.exists | ||
or tf_current_version.terraform_version != tf_version | ||
- name: 'Convert zip checksums to dictionary' | ||
set_fact: | ||
tf_zip_checksum_dict: '{{ tf_zip_checksums | content_to_dict(",") }}' | ||
when: > | ||
not tf_path.stat.exists | ||
or tf_current_version.terraform_version != tf_version | ||
- name: 'Set zip checksum' | ||
set_fact: | ||
tf_zip_checksum: '{{ tf_zip_checksum_dict | get_dict_key(tf_zip_name) }}' | ||
when: > | ||
not tf_path.stat.exists | ||
or tf_current_version.terraform_version != tf_version | ||
- name: 'Download zip' | ||
get_url: | ||
url: '{{ tf_zip_url }}' | ||
dest: '/tmp/{{ tf_zip_name }}' | ||
checksum: 'sha256:{{ tf_zip_checksum }}' | ||
when: > | ||
not tf_path.stat.exists | ||
or tf_current_version.terraform_version != tf_version | ||
- name: 'Ensure install directory exists' | ||
file: | ||
path: '{{ tf_install_dir }}' | ||
state: 'directory' | ||
mode: 0755 | ||
owner: 'root' | ||
group: 'root' | ||
become: 'yes' | ||
when: > | ||
not tf_path.stat.exists | ||
or tf_current_version.terraform_version != tf_version | ||
- name: 'Extract {{ tf_zip_name }}' | ||
unarchive: | ||
src: '/tmp/{{ tf_zip_name }}' | ||
dest: '{{ tf_install_dir }}' | ||
remote_src: 'yes' | ||
mode: 0755 | ||
owner: root | ||
group: root | ||
become: 'yes' | ||
notify: | ||
- 'Check for existing terraform version' | ||
- 'Define existing terraform version' | ||
- 'Verify installed terraform version' | ||
when: > | ||
not tf_path.stat.exists | ||
or tf_current_version.terraform_version != tf_version | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
tf_arch: 'amd64' | ||
tf_os: '{{ ansible_system | lower }}' | ||
tf_binary_name: 'tf_{{ tf_os }}_{{ tf_arch }}' | ||
tf_download_url: 'https://releases.hashicorp.com/terraform' | ||
tf_zip_name: 'terraform_{{ tf_version }}_{{ tf_os }}_{{ tf_arch }}.zip' | ||
tf_zip_url: '{{ tf_download_url }}/{{ tf_version }}/{{ tf_zip_name }}' | ||
tf_checksums_url: '{{ tf_download_url }}/{{ tf_version }}/terraform_{{ tf_version }}_SHA256SUMS' | ||
... |