diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..1cd2768 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,28 @@ +version: 2 + +jobs: + build: + environment: + TEST_DIR: terraform-role/tests + + machine: + image: ubuntu-1604:201903-01 + + steps: + - checkout + - run: cp -r tests ~/tests + - run: mkdir ~/tests/roles + - run: sudo ln -s $(pwd) ~/tests/roles/migibert.terraform + - run: sudo pip install ansible + - run: + command: ansible-playbook --syntax-check -i inventory example.yml + working_directory: ~/tests + - run: + command: ansible-playbook --list-tasks -i inventory example.yml + working_directory: ~/tests + - run: + command: sudo ansible-playbook --connection=local -i inventory example.yml + working_directory: ~/tests + - run: + command: "sudo ansible-playbook --connection=local -i inventory example.yml | grep -q 'changed=0.*failed=0'" + working_directory: ~/tests diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 0e559a5..0000000 --- a/circle.yml +++ /dev/null @@ -1,19 +0,0 @@ -general: - build_dir: tests - -dependencies: - post: - - sudo pip install ansible - -machine: - environment: - PLAYBOOK: example.yml - -test: - pre: - - sudo ln -s terraform-role ../../migibert.terraform - override: - - ansible-playbook --syntax-check -i inventory $PLAYBOOK - - ansible-playbook --list-tasks -i inventory $PLAYBOOK - - sudo ansible-playbook --connection=local -i inventory $PLAYBOOK - - sudo ansible-playbook --connection=local -i inventory $PLAYBOOK | grep -q 'changed=0.*failed=0' diff --git a/defaults/main.yml b/defaults/main.yml index 10baab3..f579f4a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,6 +1,6 @@ --- # defaults file for terraform-role -terraform_version: 0.6.11 +terraform_version: 0.12.7 terraform_dir: /opt/terraform terraform_user: terraform terraform_user_password: $6$uoCgixKJL4cFyIT$U7FisaA6GAdosBpGde.4NS00vaAg4tGmR63eBQQMsd8LiHUjetq6HDXG10719JwbNmQUSLzvG6zq8DOVOggIw1 diff --git a/meta/main.yml b/meta/main.yml index 4ef39b4..4974642 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -3,14 +3,23 @@ galaxy_info: author: Mikael Gibert description: Terraform installation license: MIT - min_ansible_version: 1.2 + min_ansible_version: 2.0 platforms: - - name: Ubuntu - versions: - - all - - name: Debian - versions: - - all + - name: EL + versions: + - all + - name: Fedora + versions: + - all + - name: Debian + versions: + - all + - name: Ubuntu + versions: + - all + - name: GenericUNIX + versions: + - all categories: - cloud -dependencies: [] \ No newline at end of file +dependencies: [] diff --git a/tasks/main.yml b/tasks/main.yml index c033e65..0e830a6 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -13,7 +13,7 @@ register: terraform_directory - name: Check terraform version - shell: "terraform --version 2>&1 | head -n 1 | grep {{terraform_version}}" + shell: "terraform version 2>&1 | head -n 1 | grep -q {{terraform_version}}" failed_when: false changed_when: false register: terraform_versions_match @@ -22,7 +22,7 @@ when: terraform_versions_match.rc != 0 - name: Install unzip to unarchive terraform - apt: + package: name: unzip state: present @@ -31,7 +31,7 @@ src: /tmp/terraform-{{terraform_version}}.zip dest: "{{terraform_dir}}" copy: no - when: terraform_versions_match.rc != 0 or terraform_directory | changed + when: terraform_versions_match.rc != 0 or terraform_directory is changed - name: Make terraform_user terraform directory owner file: diff --git a/tests/ansible.cfg b/tests/ansible.cfg deleted file mode 100644 index e9315a8..0000000 --- a/tests/ansible.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[defaults] -roles_path=../../ -hostfile=inventory -hosts=localhost -hash_behaviour=merge \ No newline at end of file diff --git a/tests/example.yml b/tests/example.yml index ff6979a..da5cfa1 100644 --- a/tests/example.yml +++ b/tests/example.yml @@ -1,7 +1,7 @@ - hosts: localhost vars: - terraform_version: 0.6.11 + terraform_version: 0.12.7 terraform_dir: /opt roles: