diff --git a/roles/database/defaults/main.yml b/roles/database/defaults/main.yml index e093480665698ccbc55753591d61bb71b87fdc00..83e7c5697ca05854b0bd9a617983df26d6718b63 100644 --- a/roles/database/defaults/main.yml +++ b/roles/database/defaults/main.yml @@ -1,3 +1,3 @@ --- -enable_backup: False +enable_backup: false diff --git a/roles/database/meta/main.yml b/roles/database/meta/main.yml index 9778445d22f2635083bbb069c3bac6319860e6d6..c7b4ee02070fd5e78997a74753fd7e2ed69383a0 100644 --- a/roles/database/meta/main.yml +++ b/roles/database/meta/main.yml @@ -1,6 +1,6 @@ --- -allow_duplicates: yes +allow_duplicates: true dependencies: - database_server diff --git a/roles/database/molecule/default/create.yml b/roles/database/molecule/default/create.yml index f8eb37cd4df02c540216c02791d0c50870986202..ce8657f9bae3be7f42731fd1efe77e87a62afcd9 100644 --- a/roles/database/molecule/default/create.yml +++ b/roles/database/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/database/molecule/default/destroy.yml b/roles/database/molecule/default/destroy.yml index 3972a2df8fafe515b30a74f951499b83aae8449c..8f0a3703672765e77f4f1a3a8046a1f2b561a7a8 100644 --- a/roles/database/molecule/default/destroy.yml +++ b/roles/database/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/database/molecule/default/group_vars/parameters-mandatory.yml b/roles/database/molecule/default/group_vars/parameters-mandatory.yml new file mode 100644 index 0000000000000000000000000000000000000000..c1ad193bdc9198b88b303e29590d2fc66ab2c1a7 --- /dev/null +++ b/roles/database/molecule/default/group_vars/parameters-mandatory.yml @@ -0,0 +1,7 @@ +--- + +db_name: testdb +db_password: testdbpassword + +# database_server role +db_root_password: "root_password" diff --git a/roles/database/molecule/default/group_vars/parameters-optional.yml b/roles/database/molecule/default/group_vars/parameters-optional.yml new file mode 100644 index 0000000000000000000000000000000000000000..4286afc962b1db0b8df6f2c87e7def6d685fbae7 --- /dev/null +++ b/roles/database/molecule/default/group_vars/parameters-optional.yml @@ -0,0 +1,19 @@ +--- + +db_name: testdb +db_password: testdbpassword +enable_backup: true + +# database_server +db_root_password: "root_password" + +# backup_client +backup_client_username: "bak-localhost" +backup_encryption_key: "{{ lookup('file', 'tests/data/gnupg/parameters-optional.asc') }}" +backup_server: localhost +backup_server_host_ssh_public_keys: + - "{{ lookup('file', 'tests/data/ssh/server_dsa.pub') }}" + - "{{ lookup('file', 'tests/data/ssh/server_rsa.pub') }}" + - "{{ lookup('file', 'tests/data/ssh/server_ed25519.pub') }}" + - "{{ lookup('file', 'tests/data/ssh/server_ecdsa.pub') }}" +backup_ssh_key: "{{ lookup('file', 'tests/data/ssh/parameters-optional' ) }}" diff --git a/roles/database/molecule/default/molecule.yml b/roles/database/molecule/default/molecule.yml index 478b973e85120ddd36ad00c5a95464db73429287..c8347df4ce0e9492868b591c3abbf6fd980decfd 100644 --- a/roles/database/molecule/default/molecule.yml +++ b/roles/database/molecule/default/molecule.yml @@ -9,6 +9,8 @@ driver: lint: name: yamllint + options: + config-file: ../../.yamllint.yml platforms: @@ -19,9 +21,10 @@ platforms: memory: 256 cpus: 1 - - name: backup-jessie64 + - name: parameters-optional-jessie64 groups: - - backup + - parameters-optional + - backup-server box: debian/contrib-jessie64 memory: 512 cpus: 1 diff --git a/roles/database/molecule/default/playbook.yml b/roles/database/molecule/default/playbook.yml index 2d9e636b94791137f73c6549e0417b5754699042..43e8d21aa7cbedd496c2001996bfaf2cca93be8c 100644 --- a/roles/database/molecule/default/playbook.yml +++ b/roles/database/molecule/default/playbook.yml @@ -1,34 +1,7 @@ --- -- hosts: parameters-mandatory - become: yes +- hosts: parameters-mandatory,parameters-optional + become: true roles: - - role: database - db_name: testdb - db_password: testdbpassword - - # database_server role - db_root_password: "root_password" - -- hosts: backup - become: yes - roles: - - role: database - db_name: testdb - db_password: testdbpassword - enable_backup: yes - - # database_server - db_root_password: "root_password" - - # backup_client - backup_client_username: "bak-localhost" - backup_encryption_key: "{{ lookup('file', 'tests/data/gnupg/parameters-optional.asc') }}" - backup_server: localhost - backup_server_host_ssh_public_keys: - - "{{ lookup('file', 'tests/data/ssh/server_dsa.pub') }}" - - "{{ lookup('file', 'tests/data/ssh/server_rsa.pub') }}" - - "{{ lookup('file', 'tests/data/ssh/server_ed25519.pub') }}" - - "{{ lookup('file', 'tests/data/ssh/server_ecdsa.pub') }}" - backup_ssh_key: "{{ lookup('file', 'tests/data/ssh/parameters-optional' ) }}" + - database diff --git a/roles/database/molecule/default/prepare.yml b/roles/database/molecule/default/prepare.yml index b145f2960193cd8dd188b19042b3bb11de67d069..55f8d9f94a6942db2f8bb2587db498d8fd20c6e7 100644 --- a/roles/database/molecule/default/prepare.yml +++ b/roles/database/molecule/default/prepare.yml @@ -2,24 +2,24 @@ - 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 -- hosts: backup - become: yes +- hosts: backup-server + become: true roles: - role: backup_server backup_host_ssh_private_keys: diff --git a/roles/database/molecule/default/tests/test_backup.py b/roles/database/molecule/default/tests/test_backup.py index d5dd7273d796b3b86f1b3fc913836fda1e4826b2..f20c0bd2d4a4b1128e49c6e02a0434d79cc6465d 100644 --- a/roles/database/molecule/default/tests/test_backup.py +++ b/roles/database/molecule/default/tests/test_backup.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('backup') + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(['parameters-optional']) def test_backup_directories(host): diff --git a/roles/database/molecule/default/tests/test_default.py b/roles/database/molecule/default/tests/test_default.py index 42a3ce7c9ba1d8b3b8cd39706260024b31982292..ad4ad2c0faa27b184ef35d9a805eb44070127a31 100644 --- a/roles/database/molecule/default/tests/test_default.py +++ b/roles/database/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_database_created(host):