77@pytest .fixture (scope = "module" )
88def get_ansible_vars (host ):
99 """Define get_ansible_vars"""
10- java_role = "file=../../vars/main.yml name=java_role"
11- common_vars = "file=../../../common/vars/main.yml name=common_vars"
10+ java_role_defaults = "file=../../defaults/main.yml name=java_role"
1211 common_defaults = "file=../../../common/defaults/main.yml name=common_defaults"
13- group_vars = "file=../../../../group_vars/all.yml name=group_vars"
1412 ansible_vars = host .ansible (
1513 "include_vars" ,
16- java_role
14+ java_role_defaults
1715 )["ansible_facts" ]["java_role" ]
18- ansible_vars .update (
19- host .ansible (
20- "include_vars" , java_role
21- )["ansible_facts" ]["java_role" ]
22- )
23- ansible_vars .update (
24- host .ansible (
25- "include_vars" , common_vars
26- )["ansible_facts" ]["common_vars" ]
27- )
2816 ansible_vars .update (
2917 host .ansible (
3018 "include_vars" , common_defaults
3119 )["ansible_facts" ]["common_defaults" ]
3220 )
33- ansible_vars .update (
34- host .ansible (
35- "include_vars" ,
36- group_vars
37- )["ansible_facts" ]["group_vars" ]
38- )
3921 return ansible_vars
4022
4123
4224def test_java_exists (host , get_ansible_vars ):
4325 """Check that java executable exists"""
44- java_version = get_ansible_vars ["dependencies_version" ][ "java " ]
26+ java_version = get_ansible_vars ["java_core " ]
4527 java_bin = host .file ("/opt/openjdk-{}/bin/java" .format (java_version ))
4628 assert_that (java_bin .exists , True )
4729
4830
4931def test_java_version (host , get_ansible_vars ):
5032 """Check that java version is correct"""
51- java_version = get_ansible_vars ["dependencies_version" ][ "java " ]
33+ java_version = get_ansible_vars ["java_core " ]
5234 cmd = host .run ("/opt/openjdk-{}/bin/java -version" .format (java_version ))
5335 assert_that (cmd .stderr , contains_string (java_version ))
5436
5537
5638def test_java_home (host , get_ansible_vars ):
5739 """Check that JAVA_HOME is environment variable is set"""
58- java_version = get_ansible_vars ["dependencies_version" ][ "java " ]
40+ java_version = get_ansible_vars ["java_core " ]
5941 with host .sudo ():
6042 cmd = host .run (
6143 ". {}/setenv.sh && echo $JAVA_HOME" .format (
@@ -70,7 +52,7 @@ def test_java_home(host, get_ansible_vars):
7052def test_keystore (host , get_ansible_vars ):
7153 """Check the Java keytore is populated with certificate"""
7254 hostname = host .ansible .get_variables ()["inventory_hostname" ]
73- java_version = get_ansible_vars ["dependencies_version" ][ "java " ]
55+ java_version = get_ansible_vars ["java_core " ]
7456 java_home = '/opt/openjdk-' + java_version
7557 keystore = java_home + '/lib/security/keystore/ansible.jceks'
7658 cmd_tpl = '{}/bin/keytool -list -keystore {} -storepass alfresco -alias {}'
@@ -88,7 +70,7 @@ def test_keystore(host, get_ansible_vars):
8870
8971def test_keystore_seckey (host , get_ansible_vars ):
9072 """Check the Java keytore is populated with certificate"""
91- java_version = get_ansible_vars ["dependencies_version" ][ "java " ]
73+ java_version = get_ansible_vars ["java_core " ]
9274 java_home = '/opt/openjdk-' + java_version
9375 keystore = java_home + '/lib/security/keystore/ansible.jceks'
9476 cmd_tpl = '{}/bin/keytool -keypasswd -keystore {} -storepass alfresco -keypass "{}" -new "{}" -alias test'
@@ -107,7 +89,7 @@ def test_keystore_seckey(host, get_ansible_vars):
10789
10890def test_truststore (host , get_ansible_vars ):
10991 """Check the Java truststore trusts the CA root signing certificate"""
110- java_version = get_ansible_vars ["dependencies_version" ][ "java " ]
92+ java_version = get_ansible_vars ["java_core " ]
11193 cmd = host .run (
11294 "/opt/openjdk-{}/bin/keytool -list -cacerts" .format (java_version )
11395 )
0 commit comments