summaryrefslogtreecommitdiffstats
path: root/ansible
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2021-04-09 13:30:47 +0200
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>2021-04-09 13:30:47 +0200
commit31990268811b0fc80a5332f93248131163fb511d (patch)
tree1927d481fe49fef8ea3553a0d9fdca3296e73c10 /ansible
parent3a1efb1884db1d3911e71d0197ef41fcd823381d (diff)
[MOLECULE] Fix 'certificates' setup and verifier tests
Change-Id: I13d4774f6860f6c3e396f58f1c60ae589beea9b1 Issue-ID: OOM-2722 Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Diffstat (limited to 'ansible')
-rw-r--r--ansible/roles/certificates/molecule/default/group_vars/all.yml7
-rw-r--r--ansible/roles/certificates/molecule/default/host_vars/infrastructure-server.yml2
-rw-r--r--ansible/roles/certificates/molecule/default/molecule.yml41
-rw-r--r--ansible/roles/certificates/molecule/default/tests/test_infrastructure.py13
l---------ansible/roles/certificates/molecule/ubuntu/group_vars1
l---------ansible/roles/certificates/molecule/ubuntu/host_vars1
-rw-r--r--ansible/roles/certificates/molecule/ubuntu/molecule.yml41
7 files changed, 29 insertions, 77 deletions
diff --git a/ansible/roles/certificates/molecule/default/group_vars/all.yml b/ansible/roles/certificates/molecule/default/group_vars/all.yml
deleted file mode 100644
index 6e528ae0..00000000
--- a/ansible/roles/certificates/molecule/default/group_vars/all.yml
+++ /dev/null
@@ -1,7 +0,0 @@
----
-certificates:
- organization_name: MoleculeTesters
- state_or_province_name: Poland
- country_name: PL
- locality_name: Krakow
-app_data_path: /opt/moleculetestapp
diff --git a/ansible/roles/certificates/molecule/default/host_vars/infrastructure-server.yml b/ansible/roles/certificates/molecule/default/host_vars/infrastructure-server.yml
deleted file mode 100644
index 67b7ac9e..00000000
--- a/ansible/roles/certificates/molecule/default/host_vars/infrastructure-server.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-cluster_ip: 1.2.3.4
diff --git a/ansible/roles/certificates/molecule/default/molecule.yml b/ansible/roles/certificates/molecule/default/molecule.yml
index fd703ca5..98db057b 100644
--- a/ansible/roles/certificates/molecule/default/molecule.yml
+++ b/ansible/roles/certificates/molecule/default/molecule.yml
@@ -31,34 +31,19 @@ provisioner:
ANSIBLE_ROLES_PATH: ../../../../test/roles
ANSIBLE_LIBRARY: ../../../../library
inventory:
- links:
- group_vars: ../../../../group_vars/
-scenario:
- test_sequence:
- - lint
- - cleanup
- - destroy
- - dependency
- - syntax
- - create
- - prepare
- - converge
- # - idempotence
- # --> Action: 'idempotence'
- # ERROR: Idempotence test failed because of the following tasks:
- # * [infrastructure-server -> localhost] => certificates : Generate an OpenSSL CSR.
- # * [infrastructure-server -> localhost] => certificates : Generate root CA certificate
- # * [infrastructure-server] => certificates : Upload certificates to infrastructure server
- # * [infrastructure-server] => certificates : Copy root certificate
- # * [infrastructure-server] => certificates : Extract root certificate
- # * [infrastructure-server] => docker : Setup docker dns settings
- # * [kubernetes-node-1] => certificates : Copy root certificate
- # * [kubernetes-node-1] => certificates : Extract root certificate
- # * [kubernetes-node-1] => certificates : Extract root certificate
- - side_effect
- - verify
- - cleanup
- - destroy
+ group_vars:
+ all:
+ certificates:
+ organization_name: MoleculeTesters
+ state_or_province_name: Poland
+ country_name: PL
+ locality_name: Krakow
+ app_data_path: /opt/moleculetestapp
+ all_simulated_hosts:
+ - molecule.sim.host1
+ - molecule.sim.host2
+ infrastructure-server:
+ cluster_ip: 1.2.3.4
verifier:
name: testinfra
options:
diff --git a/ansible/roles/certificates/molecule/default/tests/test_infrastructure.py b/ansible/roles/certificates/molecule/default/tests/test_infrastructure.py
index 6a0aec03..ca5e89cc 100644
--- a/ansible/roles/certificates/molecule/default/tests/test_infrastructure.py
+++ b/ansible/roles/certificates/molecule/default/tests/test_infrastructure.py
@@ -9,8 +9,7 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
@pytest.fixture
def group_vars(host):
- all_file = "file=group_vars/all.yml name=all"
- return host.ansible("include_vars", all_file)["ansible_facts"]["all"]
+ return host.ansible.get_variables()
@pytest.mark.parametrize('cert_file', [
@@ -27,13 +26,7 @@ def test_generated_cert_files_copied_to_infra(host, cert_file, group_vars):
assert f.user == 'root'
assert f.group == 'root'
- os = host.system_info.distribution
- if (os == "centos"):
- node_directory = "certs/"
- elif (os == "ubuntu"):
- node_directory = "../default/certs/"
-
# Verify cert files content locally is as in node
- with open(node_directory + cert_file) as local_cert_file:
+ with open("molecule/default/certs/" + cert_file) as local_cert_file:
local_content = local_cert_file.read().strip()
- assert local_content == f.content_string
+ assert local_content == f.content_string.strip()
diff --git a/ansible/roles/certificates/molecule/ubuntu/group_vars b/ansible/roles/certificates/molecule/ubuntu/group_vars
deleted file mode 120000
index 5ce8257f..00000000
--- a/ansible/roles/certificates/molecule/ubuntu/group_vars
+++ /dev/null
@@ -1 +0,0 @@
-../default/group_vars/ \ No newline at end of file
diff --git a/ansible/roles/certificates/molecule/ubuntu/host_vars b/ansible/roles/certificates/molecule/ubuntu/host_vars
deleted file mode 120000
index a7046132..00000000
--- a/ansible/roles/certificates/molecule/ubuntu/host_vars
+++ /dev/null
@@ -1 +0,0 @@
-../default/host_vars/ \ No newline at end of file
diff --git a/ansible/roles/certificates/molecule/ubuntu/molecule.yml b/ansible/roles/certificates/molecule/ubuntu/molecule.yml
index 69971175..25fb392e 100644
--- a/ansible/roles/certificates/molecule/ubuntu/molecule.yml
+++ b/ansible/roles/certificates/molecule/ubuntu/molecule.yml
@@ -33,34 +33,19 @@ provisioner:
converge: ../default/converge.yml
cleanup: ../default/cleanup.yml
inventory:
- links:
- group_vars: ../../../../group_vars/
-scenario:
- test_sequence:
- - lint
- - cleanup
- - destroy
- - dependency
- - syntax
- - create
- - prepare
- - converge
- # - idempotence
- # --> Action: 'idempotence'
- # ERROR: Idempotence test failed because of the following tasks:
- # * [infrastructure-server -> localhost] => certificates : Generate an OpenSSL CSR.
- # * [infrastructure-server -> localhost] => certificates : Generate root CA certificate
- # * [infrastructure-server] => certificates : Upload certificates to infrastructure server
- # * [infrastructure-server] => certificates : Copy root certificate
- # * [infrastructure-server] => certificates : Extract root certificate
- # * [infrastructure-server] => docker : Setup docker dns settings
- # * [kubernetes-node-1] => certificates : Copy root certificate
- # * [kubernetes-node-1] => certificates : Extract root certificate
- # * [kubernetes-node-1] => certificates : Extract root certificate
- - side_effect
- - verify
- - cleanup
- - destroy
+ group_vars:
+ all:
+ certificates:
+ organization_name: MoleculeTesters
+ state_or_province_name: Poland
+ country_name: PL
+ locality_name: Krakow
+ app_data_path: /opt/moleculetestapp
+ all_simulated_hosts:
+ - molecule.sim.host1
+ - molecule.sim.host2
+ infrastructure-server:
+ cluster_ip: 1.2.3.4
verifier:
name: testinfra
options: