Skip to content

Commit 0599f83

Browse files
authored
Merge pull request #7 from stackhpc/test
Add tests
2 parents fd0b10b + b8abcba commit 0599f83

File tree

9 files changed

+108
-1
lines changed

9 files changed

+108
-1
lines changed

.ansible-lint

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
skip_list:
3+
- '701' # meta/main.yml should contain relevant info

.github/workflows/pull_request.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
2+
name: Tests
3+
4+
# Controls when the action will run.
5+
on:
6+
pull_request:
7+
push:
8+
branches:
9+
- master
10+
11+
jobs:
12+
lint:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
ansible:
18+
- "2.9"
19+
- "2.10"
20+
- "2.12"
21+
steps:
22+
# Checks-out the repository under $GITHUB_WORKSPACE, so it's accessible to the job
23+
- uses: actions/checkout@v2
24+
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
if [[ "${{ matrix.ansible }}" = "2.9" ]]; then
29+
ansible_package=ansible
30+
elif [[ "${{ matrix.ansible }}" = "2.10" ]]; then
31+
ansible_package=ansible-base
32+
else
33+
ansible_package=ansible-core
34+
fi
35+
pip install $ansible_package==${{ matrix.ansible }}.* 'ansible-lint<5'
36+
37+
- name: Linting code
38+
run: |
39+
ansible-lint -v --force-color
40+
41+
integration:
42+
runs-on: ubuntu-latest
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
ansible:
47+
- "2.9"
48+
- "2.10"
49+
- "2.12"
50+
steps:
51+
# Checks-out the repository under $GITHUB_WORKSPACE, so it's accessible to the job
52+
- uses: actions/checkout@v2
53+
54+
- uses: actions/setup-python@v2
55+
56+
- name: Install dependencies
57+
run: |
58+
python3 -m pip install --upgrade pip
59+
if [[ "${{ matrix.ansible }}" = "2.9" ]]; then
60+
ansible_package=ansible
61+
elif [[ "${{ matrix.ansible }}" = "2.10" ]]; then
62+
ansible_package=ansible-base
63+
else
64+
ansible_package=ansible-core
65+
fi
66+
python3 -m pip install $ansible_package==${{ matrix.ansible }}.* docker
67+
ansible-galaxy collection build
68+
ansible-galaxy collection install *.tar.gz
69+
70+
# TODO: Use ansible-test to run these.
71+
- name: Running integration tests
72+
run: |
73+
ansible-playbook -i tests/inventory -v tests/*.yml -e ansible_python_interpreter=$(which python3)

galaxy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ version: "1.0.0"
44
readme: "README.md"
55
authors:
66
- "Michał Nasiadka"
7+
dependencies:
8+
"community.docker": "*"
79
license:
810
- "Apache-2.0"
911
tags:

roles/vault/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ Example playbook (used with OpenStack Kayobe)
4242
tasks:
4343
- name: Ensure /opt/kayobe/vault exists
4444
file:
45-
state: present
4645
path: /opt/kayobe/vault
4746
state: directory
4847

roles/vault/defaults/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ vault_config: >
2626
"listener": [{
2727
"tcp": {
2828
"address": "{{ vault_bind_address }}:8200",
29+
{% if vault_tls_key and vault_tls_cert %}
2930
"tls_min_version": "tls12",
3031
"tls_key_file": "/vault/config/tls.key",
3132
"tls_cert_file": "/vault/config/tls.cert"
33+
{% else %}
34+
"tls_disable": "true"
35+
{% endif %}
3236
}
3337
}],
3438
"storage": {

roles/vault/meta/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
collections:
3+
- community.docker

tests/inventory

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[consul]
2+
localhost ansible_connection=local

tests/roles

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../roles

tests/test_vault.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
- name: Prepare for vault role
3+
gather_facts: True
4+
hosts: consul
5+
tasks:
6+
- name: Ensure /etc/vault exists
7+
file:
8+
path: /etc/vault
9+
state: directory
10+
become: true
11+
12+
- include_role:
13+
name: vault
14+
vars:
15+
consul_bind_interface: lo
16+
consul_bind_ip: 127.0.0.1
17+
consul_vip_address: 127.0.0.1
18+
vault_bind_address: 127.0.0.1
19+
vault_api_addr: http://127.0.0.1:8200
20+
vault_config_dir: "/etc/vault"

0 commit comments

Comments
 (0)