summaryrefslogtreecommitdiffstats
path: root/ansible/roles
diff options
context:
space:
mode:
Diffstat (limited to 'ansible/roles')
-rw-r--r--ansible/roles/chrony/molecule/external_time_source/molecule.yml49
-rw-r--r--ansible/roles/chrony/molecule/external_time_source/playbook.yml10
-rw-r--r--ansible/roles/chrony/molecule/external_time_source_ubuntu/molecule.yml50
-rw-r--r--ansible/roles/dns/molecule/default/cleanup.yml6
l---------ansible/roles/helm/molecule/default/group_vars/infrastructure.yml1
-rw-r--r--ansible/roles/helm/molecule/default/prepare.yml5
-rw-r--r--ansible/roles/helm/tasks/main.yml8
-rw-r--r--ansible/roles/nexus/molecule/default/cleanup.yml8
-rw-r--r--ansible/roles/rke/defaults/main.yml2
-rw-r--r--ansible/roles/rke/molecule/default/molecule.yml4
-rw-r--r--ansible/roles/rke/molecule/default/playbook.yml6
-rw-r--r--ansible/roles/rke/molecule/default/tests/test_etcd.py (renamed from ansible/roles/rke/molecule/default/tests/test_kubernetes.py)4
-rw-r--r--ansible/roles/rke/molecule/default/tests/test_nodes.py13
-rw-r--r--ansible/roles/rke/templates/cluster.yml.j28
-rw-r--r--ansible/roles/vncserver/.yamllint11
-rw-r--r--ansible/roles/vncserver/molecule/default/cleanup.yml6
-rw-r--r--ansible/roles/vncserver/molecule/default/molecule.yml32
-rw-r--r--ansible/roles/vncserver/molecule/default/playbook.yml5
-rw-r--r--ansible/roles/vncserver/molecule/default/prepare.yml8
-rw-r--r--ansible/roles/vncserver/molecule/default/tests/test_default.py10
20 files changed, 232 insertions, 14 deletions
diff --git a/ansible/roles/chrony/molecule/external_time_source/molecule.yml b/ansible/roles/chrony/molecule/external_time_source/molecule.yml
new file mode 100644
index 00000000..e38f4295
--- /dev/null
+++ b/ansible/roles/chrony/molecule/external_time_source/molecule.yml
@@ -0,0 +1,49 @@
+---
+dependency:
+ name: galaxy
+driver:
+ name: docker
+lint:
+ name: yamllint
+platforms:
+ - name: infra_host
+ image: molecule-${PREBUILD_PLATFORM_DISTRO:-centos}:${PREBUILD_DISTRO_VERSION:-centos7.6}
+ pre_build_image: True
+ privileged: true
+ volume_mounts:
+ - "/sys/fs/cgroup:/sys/fs/cgroup:ro"
+ override_command: False
+ groups:
+ - infrastructure
+ - name: node0
+ image: molecule-${PREBUILD_PLATFORM_DISTRO:-centos}:${PREBUILD_DISTRO_VERSION:-centos7.6}
+ pre_build_image: True
+ privileged: true
+ volume_mounts:
+ - "/sys/fs/cgroup:/sys/fs/cgroup:ro"
+ override_command: False
+ groups:
+ - kubernetes
+provisioner:
+ name: ansible
+ lint:
+ name: ansible-lint
+ env:
+ ANSIBLE_ROLES_PATH: ../../../../test/roles
+ inventory:
+ group_vars:
+ all:
+ timesync:
+ servers:
+ - 0.pool.ntp.org
+ - 1.pool.ntp.org
+ timezone: Europe/Warsaw
+ playbooks:
+ prepare: ../default/prepare.yml
+verifier:
+ name: testinfra
+ lint:
+ name: flake8
+ options:
+ v: 1
+ directory: ../default/tests/
diff --git a/ansible/roles/chrony/molecule/external_time_source/playbook.yml b/ansible/roles/chrony/molecule/external_time_source/playbook.yml
new file mode 100644
index 00000000..7dccfc35
--- /dev/null
+++ b/ansible/roles/chrony/molecule/external_time_source/playbook.yml
@@ -0,0 +1,10 @@
+---
+- name: Converge infrastructure hosts
+ hosts: infrastructure
+ roles:
+ - chrony
+
+- name: Converge kubernetes hosts
+ hosts: kubernetes
+ roles:
+ - chrony
diff --git a/ansible/roles/chrony/molecule/external_time_source_ubuntu/molecule.yml b/ansible/roles/chrony/molecule/external_time_source_ubuntu/molecule.yml
new file mode 100644
index 00000000..6cc2854a
--- /dev/null
+++ b/ansible/roles/chrony/molecule/external_time_source_ubuntu/molecule.yml
@@ -0,0 +1,50 @@
+---
+dependency:
+ name: galaxy
+driver:
+ name: docker
+lint:
+ name: yamllint
+platforms:
+ - name: infra_host-ubuntu
+ image: molecule-${PREBUILD_PLATFORM_DISTRO:-ubuntu}:${PREBUILD_DISTRO_VERSION:-18.04}
+ pre_build_image: True
+ privileged: true
+ volume_mounts:
+ - "/sys/fs/cgroup:/sys/fs/cgroup:ro"
+ override_command: False
+ groups:
+ - infrastructure
+ - name: node0-ubuntu
+ image: molecule-${PREBUILD_PLATFORM_DISTRO:-ubuntu}:${PREBUILD_DISTRO_VERSION:-18.04}
+ pre_build_image: True
+ privileged: true
+ volume_mounts:
+ - "/sys/fs/cgroup:/sys/fs/cgroup:ro"
+ override_command: False
+ groups:
+ - kubernetes
+provisioner:
+ name: ansible
+ lint:
+ name: ansible-lint
+ env:
+ ANSIBLE_ROLES_PATH: ../../../../test/roles
+ inventory:
+ group_vars:
+ all:
+ timesync:
+ servers:
+ - 0.pool.ntp.org
+ - 1.pool.ntp.org
+ timezone: Europe/Warsaw
+ playbooks:
+ prepare: ../default/prepare.yml
+ converge: ../external_time_source/playbook.yml
+verifier:
+ name: testinfra
+ lint:
+ name: flake8
+ options:
+ v: 1
+ directory: ../default/tests/
diff --git a/ansible/roles/dns/molecule/default/cleanup.yml b/ansible/roles/dns/molecule/default/cleanup.yml
new file mode 100644
index 00000000..60195bb3
--- /dev/null
+++ b/ansible/roles/dns/molecule/default/cleanup.yml
@@ -0,0 +1,6 @@
+---
+- name: Cleanup
+ hosts: all
+ ignore_unreachable: true
+ roles:
+ - cleanup-dns
diff --git a/ansible/roles/helm/molecule/default/group_vars/infrastructure.yml b/ansible/roles/helm/molecule/default/group_vars/infrastructure.yml
new file mode 120000
index 00000000..3e9c2f0c
--- /dev/null
+++ b/ansible/roles/helm/molecule/default/group_vars/infrastructure.yml
@@ -0,0 +1 @@
+../../../../../group_vars/infrastructure.yml \ No newline at end of file
diff --git a/ansible/roles/helm/molecule/default/prepare.yml b/ansible/roles/helm/molecule/default/prepare.yml
index 8a149b89..34c41e8e 100644
--- a/ansible/roles/helm/molecule/default/prepare.yml
+++ b/ansible/roles/helm/molecule/default/prepare.yml
@@ -1,5 +1,8 @@
---
- name: Prepare for helm tests
- hosts: all
+ hosts: infrastructure
+ pre_tasks:
+ - name: Include infrastructure group variables
+ include_vars: ../../../../group_vars/infrastructure.yml
roles:
- prepare-helm
diff --git a/ansible/roles/helm/tasks/main.yml b/ansible/roles/helm/tasks/main.yml
index 2521ad28..c1b47103 100644
--- a/ansible/roles/helm/tasks/main.yml
+++ b/ansible/roles/helm/tasks/main.yml
@@ -1,7 +1,11 @@
---
- name: Install Helm
- copy:
- src: "{{ app_data_path }}/downloads/helm"
+ unarchive:
+ src: "{{ app_data_path }}/downloads/helm-{{ helm_version }}-linux-amd64.tar.gz"
dest: "{{ helm_bin_dir }}"
+ extra_opts:
+ - --strip=1
+ - --wildcards
+ - '*/helm'
remote_src: true
mode: 0755
diff --git a/ansible/roles/nexus/molecule/default/cleanup.yml b/ansible/roles/nexus/molecule/default/cleanup.yml
new file mode 100644
index 00000000..1517e53e
--- /dev/null
+++ b/ansible/roles/nexus/molecule/default/cleanup.yml
@@ -0,0 +1,8 @@
+---
+- name: Cleanup
+ hosts: all
+ ignore_unreachable: true
+ vars_files:
+ - ../../defaults/main.yml
+ roles:
+ - cleanup-nexus
diff --git a/ansible/roles/rke/defaults/main.yml b/ansible/roles/rke/defaults/main.yml
index 88216857..2f160fc2 100644
--- a/ansible/roles/rke/defaults/main.yml
+++ b/ansible/roles/rke/defaults/main.yml
@@ -1,5 +1,5 @@
---
-rke_binary: rke
+rke_binary: rke_linux-amd64
rke_username: rke
rke_bin_dir: /usr/local/bin
kube_config_dir: "{{ ansible_env.HOME }}/.kube"
diff --git a/ansible/roles/rke/molecule/default/molecule.yml b/ansible/roles/rke/molecule/default/molecule.yml
index e8e5ad76..6ae613a9 100644
--- a/ansible/roles/rke/molecule/default/molecule.yml
+++ b/ansible/roles/rke/molecule/default/molecule.yml
@@ -19,7 +19,9 @@ platforms:
container: docker
groups:
- infrastructure
+ - kubernetes-etcd
- kubernetes-control-plane
+ - kubernetes
networks:
- name: rke
purge_networks: true
@@ -37,6 +39,7 @@ platforms:
- /var/lib/docker
groups:
- kubernetes
+ - kubernetes-node
networks:
- name: rke
purge_networks: true
@@ -54,6 +57,7 @@ platforms:
- /var/lib/docker
groups:
- kubernetes
+ - kubernetes-node
networks:
- name: rke
purge_networks: true
diff --git a/ansible/roles/rke/molecule/default/playbook.yml b/ansible/roles/rke/molecule/default/playbook.yml
index 09dbfb8e..fab7a0d0 100644
--- a/ansible/roles/rke/molecule/default/playbook.yml
+++ b/ansible/roles/rke/molecule/default/playbook.yml
@@ -13,10 +13,8 @@
vars:
mode: config
-- name: Prepare kubernetes nodes (RKE)
- hosts:
- - kubernetes
- - kubernetes-control-plane
+- name: Prepare kubernetes hosts (RKE)
+ hosts: kubernetes
roles:
- role: rke
vars:
diff --git a/ansible/roles/rke/molecule/default/tests/test_kubernetes.py b/ansible/roles/rke/molecule/default/tests/test_etcd.py
index 887494fa..0f4b6f12 100644
--- a/ansible/roles/rke/molecule/default/tests/test_kubernetes.py
+++ b/ansible/roles/rke/molecule/default/tests/test_etcd.py
@@ -4,10 +4,10 @@ import pytest
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
- os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('kubernetes')
+ os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('kubernetes-etcd')
@pytest.mark.parametrize('container_name', [
- 'etcd', 'kubelet', 'kube-proxy'])
+ 'etcd'])
def test_container_running(host, container_name):
assert host.docker(container_name).is_running
diff --git a/ansible/roles/rke/molecule/default/tests/test_nodes.py b/ansible/roles/rke/molecule/default/tests/test_nodes.py
new file mode 100644
index 00000000..60413018
--- /dev/null
+++ b/ansible/roles/rke/molecule/default/tests/test_nodes.py
@@ -0,0 +1,13 @@
+import os
+import pytest
+
+import testinfra.utils.ansible_runner
+
+testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
+ os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('kubernetes-node')
+
+
+@pytest.mark.parametrize('container_name', [
+ 'kubelet', 'kube-proxy'])
+def test_container_running(host, container_name):
+ assert host.docker(container_name).is_running
diff --git a/ansible/roles/rke/templates/cluster.yml.j2 b/ansible/roles/rke/templates/cluster.yml.j2
index 64508e6f..2012ab92 100644
--- a/ansible/roles/rke/templates/cluster.yml.j2
+++ b/ansible/roles/rke/templates/cluster.yml.j2
@@ -1,7 +1,5 @@
nodes:
-{# Note that we iterate through all nodes in relevant groups.
-We check which groups they belong to exactly later to determine roles. #}
-{% for node in groups['kubernetes'] | union(groups['kubernetes-control-plane']) %}
+{% for node in groups['kubernetes'] %}
- address: "{{ hostvars[node].cluster_ip }}"
port: "22"
internal_address: "{{ hostvars[node].cluster_ip }}"
@@ -9,8 +7,10 @@ We check which groups they belong to exactly later to determine roles. #}
{% if node in groups['kubernetes-control-plane'] %}
- controlplane
{% endif %}
-{% if node in groups['kubernetes'] %}
+{% if node in groups['kubernetes-node'] %}
- worker
+{% endif %}
+{% if node in groups['kubernetes-etcd'] %}
- etcd
{% endif %}
hostname_override: ""
diff --git a/ansible/roles/vncserver/.yamllint b/ansible/roles/vncserver/.yamllint
new file mode 100644
index 00000000..ad0be760
--- /dev/null
+++ b/ansible/roles/vncserver/.yamllint
@@ -0,0 +1,11 @@
+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/vncserver/molecule/default/cleanup.yml b/ansible/roles/vncserver/molecule/default/cleanup.yml
new file mode 100644
index 00000000..16be86ef
--- /dev/null
+++ b/ansible/roles/vncserver/molecule/default/cleanup.yml
@@ -0,0 +1,6 @@
+---
+- name: Cleanup
+ hosts: all
+ ignore_unreachable: true
+ roles:
+ - cleanup-vncserver
diff --git a/ansible/roles/vncserver/molecule/default/molecule.yml b/ansible/roles/vncserver/molecule/default/molecule.yml
new file mode 100644
index 00000000..5f7e4062
--- /dev/null
+++ b/ansible/roles/vncserver/molecule/default/molecule.yml
@@ -0,0 +1,32 @@
+---
+dependency:
+ name: galaxy
+driver:
+ name: docker
+lint:
+ name: yamllint
+platforms:
+ - name: infrastructure-server
+ image: molecule-${PREBUILD_PLATFORM_DISTRO:-centos}:${PREBUILD_DISTRO_VERSION:-centos7.6}
+ pre_build_image: True
+ privileged: true
+ volumes:
+ - /var/lib/docker
+ override_command: False
+ groups:
+ - infrastructure
+provisioner:
+ name: ansible
+ lint:
+ name: ansible-lint
+ env:
+ ANSIBLE_ROLES_PATH: ../../../../test/roles
+ inventory:
+ links:
+ group_vars: ../../../../group_vars
+verifier:
+ name: testinfra
+ lint:
+ name: flake8
+ options:
+ v: 1
diff --git a/ansible/roles/vncserver/molecule/default/playbook.yml b/ansible/roles/vncserver/molecule/default/playbook.yml
new file mode 100644
index 00000000..1b253495
--- /dev/null
+++ b/ansible/roles/vncserver/molecule/default/playbook.yml
@@ -0,0 +1,5 @@
+---
+- name: Converge
+ hosts: infrastructure
+ roles:
+ - vncserver
diff --git a/ansible/roles/vncserver/molecule/default/prepare.yml b/ansible/roles/vncserver/molecule/default/prepare.yml
new file mode 100644
index 00000000..55edb8f8
--- /dev/null
+++ b/ansible/roles/vncserver/molecule/default/prepare.yml
@@ -0,0 +1,8 @@
+---
+- name: Prepare
+ hosts: all
+ vars_files:
+ - ../../defaults/main.yml
+ roles:
+ - prepare-docker-dind
+ - prepare-vncserver
diff --git a/ansible/roles/vncserver/molecule/default/tests/test_default.py b/ansible/roles/vncserver/molecule/default/tests/test_default.py
new file mode 100644
index 00000000..0164a3ee
--- /dev/null
+++ b/ansible/roles/vncserver/molecule/default/tests/test_default.py
@@ -0,0 +1,10 @@
+import os
+
+import testinfra.utils.ansible_runner
+
+testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
+ os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('infrastructure')
+
+
+def test_container_running(host):
+ assert host.docker('vnc-server').is_running