Skip to content
This repository has been archived by the owner on Oct 8, 2022. It is now read-only.

Fix Terraform version check #6

Merged
merged 1 commit into from Oct 11, 2016
Merged

Conversation

hectcastro
Copy link
Contributor

Ensure that this role installs the version of Terraform defined in terraform_version when it is not currently installed.

Also, update the default version of Terraform to 0.7.5.


Testing

First, compare the versions of Molecule and Ansible you have installed to these:

❯ molecule --version
molecule, version 1.12.4

❯ ansible --version
ansible 2.1.2.0
  config file = /Users/hcastro/Projects/ansible-terraform/ansible.cfg
  configured module search path = Default w/o overrides

Next, converge across both platforms:

❯ molecule converge --platform=all

Then, change the version of Terraform to be installed:

diff --git a/defaults/main.yml b/defaults/main.yml
index c4a2a98..db30e75 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -1,2 +1,2 @@
 ---
-terraform_version: "0.7.5"
+terraform_version: "0.7.4"

Lastly, converge again and login to ensure that the correct version of Terraform is installed:

❯ molecule converge --platform=all

❯ molecule login --host ansible-terraform-trusty64
Warning: Permanently added '[127.0.0.1]:2222' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-96-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Mon Oct 10 15:09:24 UTC 2016

  System load:  0.01              Processes:           86
  Usage of /:   3.9% of 39.34GB   Users logged in:     0
  Memory usage: 27%               IP address for eth0: 10.0.2.15
  Swap usage:   0%

  Graph this data and manage this system at:
    https://landscape.canonical.com/

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

New release '16.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


Last login: Mon Oct 10 15:10:05 2016 from 10.0.2.2
vagrant@ansible-terraform-trusty64:~$ terraform --version
Terraform v0.7.4

Your version of Terraform is out of date! The latest version
is 0.7.5. You can update by downloading from www.terraform.io

❯ molecule login --host ansible-terraform-xenial64
Warning: Permanently added '[127.0.0.1]:2200' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-34-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

71 packages can be updated.
32 updates are security updates.


Last login: Mon Oct 10 15:10:05 2016 from 10.0.2.2
ubuntu@ansible-terraform-xenial64:~$ terraform --version
Terraform v0.7.4

Your version of Terraform is out of date! The latest version
is 0.7.5. You can update by downloading from www.terraform.io

Ensure that this role installs the version of Terraform defined in
`terraform_version` when it is not currently installed.

Also, update the default version of Terraform to 0.7.5.
Copy link
Contributor

@tnation14 tnation14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with molecule 1.12.4, ansible 2.1.2.0, everything looks good 👍

Converge works the first time...

$ molecule converge
TASK [ansible-terraform : Check Terraform Version] *****************************
ok: [ansible-terraform-trusty64]
ok: [ansible-terraform-xenial64]

TASK [ansible-terraform : Download Terraform] **********************************
changed: [ansible-terraform-trusty64]
changed: [ansible-terraform-xenial64]

TASK [ansible-terraform : Extract and install Terraform] ***********************
changed: [ansible-terraform-xenial64]
>f++++++.?? terraform
changed: [ansible-terraform-trusty64]
>f++++++.?? terraform

PLAY RECAP *********************************************************************
ansible-terraform-trusty64 : ok=8    changed=3    unreachable=0    failed=0
ansible-terraform-xenial64 : ok=9    changed=3    unreachable=0    failed=0

$ molecule login

vagrant@ansible-terraform-trusty64:~$ terraform -v
Terraform v0.7.5

Update terraform version:

diff --git a/defaults/main.yml b/defaults/main.yml
index c4a2a98..b59e173 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -1,2 +1,2 @@
 ---
-terraform_version: "0.7.5"
+terraform_version: "0.7.3"

converge works a second time:

$ molecule converge --platform=all

TASK [ansible-terraform : Check Terraform Version] *****************************
ok: [ansible-terraform-trusty64]
ok: [ansible-terraform-xenial64]

TASK [ansible-terraform : Download Terraform] **********************************
changed: [ansible-terraform-xenial64]
changed: [ansible-terraform-trusty64]

TASK [ansible-terraform : Extract and install Terraform] ***********************
changed: [ansible-terraform-xenial64]
.fcstp...?? terraform
changed: [ansible-terraform-trusty64]
.fcstp...?? terraform

PLAY RECAP *********************************************************************
ansible-terraform-trusty64 : ok=8    changed=2    unreachable=0    failed=0
ansible-terraform-xenial64 : ok=9    changed=2    unreachable=0    failed=0

$ molecule login

vagrant@ansible-terraform-trusty64:~$ terraform -v
Terraform v0.7.3

Your version of Terraform is out of date! The latest version
is 0.7.5. You can update by downloading from www.terraform.io

@hectcastro hectcastro merged commit 2d2933f into develop Oct 11, 2016
@hectcastro hectcastro deleted the feature/hmc/version-check branch October 11, 2016 17:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants