[MOLECULE] Fix 'certificates' setup and verifier tests 61/120361/1
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>
Fri, 9 Apr 2021 11:30:47 +0000 (13:30 +0200)
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>
Fri, 9 Apr 2021 11:30:47 +0000 (13:30 +0200)
Change-Id: I13d4774f6860f6c3e396f58f1c60ae589beea9b1
Issue-ID: OOM-2722
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
ansible/roles/certificates/molecule/default/group_vars/all.yml [deleted file]
ansible/roles/certificates/molecule/default/host_vars/infrastructure-server.yml [deleted file]
ansible/roles/certificates/molecule/default/molecule.yml
ansible/roles/certificates/molecule/default/tests/test_infrastructure.py
ansible/roles/certificates/molecule/ubuntu/group_vars [deleted symlink]
ansible/roles/certificates/molecule/ubuntu/host_vars [deleted symlink]
ansible/roles/certificates/molecule/ubuntu/molecule.yml

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 (file)
index 6e528ae..0000000
+++ /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 (file)
index 67b7ac9..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
----
-cluster_ip: 1.2.3.4
index fd703ca..98db057 100644 (file)
@@ -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:
index 6a0aec0..ca5e89c 100644 (file)
@@ -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 (symlink)
index 5ce8257..0000000
+++ /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 (symlink)
index a704613..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../default/host_vars/
\ No newline at end of file
index 6997117..25fb392 100644 (file)
@@ -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: