Selaa lähdekoodia

terraform installation

master
vanhempi
commit
6778c769b1
3 muutettua tiedostoa jossa 55 lisäystä ja 0 poistoa
  1. +1
    -0
      defaults/main.yaml
  2. +44
    -0
      tasks/main.yaml
  3. +10
    -0
      vars/main.yaml

+ 1
- 0
defaults/main.yaml Näytä tiedosto

@@ -1 +1,2 @@
---
terraform_version: 0.12.24 # "{{ terraform_latest_version }}"

+ 44
- 0
tasks/main.yaml Näytä tiedosto

@@ -1 +1,45 @@
---

- name: required debian packages
apt:
pkg:
# ansible
- unzip

- name: get latest terraform release version
uri:
url: https://checkpoint-api.hashicorp.com/v1/check/terraform
register: terraform_release_query

- name: check if terraform version matches
command: terraform --version
failed_when: False
changed_when: False
register: terraform_version_command

- name: get terraform release checksums
uri:
url: "https://releases.hashicorp.com/terraform/{{ terraform_version }}/terraform_{{ terraform_version }}_SHA256SUMS"
return_content: yes
register: terraform_release_checksums_uri

- debug:
msg:
terraform_current_version: "{{ terraform_current_version }}"
ansible_architecture: "{{ ansible_architecture }}"
terraform_download_checksum: "{{ terraform_download_checksum }}"
terraform_download_filename: "{{ terraform_download_filename }}"
terraform_download_checksum: "{{ terraform_download_checksum }}"

- name: download terraform release
get_url:
url: "{{ terraform_download_url }}"
dest: "{{ terraform_download_dest }}"
checksum: "{{ terraform_download_checksum }}"
register: terraform_download

- name: extract and install Terraform
unarchive:
src: "{{terraform_download_dest}}"
dest: /usr/local/bin
copy: no

+ 10
- 0
vars/main.yaml Näytä tiedosto

@@ -1 +1,11 @@
---
terraform_latest_version: "{{terraform_release.json.current_version}}"
terraform_current_version: "{{ terraform_version_command }}"
terraform_ansible_architecture_map:
x86_64: amd64
terraform_architecture: "{{ terraform_ansible_architecture_map[ansible_architecture] }}"
terraform_download_checksum_line: "{{ terraform_release_checksums_uri.content.split('\n')|select('match', '^[0-9a-fA-F]+ +(terraform_'+terraform_version+'_linux_'+terraform_architecture+'.zip)') | first }}"
terraform_download_filename: "{{ terraform_download_checksum_line | regex_replace('^[0-9a-fA-F]+ +(terraform_'+terraform_version+'_linux_'+terraform_architecture+'.zip)','\\1') }}"
terraform_download_checksum: "sha256:{{ terraform_download_checksum_line | regex_replace('^([0-9a-fA-F]+) +terraform_'+terraform_version+'_linux_'+terraform_architecture+'.zip','\\1') }}"
terraform_download_url: "https://releases.hashicorp.com/terraform/{{ terraform_version }}/{{terraform_download_filename}}"
terraform_download_dest: "/usr/local/src/{{terraform_download_filename}}"

Loading…
Peruuta
Tallenna