diff --git a/roles/ldap_client/handlers/main.yml b/roles/ldap_client/handlers/main.yml index ed97d539c095cf1413af30cc23dea272095b97dd..95f29b7a2a9f22adce44f88731d56b24b1723de4 100644 --- a/roles/ldap_client/handlers/main.yml +++ b/roles/ldap_client/handlers/main.yml @@ -1 +1,4 @@ --- + +- debug: + msg: "No handlers are available for ldap_client role." diff --git a/roles/ldap_client/molecule/default/create.yml b/roles/ldap_client/molecule/default/create.yml index f8eb37cd4df02c540216c02791d0c50870986202..ce8657f9bae3be7f42731fd1efe77e87a62afcd9 100644 --- a/roles/ldap_client/molecule/default/create.yml +++ b/roles/ldap_client/molecule/default/create.yml @@ -2,7 +2,7 @@ - name: Create hosts: localhost connection: local - gather_facts: False + gather_facts: false no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" vars: molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}" diff --git a/roles/ldap_client/molecule/default/destroy.yml b/roles/ldap_client/molecule/default/destroy.yml index 3972a2df8fafe515b30a74f951499b83aae8449c..8f0a3703672765e77f4f1a3a8046a1f2b561a7a8 100644 --- a/roles/ldap_client/molecule/default/destroy.yml +++ b/roles/ldap_client/molecule/default/destroy.yml @@ -3,7 +3,7 @@ - name: Destroy hosts: localhost connection: local - gather_facts: False + gather_facts: false no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" vars: molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}" diff --git a/roles/ldap_client/molecule/default/group_vars/parameters-mandatory.yml b/roles/ldap_client/molecule/default/group_vars/parameters-mandatory.yml new file mode 100644 index 0000000000000000000000000000000000000000..ed97d539c095cf1413af30cc23dea272095b97dd --- /dev/null +++ b/roles/ldap_client/molecule/default/group_vars/parameters-mandatory.yml @@ -0,0 +1 @@ +--- diff --git a/roles/ldap_client/molecule/default/group_vars/parameters-optional.yml b/roles/ldap_client/molecule/default/group_vars/parameters-optional.yml new file mode 100644 index 0000000000000000000000000000000000000000..4abb1ab4c26d39bdf7956f7d067c15a78fa2eec6 --- /dev/null +++ b/roles/ldap_client/molecule/default/group_vars/parameters-optional.yml @@ -0,0 +1,15 @@ +--- + +ldap_client_config: + - comment: CA truststore + option: TLS_CACERT + value: /etc/ssl/certs/testca.cert.pem + - comment: Ensure TLS is enforced + option: TLS_REQCERT + value: demand + - comment: Default URI to connect to + option: URI + value: ldaps://ldap-server/ + - comment: Base entry + option: BASE + value: dc=local diff --git a/roles/ldap_client/molecule/default/molecule.yml b/roles/ldap_client/molecule/default/molecule.yml index cab3cf35b8c91b686e4dff2cb5f903b45ded876a..020b4c42adbf474a57b931f42bd2c5e81b157309 100644 --- a/roles/ldap_client/molecule/default/molecule.yml +++ b/roles/ldap_client/molecule/default/molecule.yml @@ -9,6 +9,8 @@ driver: lint: name: yamllint + options: + config-file: ../../.yamllint.yml platforms: diff --git a/roles/ldap_client/molecule/default/playbook.yml b/roles/ldap_client/molecule/default/playbook.yml index c110bb100dec50bca3f82f8c8cbcd5263a51e24f..384c7fa6f0e871cfc657b2ff9bbed420e61f5e7f 100644 --- a/roles/ldap_client/molecule/default/playbook.yml +++ b/roles/ldap_client/molecule/default/playbook.yml @@ -1,24 +1,6 @@ --- -- hosts: parameters-mandatory - become: yes +- hosts: parameters-mandatory,parameters-optional + become: true roles: - ldap_client - -- hosts: parameters-optional - become: yes - roles: - - role: ldap_client - ldap_client_config: - - comment: CA truststore - option: TLS_CACERT - value: /etc/ssl/certs/testca.cert.pem - - comment: Ensure TLS is enforced - option: TLS_REQCERT - value: demand - - comment: Default URI to connect to - option: URI - value: ldaps://ldap-server/ - - comment: Base entry - option: BASE - value: dc=local diff --git a/roles/ldap_client/molecule/default/prepare.yml b/roles/ldap_client/molecule/default/prepare.yml index 2ca5369027ee16118496dcf8548f8d803a0c9699..ecfa6db10c57f61e118e827fb3a95abf2159de8c 100644 --- a/roles/ldap_client/molecule/default/prepare.yml +++ b/roles/ldap_client/molecule/default/prepare.yml @@ -2,18 +2,18 @@ - name: Prepare hosts: all - gather_facts: False + gather_facts: false tasks: - name: Install python for Ansible raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal) - become: True - changed_when: False + become: true + changed_when: false - hosts: all - become: yes + become: true tasks: - name: Update all caches to avoid errors due to missing remote archives apt: - update_cache: yes - changed_when: False + update_cache: true + changed_when: false diff --git a/roles/ldap_client/molecule/default/tests/test_default.py b/roles/ldap_client/molecule/default/tests/test_default.py index c1db640b9f866cc39e4a2af85a77e5f7b1525111..74e7f858a01e5098c98b417589092f01e49214cc 100644 --- a/roles/ldap_client/molecule/default/tests/test_default.py +++ b/roles/ldap_client/molecule/default/tests/test_default.py @@ -1,7 +1,10 @@ +import os + import testinfra.utils.ansible_runner + testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - '.molecule/ansible_inventory.yml').get_hosts('all') + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(['parameters-mandatory', 'parameters-optional']) def test_installed_packages(host): diff --git a/roles/ldap_client/molecule/default/tests/test_mandatory.py b/roles/ldap_client/molecule/default/tests/test_mandatory.py index cfd14699498c8b90ee4e4a1b3b7a7e047a141f04..0dcc51916cf2f626ad09abb643fe7a46307bbb43 100644 --- a/roles/ldap_client/molecule/default/tests/test_mandatory.py +++ b/roles/ldap_client/molecule/default/tests/test_mandatory.py @@ -1,7 +1,10 @@ +import os + import testinfra.utils.ansible_runner + testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - '.molecule/ansible_inventory.yml').get_hosts('parameters-mandatory') + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(['parameters-mandatory']) def test_ldap_configuration_file_content(host): diff --git a/roles/ldap_client/molecule/default/tests/test_optional.py b/roles/ldap_client/molecule/default/tests/test_optional.py index 04060c9c56a5efdcb35a2a2f6cbd1f2e582d4501..7beedf3018c091e15334d51fdeb52b3791854d09 100644 --- a/roles/ldap_client/molecule/default/tests/test_optional.py +++ b/roles/ldap_client/molecule/default/tests/test_optional.py @@ -1,7 +1,10 @@ +import os + import testinfra.utils.ansible_runner + testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - '.molecule/ansible_inventory.yml').get_hosts('parameters-optional') + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(['parameters-optional']) def test_ldap_configuration_file_content(host): diff --git a/roles/ldap_client/tasks/main.yml b/roles/ldap_client/tasks/main.yml index a9b38fc08932ca7fd3275ae693fcdd57f9ef0fae..54e3087f404dea06bc6239c6d1d9d8ca54fd641d 100644 --- a/roles/ldap_client/tasks/main.yml +++ b/roles/ldap_client/tasks/main.yml @@ -3,7 +3,7 @@ - name: Install OpenLDAP client tools apt: name: ldap-utils - state: installed + state: present - name: Deploy LDAP client configuration file template: