Skip to content
This repository was archived by the owner on Oct 5, 2024. It is now read-only.

Commit e0d9d58

Browse files
authored
Merge pull request #1 from Provizanta/add-capability-to-install-plugins
Extend deployment with plugin installation
2 parents b70530d + ce70642 commit e0d9d58

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ These variables are defined in [defaults/main.yml](./defaults/main.yml):
2121

2222
terraform_binary_dir_path: "/usr/local/bin"
2323

24+
terraform_plugin_urls: []
25+
2426
Dependencies
2527
------------
2628

defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ terraform_architecture: 'amd64' # enum, one of 386|amd64|arm
55
terraform_version: '0.12.24'
66

77
terraform_binary_dir_path: "/usr/local/bin"
8+
9+
terraform_plugin_urls: []

molecule/default/playbook.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
vars:
1010
terraform_version: "{{ version }}"
1111
terraform_binary_dir_path: /usr/bin
12+
terraform_plugin_urls:
13+
- https://github.com/dmacvicar/terraform-provider-libvirt/releases/download/v0.6.11/terraform-provider-libvirt_0.6.11_linux_amd64.zip
1214

1315
post_tasks:
1416
- name: terraform should be installed

tasks/main.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,35 @@
1717

1818
# from https://terraform.io/downloads.html
1919
- name: establish (download) binary
20-
when: v['stdout'] is not defined or terraform_version not in v.stdout
20+
when: >-
21+
v['stdout'] is not defined or
22+
terraform_version not in v.stdout
2123
become: true
2224
unarchive:
2325
src: https://releases.hashicorp.com/terraform/{{ terraform_version }}/terraform_{{ terraform_version }}_{{ ansible_system | lower }}_{{ terraform_architecture }}.zip # noqa 204
2426
dest: "{{ terraform_binary_dir_path }}"
2527
remote_src: true
2628
creates: "{{ terraform_binary_dir_path }}/terraform"
2729
tags: install
30+
31+
- name: establish plugins
32+
when: terraform_plugin_urls | length > 0
33+
tags: install
34+
block:
35+
- name: establish plugins directory
36+
loop:
37+
- .terraform.d/
38+
- .terraform.d/plugins/
39+
file:
40+
path: "{{ ansible_env.HOME }}/{{ item }}"
41+
state: directory
42+
owner: "{{ ansible_env.USER | default(ansible_user_id) }}"
43+
group: "{{ ansible_env.USER | default(ansible_user_id) }}"
44+
mode: "u=rwx,go=rx"
45+
46+
- name: establish plugins
47+
loop: "{{ terraform_plugin_urls }}"
48+
unarchive:
49+
src: "{{ item }}"
50+
dest: "{{ ansible_env.HOME }}/.terraform.d/plugins/"
51+
remote_src: true

0 commit comments

Comments
 (0)