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

Commit 572a32e

Browse files
authored
Merge pull request #3 from Provizanta/add-package-installation
Add support for package installation
2 parents e5a2b05 + a4f4d3b commit 572a32e

File tree

14 files changed

+208
-39
lines changed

14 files changed

+208
-39
lines changed

.github/workflows/main.yml

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,67 @@ on:
1111
- master
1212

1313
jobs:
14-
test:
14+
test_default:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
distro:
20+
- ubuntu2004
21+
- ubuntu1804
22+
# - centos7
23+
# - centos8
24+
- debian10
25+
- debian11
26+
- fedora35
27+
# - amazonlinux2
28+
steps:
29+
- name: checkout the repository
30+
uses: actions/checkout@v2
31+
with:
32+
path: "${{ github.repository }}"
33+
34+
- name: run molecule (default scenario)
35+
uses: robertdebock/[email protected]
36+
with:
37+
command: "test"
38+
env:
39+
MOLECULE_DISTRO: ${{ matrix.distro }}
40+
41+
test_versioned:
42+
needs:
43+
- test_default
1544
runs-on: ubuntu-latest
1645
strategy:
1746
fail-fast: false
1847
matrix:
1948
distro:
2049
- ubuntu2004
2150
- ubuntu1804
22-
- ubuntu1604
2351
- centos7
2452
- centos8
25-
- debian9
2653
- debian10
27-
- fedora29
54+
- debian11
55+
- fedora35
56+
- amazonlinux2
2857
steps:
2958
- name: checkout the repository
3059
uses: actions/checkout@v2
3160
with:
3261
path: "${{ github.repository }}"
3362

34-
- name: run molecule
35-
uses: robertdebock/[email protected]
63+
- name: run molecule (versioned scenario)
64+
uses: robertdebock/[email protected]
65+
with:
66+
scenario: versioned
67+
command: "test"
3668
env:
3769
MOLECULE_DISTRO: ${{ matrix.distro }}
3870

3971
deploy:
4072
needs:
41-
- test
73+
- test_default
74+
- test_versioned
4275
runs-on: ubuntu-latest
4376
steps:
4477
- name: to Ansible Galaxy

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ Role Variables
1515

1616
These variables are defined in [defaults/main.yml](./defaults/main.yml):
1717

18-
terraform_architecture: 'amd64' # enum, one of 386|amd64|arm
18+
terraform_plugin_urls: []
1919

20-
terraform_version: '0.12.24'
20+
Additionally, it is possible to define an explicit version to be downloaded and installed:
2121

22-
terraform_binary_dir_path: "/usr/local/bin"
22+
terraform_version: '0.12.24'
2323

24-
terraform_plugin_urls: []
2524

2625
Dependencies
2726
------------
@@ -31,6 +30,16 @@ None
3130
Example Playbook
3231
----------------
3332

33+
To get a default package:
34+
35+
- name: Converge
36+
hosts: all
37+
roles:
38+
- role: terraform
39+
40+
41+
To get an explicit version:
42+
3443
- name: Converge
3544
hosts: all
3645
vars:

defaults/main.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
---
22

3-
terraform_architecture: 'amd64' # enum, one of 386|amd64|arm
4-
5-
terraform_version: '0.12.24'
6-
7-
terraform_binary_dir_path: "/usr/local/bin"
8-
93
terraform_plugin_urls: []

meta/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ galaxy_info:
2424
- all
2525
- name: EL
2626
versions:
27-
- 7
27+
- all
2828

2929
galaxy_tags:
3030
- terraform

molecule/default/converge.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,8 @@
22

33
- name: Converge
44
hosts: all
5-
vars:
6-
version: '0.12.24'
75
roles:
86
- role: ansible-role-terraform
97
vars:
10-
terraform_version: "{{ version }}"
11-
terraform_binary_dir_path: /usr/bin
128
terraform_plugin_urls:
139
- https://github.com/dmacvicar/terraform-provider-libvirt/releases/download/v0.6.11/terraform-provider-libvirt_0.6.11_linux_amd64.zip
14-
15-
post_tasks:
16-
- name: terraform should be installed
17-
block:
18-
- name: check terraform version
19-
command: '/usr/bin/terraform --version'
20-
changed_when: false
21-
register: r
22-
- name: evaluate file presence
23-
assert:
24-
that: version in r.stdout
25-
fail_msg: "terraform should be installed with a correct version"

molecule/default/verify.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
3+
- name: Verify
4+
hosts: all
5+
tasks:
6+
- name: terraform should be installed
7+
block:
8+
- name: check terraform version
9+
command: '/usr/bin/terraform --version'
10+
changed_when: false

molecule/versioned/converge.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
3+
- name: Converge
4+
hosts: all
5+
vars:
6+
version: '0.12.24'
7+
roles:
8+
- role: ansible-role-terraform
9+
vars:
10+
terraform_version: "{{ version }}"
11+
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

molecule/versioned/molecule.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
3+
dependency:
4+
name: galaxy
5+
driver:
6+
name: docker
7+
lint: |
8+
set -e
9+
yamllint -c .yamllint .
10+
ansible-lint
11+
platforms:
12+
- name: instance
13+
image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest"
14+
command: ${MOLECULE_DOCKER_COMMAND:-""}
15+
volumes:
16+
- /sys/fs/cgroup:/sys/fs/cgroup:ro
17+
privileged: true
18+
pre_build_image: true
19+
provisioner:
20+
name: ansible
21+
verifier:
22+
name: ansible

molecule/versioned/prepare.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
- name: Converge
3+
hosts: all
4+
tasks:
5+
- name: update apt repository
6+
when: "ansible_pkg_mgr == 'apt'"
7+
apt:
8+
update_cache: true

molecule/versioned/verify.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
3+
- name: Verify
4+
hosts: all
5+
vars:
6+
version: '0.12.24'
7+
tasks:
8+
- name: terraform should be installed
9+
block:
10+
- name: check terraform version
11+
command: 'terraform --version'
12+
changed_when: false
13+
register: r
14+
failed_when: not version in r.stdout

0 commit comments

Comments
 (0)