Changeset - 62014a66e35f
[Not reviewed]
0 10 2
Branko Majic (branko) - 6 years ago 2018-05-28 22:34:14
branko@majic.rs
MAR-129: Updated LDAP client role and its tests for new Molecule and Ansible:

- Fixed linting issues.
- Moved test playbook variables into group_vars.
- Include linting configuration for tests from top-level directory.
- Updated how the target hosts are refenced in tests.
- Fixed Ansible warnings.
12 files changed with 44 insertions and 32 deletions:
0 comments (0 inline, 0 general)
roles/ldap_client/handlers/main.yml
Show inline comments
 
---
 

	
 
- debug:
 
    msg: "No handlers are available for ldap_client role."
roles/ldap_client/molecule/default/create.yml
Show inline comments
 
@@ -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') }}"
roles/ldap_client/molecule/default/destroy.yml
Show inline comments
 
@@ -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') }}"
roles/ldap_client/molecule/default/group_vars/parameters-mandatory.yml
Show inline comments
 
new file 100644
 
---
roles/ldap_client/molecule/default/group_vars/parameters-optional.yml
Show inline comments
 
new file 100644
 
---
 

	
 
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
roles/ldap_client/molecule/default/molecule.yml
Show inline comments
 
@@ -9,6 +9,8 @@ driver:
 

	
 
lint:
 
  name: yamllint
 
  options:
 
    config-file: ../../.yamllint.yml
 

	
 
platforms:
 

	
roles/ldap_client/molecule/default/playbook.yml
Show inline comments
 
---
 

	
 
- 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
roles/ldap_client/molecule/default/prepare.yml
Show inline comments
 
@@ -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
roles/ldap_client/molecule/default/tests/test_default.py
Show inline comments
 
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):
roles/ldap_client/molecule/default/tests/test_mandatory.py
Show inline comments
 
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):
roles/ldap_client/molecule/default/tests/test_optional.py
Show inline comments
 
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):
roles/ldap_client/tasks/main.yml
Show inline comments
 
@@ -3,7 +3,7 @@
 
- name: Install OpenLDAP client tools
 
  apt:
 
    name: ldap-utils
 
    state: installed
 
    state: present
 

	
 
- name: Deploy LDAP client configuration file
 
  template:
0 comments (0 inline, 0 general)