summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ansible/roles/application-override/.yamllint12
-rw-r--r--ansible/roles/application-override/molecule/default/cleanup.yml6
-rw-r--r--ansible/roles/application-override/molecule/default/converge.yml7
-rw-r--r--ansible/roles/application-override/molecule/default/molecule.yml23
-rw-r--r--ansible/roles/application-override/molecule/default/prepare.yml5
-rw-r--r--ansible/roles/application-override/molecule/default/tests/test_default.py13
-rw-r--r--ansible/roles/application-override/molecule/ubuntu/molecule.yml28
-rw-r--r--ansible/roles/application-override/tasks/main.yml2
-rwxr-xr-xansible/test/bin/install-molecule.sh2
-rw-r--r--ansible/test/roles/cleanup-application-override/tasks/main.yml5
-rw-r--r--ansible/test/roles/prepare-application-override/tasks/main.yml13
11 files changed, 114 insertions, 2 deletions
diff --git a/ansible/roles/application-override/.yamllint b/ansible/roles/application-override/.yamllint
new file mode 100644
index 00000000..c5ae64be
--- /dev/null
+++ b/ansible/roles/application-override/.yamllint
@@ -0,0 +1,12 @@
+---
+extends: default
+
+rules:
+ braces:
+ max-spaces-inside: 1
+ level: error
+ brackets:
+ max-spaces-inside: 1
+ level: error
+ line-length: disable
+ truthy: disable
diff --git a/ansible/roles/application-override/molecule/default/cleanup.yml b/ansible/roles/application-override/molecule/default/cleanup.yml
new file mode 100644
index 00000000..6a0dbf4b
--- /dev/null
+++ b/ansible/roles/application-override/molecule/default/cleanup.yml
@@ -0,0 +1,6 @@
+---
+- name: Cleanup infra
+ hosts: all
+ ignore_unreachable: true
+ roles:
+ - cleanup-application-override
diff --git a/ansible/roles/application-override/molecule/default/converge.yml b/ansible/roles/application-override/molecule/default/converge.yml
new file mode 100644
index 00000000..9f5eb235
--- /dev/null
+++ b/ansible/roles/application-override/molecule/default/converge.yml
@@ -0,0 +1,7 @@
+---
+- name: Converge
+ hosts: all
+ tasks:
+ - name: "Include application-override"
+ include_role:
+ name: "application-override"
diff --git a/ansible/roles/application-override/molecule/default/molecule.yml b/ansible/roles/application-override/molecule/default/molecule.yml
new file mode 100644
index 00000000..d80e2f10
--- /dev/null
+++ b/ansible/roles/application-override/molecule/default/molecule.yml
@@ -0,0 +1,23 @@
+---
+dependency:
+ name: galaxy
+driver:
+ name: docker
+lint: |
+ set -e
+ yamllint .
+ ansible-lint .
+ flake8
+platforms:
+ - name: instance
+ image: centos:7
+provisioner:
+ name: ansible
+ env:
+ ANSIBLE_ROLES_PATH: ../../../../test/roles
+ inventory:
+ group_vars:
+ all:
+ app_helm_override_file: "/override.yml"
+verifier:
+ name: testinfra
diff --git a/ansible/roles/application-override/molecule/default/prepare.yml b/ansible/roles/application-override/molecule/default/prepare.yml
new file mode 100644
index 00000000..a2f608b0
--- /dev/null
+++ b/ansible/roles/application-override/molecule/default/prepare.yml
@@ -0,0 +1,5 @@
+---
+- name: Prepare infra
+ hosts: all
+ roles:
+ - prepare-application-override
diff --git a/ansible/roles/application-override/molecule/default/tests/test_default.py b/ansible/roles/application-override/molecule/default/tests/test_default.py
new file mode 100644
index 00000000..4b504bee
--- /dev/null
+++ b/ansible/roles/application-override/molecule/default/tests/test_default.py
@@ -0,0 +1,13 @@
+import yaml
+
+
+def test_override_file(host):
+ y = None
+ f = host.file("/override.yml")
+ assert f.exists
+ assert f.is_file
+ try:
+ y = yaml.safe_load(f.content)
+ except yaml.YAMLError:
+ assert False
+ assert y['global']['cacert'] == 'this is dummy server certificate value\n'
diff --git a/ansible/roles/application-override/molecule/ubuntu/molecule.yml b/ansible/roles/application-override/molecule/ubuntu/molecule.yml
new file mode 100644
index 00000000..9d97f716
--- /dev/null
+++ b/ansible/roles/application-override/molecule/ubuntu/molecule.yml
@@ -0,0 +1,28 @@
+---
+dependency:
+ name: galaxy
+driver:
+ name: docker
+lint: |
+ set -e
+ yamllint .
+ ansible-lint .
+ flake8
+platforms:
+ - name: instance
+ image: ubuntu:18.04
+provisioner:
+ name: ansible
+ env:
+ ANSIBLE_ROLES_PATH: ../../../../test/roles
+ inventory:
+ group_vars:
+ all:
+ app_helm_override_file: "/override.yml"
+ playbooks:
+ prepare: ../default/prepare.yml
+ converge: ../default/converge.yml
+ cleanup: ../default/cleanup.yml
+verifier:
+ name: testinfra
+ directory: ../default/tests/
diff --git a/ansible/roles/application-override/tasks/main.yml b/ansible/roles/application-override/tasks/main.yml
index 1ecf7c79..9bfeae81 100644
--- a/ansible/roles/application-override/tasks/main.yml
+++ b/ansible/roles/application-override/tasks/main.yml
@@ -10,7 +10,7 @@
set_fact:
merged_overrides: "{{ overrides | default({}) | combine({'global': {'cacert': root_cert.content | b64decode}}, recursive=True) }}"
-- name: "Create {{ app_helm_override_file }}"
+- name: "Create override file"
copy:
dest: "{{ app_helm_override_file }}"
content: "{{ merged_overrides | to_nice_yaml }}"
diff --git a/ansible/test/bin/install-molecule.sh b/ansible/test/bin/install-molecule.sh
index d18f70f7..f1c8aaa4 100755
--- a/ansible/test/bin/install-molecule.sh
+++ b/ansible/test/bin/install-molecule.sh
@@ -42,5 +42,5 @@ source ${VENV_PATH}/bin/activate
if [ ! -z ${VIRTUAL_ENV} ]; then
echo "Activated virtual env in ${VIRTUAL_ENV}"
pip -q install -U pip
- pip -q install molecule==3.3.0 Jinja2==2.11.3 ansible-base==2.10.8 ansible==3.2.0 docker molecule-docker==0.2.4 pytest-testinfra yamllint flake8 markupsafe==2.0.1
+ pip -q install ansible-lint==5.4.0 molecule==3.3.0 Jinja2==2.11.3 ansible-base==2.10.8 ansible==3.2.0 docker molecule-docker==0.2.4 pytest-testinfra yamllint flake8 markupsafe==2.0.1
fi
diff --git a/ansible/test/roles/cleanup-application-override/tasks/main.yml b/ansible/test/roles/cleanup-application-override/tasks/main.yml
new file mode 100644
index 00000000..084d7ae0
--- /dev/null
+++ b/ansible/test/roles/cleanup-application-override/tasks/main.yml
@@ -0,0 +1,5 @@
+- name: "Clean application-override mocked certificate directory"
+ file:
+ path: "{{ playbook_dir }}/certs"
+ state: absent
+ delegate_to: localhost
diff --git a/ansible/test/roles/prepare-application-override/tasks/main.yml b/ansible/test/roles/prepare-application-override/tasks/main.yml
new file mode 100644
index 00000000..e601c90a
--- /dev/null
+++ b/ansible/test/roles/prepare-application-override/tasks/main.yml
@@ -0,0 +1,13 @@
+- name: "Create certificate directory"
+ file:
+ path: "{{ playbook_dir }}/certs"
+ state: directory
+ delegate_to: localhost
+
+- name: "Create dummy cert file"
+ copy:
+ content: |
+ this is dummy server certificate value
+ dest: certs/rootCA.crt
+ delegate_to: localhost
+