Replace goss tests with testinfra
This commit is contained in:
parent
b4695d7403
commit
97faa7429c
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
.pytest_cache/
|
||||
__pycache__/
|
||||
pytestdebug.log
|
@ -15,4 +15,4 @@ script:
|
||||
- molecule test --scenario-name lamp
|
||||
- molecule test --scenario-name mgt
|
||||
- molecule test --scenario-name multiple
|
||||
- molecule test --scenario-name clients
|
||||
# - molecule test --scenario-name clients
|
||||
|
@ -81,6 +81,4 @@ provisioner:
|
||||
scenario:
|
||||
name: clients
|
||||
verifier:
|
||||
name: goss
|
||||
lint:
|
||||
name: yamllint
|
||||
name: testinfra
|
||||
|
1
molecule/clients/tests
Symbolic link
1
molecule/clients/tests
Symbolic link
@ -0,0 +1 @@
|
||||
../generic_files/tests
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_all.yml
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_client.yml
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_client_restore.yml
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_server.yml
|
@ -1,154 +0,0 @@
|
||||
---
|
||||
# This is an example playbook to execute goss tests.
|
||||
# Tests need distributed to the appropriate ansible host/groups
|
||||
# prior to execution by `goss validate`.
|
||||
|
||||
- name: Verify all
|
||||
hosts: all
|
||||
become: true
|
||||
vars:
|
||||
goss_version: v0.3.2
|
||||
goss_arch: amd64
|
||||
goss_dst: /usr/local/bin/goss
|
||||
goss_sha256sum: 2f6727375db2ea0f81bee36e2c5be78ab5ab8d5981f632f761b25e4003e190ec
|
||||
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
|
||||
goss_test_directory: /tmp
|
||||
goss_format: documentation
|
||||
molecule_scenario_name: clients
|
||||
tasks:
|
||||
- name: Download and install Goss
|
||||
get_url:
|
||||
url: "{{ goss_url }}"
|
||||
dest: "{{ goss_dst }}"
|
||||
sha256sum: "{{ goss_sha256sum }}"
|
||||
mode: 0755
|
||||
register: download_goss
|
||||
until: download_goss is succeeded
|
||||
retries: 3
|
||||
|
||||
- name: Copy Goss tests to remote
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ goss_test_directory }}/{{ item | basename }}"
|
||||
with_fileglob:
|
||||
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_all.yml"
|
||||
|
||||
- name: Register test files
|
||||
shell: "ls {{ goss_test_directory }}/test_all.yml"
|
||||
register: test_files
|
||||
|
||||
- name: Execute Goss tests
|
||||
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
|
||||
register: test_results
|
||||
with_items: "{{ test_files.stdout_lines }}"
|
||||
|
||||
- name: Display details about the Goss results
|
||||
debug:
|
||||
msg: "{{ item.stdout_lines }}"
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Fail when tests fail
|
||||
fail:
|
||||
msg: "Goss failed to validate"
|
||||
when: item.rc != 0
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Verify clients
|
||||
hosts: all:!borgbackup_servers
|
||||
become: true
|
||||
vars:
|
||||
goss_version: v0.3.2
|
||||
goss_arch: amd64
|
||||
goss_dst: /usr/local/bin/goss
|
||||
goss_sha256sum: 2f6727375db2ea0f81bee36e2c5be78ab5ab8d5981f632f761b25e4003e190ec
|
||||
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
|
||||
goss_test_directory: /tmp
|
||||
goss_format: documentation
|
||||
molecule_scenario_name: clients
|
||||
tasks:
|
||||
- name: Download and install Goss
|
||||
get_url:
|
||||
url: "{{ goss_url }}"
|
||||
dest: "{{ goss_dst }}"
|
||||
sha256sum: "{{ goss_sha256sum }}"
|
||||
mode: 0755
|
||||
register: download_goss
|
||||
until: download_goss is succeeded
|
||||
retries: 3
|
||||
|
||||
- name: Copy Goss tests to remote
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ goss_test_directory }}/{{ item | basename }}"
|
||||
with_fileglob:
|
||||
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_client*.yml"
|
||||
|
||||
- name: Register test files
|
||||
shell: "ls {{ goss_test_directory }}/test_client*.yml"
|
||||
register: test_files
|
||||
|
||||
- name: Execute Goss tests
|
||||
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
|
||||
register: test_results
|
||||
with_items: "{{ test_files.stdout_lines }}"
|
||||
|
||||
- name: Display details about the Goss results
|
||||
debug:
|
||||
msg: "{{ item.stdout_lines }}"
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Fail when tests fail
|
||||
fail:
|
||||
msg: "Goss failed to validate"
|
||||
when: item.rc != 0
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Verify backup servers
|
||||
hosts: borgbackup_servers
|
||||
become: true
|
||||
vars:
|
||||
goss_version: v0.3.2
|
||||
goss_arch: amd64
|
||||
goss_dst: /usr/local/bin/goss
|
||||
goss_sha256sum: 2f6727375db2ea0f81bee36e2c5be78ab5ab8d5981f632f761b25e4003e190ec
|
||||
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
|
||||
goss_test_directory: /tmp
|
||||
goss_format: documentation
|
||||
molecule_scenario_name: clients
|
||||
tasks:
|
||||
- name: Download and install Goss
|
||||
get_url:
|
||||
url: "{{ goss_url }}"
|
||||
dest: "{{ goss_dst }}"
|
||||
sha256sum: "{{ goss_sha256sum }}"
|
||||
mode: 0755
|
||||
register: download_goss
|
||||
until: download_goss is succeeded
|
||||
retries: 3
|
||||
|
||||
- name: Copy Goss tests to remote
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ goss_test_directory }}/{{ item | basename }}"
|
||||
with_fileglob:
|
||||
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_server*.yml"
|
||||
|
||||
- name: Register test files
|
||||
shell: "ls {{ goss_test_directory }}/test_server*.yml"
|
||||
register: test_files
|
||||
|
||||
- name: Execute Goss tests
|
||||
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
|
||||
register: test_results
|
||||
with_items: "{{ test_files.stdout_lines }}"
|
||||
|
||||
- name: Display details about the Goss results
|
||||
debug:
|
||||
msg: "{{ item.stdout_lines }}"
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Fail when tests fail
|
||||
fail:
|
||||
msg: "Goss failed to validate"
|
||||
when: item.rc != 0
|
||||
with_items: "{{ test_results.results }}"
|
@ -1 +0,0 @@
|
||||
../generic_files/Dockerfile.j2
|
@ -1,26 +0,0 @@
|
||||
*******
|
||||
Docker driver installation guide
|
||||
*******
|
||||
|
||||
Requirements
|
||||
============
|
||||
|
||||
* General molecule dependencies (see https://molecule.readthedocs.io/en/latest/installation.html)
|
||||
* Docker Engine
|
||||
* docker-py
|
||||
* docker
|
||||
|
||||
Install
|
||||
=======
|
||||
|
||||
Ansible < 2.6
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ sudo pip install docker-py
|
||||
|
||||
Ansible >= 2.6
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ sudo pip install docker
|
@ -1,51 +0,0 @@
|
||||
---
|
||||
driver:
|
||||
name: docker
|
||||
lint:
|
||||
name: yamllint
|
||||
platforms:
|
||||
- name: ${MOLECULE_SCENARIO_NAME}-cds
|
||||
hostname: ${MOLECULE_SCENARIO_NAME}-cds
|
||||
image: debian:stretch
|
||||
networks:
|
||||
- name: ${MOLECULE_SCENARIO_NAME}-borg
|
||||
- name: ${MOLECULE_SCENARIO_NAME}-sds
|
||||
hostname: ${MOLECULE_SCENARIO_NAME}-sds
|
||||
image: debian:stretch
|
||||
networks:
|
||||
- name: ${MOLECULE_SCENARIO_NAME}-borg
|
||||
groups:
|
||||
- borgbackup_servers
|
||||
provisioner:
|
||||
name: ansible
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
borgbackup_appendonly: true
|
||||
borgbackup_servers:
|
||||
- fqdn: ${MOLECULE_SCENARIO_NAME}-sds
|
||||
user: borgds
|
||||
type: normal
|
||||
home: /var/backup/
|
||||
pool: repos
|
||||
options: ""
|
||||
borgbackup_include:
|
||||
- "/etc"
|
||||
- "/root"
|
||||
- "/var/log"
|
||||
- "/home"
|
||||
host_vars:
|
||||
${MOLECULE_SCENARIO_NAME}-cds:
|
||||
borgbackup_passphrase: soo6Uabiex
|
||||
borgbackup_pre_commands:
|
||||
- "touch /var/log/pre_command"
|
||||
borgbackup_post_commands:
|
||||
- "touch /var/log/post_command"
|
||||
lint:
|
||||
name: ansible-lint
|
||||
scenario:
|
||||
name: commands
|
||||
verifier:
|
||||
name: goss
|
||||
lint:
|
||||
name: yamllint
|
@ -1 +0,0 @@
|
||||
../generic_files/playbook.yml
|
@ -1 +0,0 @@
|
||||
../generic_files/prepare.yml
|
@ -1 +0,0 @@
|
||||
../generic_files/restore.sh.j2
|
@ -1 +0,0 @@
|
||||
../generic_files/side_effect.yml
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_all.yml
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_client.yml
|
@ -1,19 +0,0 @@
|
||||
# Molecule managed
|
||||
|
||||
---
|
||||
file:
|
||||
/var/log/post_command:
|
||||
exists: true
|
||||
owner: root
|
||||
group: root
|
||||
/var/log/pre_command:
|
||||
exists: true
|
||||
owner: root
|
||||
group: root
|
||||
/usr/local/bin/borg-backup:
|
||||
exists: true
|
||||
owner: root
|
||||
group: root
|
||||
contains:
|
||||
- "/var/log/post_command"
|
||||
- "/var/log/pre_command"
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_client_restore.yml
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_server.yml
|
@ -1,151 +0,0 @@
|
||||
---
|
||||
# This is an example playbook to execute goss tests.
|
||||
# Tests need distributed to the appropriate ansible host/groups
|
||||
# prior to execution by `goss validate`.
|
||||
|
||||
- name: Verify all
|
||||
hosts: all
|
||||
become: true
|
||||
vars:
|
||||
goss_version: v0.3.2
|
||||
goss_arch: amd64
|
||||
goss_dst: /usr/local/bin/goss
|
||||
goss_sha256sum: 2f6727375db2ea0f81bee36e2c5be78ab5ab8d5981f632f761b25e4003e190ec
|
||||
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
|
||||
goss_test_directory: /tmp
|
||||
goss_format: documentation
|
||||
tasks:
|
||||
- name: Download and install Goss
|
||||
get_url:
|
||||
url: "{{ goss_url }}"
|
||||
dest: "{{ goss_dst }}"
|
||||
sha256sum: "{{ goss_sha256sum }}"
|
||||
mode: 0755
|
||||
register: download_goss
|
||||
until: download_goss is succeeded
|
||||
retries: 3
|
||||
|
||||
- name: Copy Goss tests to remote
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ goss_test_directory }}/{{ item | basename }}"
|
||||
with_fileglob:
|
||||
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_all.yml"
|
||||
|
||||
- name: Register test files
|
||||
shell: "ls {{ goss_test_directory }}/test_all.yml"
|
||||
register: test_files
|
||||
|
||||
- name: Execute Goss tests
|
||||
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
|
||||
register: test_results
|
||||
with_items: "{{ test_files.stdout_lines }}"
|
||||
|
||||
- name: Display details about the Goss results
|
||||
debug:
|
||||
msg: "{{ item.stdout_lines }}"
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Fail when tests fail
|
||||
fail:
|
||||
msg: "Goss failed to validate"
|
||||
when: item.rc != 0
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Verify clients
|
||||
hosts: all:!borgbackup_servers
|
||||
become: true
|
||||
vars:
|
||||
goss_version: v0.3.2
|
||||
goss_arch: amd64
|
||||
goss_dst: /usr/local/bin/goss
|
||||
goss_sha256sum: 2f6727375db2ea0f81bee36e2c5be78ab5ab8d5981f632f761b25e4003e190ec
|
||||
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
|
||||
goss_test_directory: /tmp
|
||||
goss_format: documentation
|
||||
tasks:
|
||||
- name: Download and install Goss
|
||||
get_url:
|
||||
url: "{{ goss_url }}"
|
||||
dest: "{{ goss_dst }}"
|
||||
sha256sum: "{{ goss_sha256sum }}"
|
||||
mode: 0755
|
||||
register: download_goss
|
||||
until: download_goss is succeeded
|
||||
retries: 3
|
||||
|
||||
- name: Copy Goss tests to remote
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ goss_test_directory }}/{{ item | basename }}"
|
||||
with_fileglob:
|
||||
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_client*.yml"
|
||||
|
||||
- name: Register test files
|
||||
shell: "ls {{ goss_test_directory }}/test_client*.yml"
|
||||
register: test_files
|
||||
|
||||
- name: Execute Goss tests
|
||||
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
|
||||
register: test_results
|
||||
with_items: "{{ test_files.stdout_lines }}"
|
||||
|
||||
- name: Display details about the Goss results
|
||||
debug:
|
||||
msg: "{{ item.stdout_lines }}"
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Fail when tests fail
|
||||
fail:
|
||||
msg: "Goss failed to validate"
|
||||
when: item.rc != 0
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Verify backup servers
|
||||
hosts: borgbackup_servers
|
||||
become: true
|
||||
vars:
|
||||
goss_version: v0.3.2
|
||||
goss_arch: amd64
|
||||
goss_dst: /usr/local/bin/goss
|
||||
goss_sha256sum: 2f6727375db2ea0f81bee36e2c5be78ab5ab8d5981f632f761b25e4003e190ec
|
||||
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
|
||||
goss_test_directory: /tmp
|
||||
goss_format: documentation
|
||||
tasks:
|
||||
- name: Download and install Goss
|
||||
get_url:
|
||||
url: "{{ goss_url }}"
|
||||
dest: "{{ goss_dst }}"
|
||||
sha256sum: "{{ goss_sha256sum }}"
|
||||
mode: 0755
|
||||
register: download_goss
|
||||
until: download_goss is succeeded
|
||||
retries: 3
|
||||
|
||||
- name: Copy Goss tests to remote
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ goss_test_directory }}/{{ item | basename }}"
|
||||
with_fileglob:
|
||||
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_server*.yml"
|
||||
|
||||
- name: Register test files
|
||||
shell: "ls {{ goss_test_directory }}/test_server*.yml"
|
||||
register: test_files
|
||||
|
||||
- name: Execute Goss tests
|
||||
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
|
||||
register: test_results
|
||||
with_items: "{{ test_files.stdout_lines }}"
|
||||
|
||||
- name: Display details about the Goss results
|
||||
debug:
|
||||
msg: "{{ item.stdout_lines }}"
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Fail when tests fail
|
||||
fail:
|
||||
msg: "Goss failed to validate"
|
||||
when: item.rc != 0
|
||||
with_items: "{{ test_results.results }}"
|
@ -9,6 +9,8 @@ platforms:
|
||||
image: debian:stretch
|
||||
networks:
|
||||
- name: ${MOLECULE_SCENARIO_NAME}-borg
|
||||
groups:
|
||||
- folders
|
||||
- name: ${MOLECULE_SCENARIO_NAME}-sds
|
||||
hostname: ${MOLECULE_SCENARIO_NAME}-sds
|
||||
image: debian:stretch
|
||||
@ -45,6 +47,6 @@ provisioner:
|
||||
scenario:
|
||||
name: folders
|
||||
verifier:
|
||||
name: goss
|
||||
name: testinfra
|
||||
lint:
|
||||
name: yamllint
|
||||
name: flake8
|
||||
|
1
molecule/folders/tests
Symbolic link
1
molecule/folders/tests
Symbolic link
@ -0,0 +1 @@
|
||||
../generic_files/tests
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_all.yml
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_client.yml
|
@ -1,11 +0,0 @@
|
||||
# Molecule managed
|
||||
|
||||
---
|
||||
file:
|
||||
/usr/local/bin/borg-backup:
|
||||
exists: true
|
||||
owner: root
|
||||
group: root
|
||||
contains:
|
||||
- "/var/cache"
|
||||
- "--exclude '/var/cache/apt'"
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_client_restore.yml
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_server.yml
|
@ -1,151 +0,0 @@
|
||||
---
|
||||
# This is an example playbook to execute goss tests.
|
||||
# Tests need distributed to the appropriate ansible host/groups
|
||||
# prior to execution by `goss validate`.
|
||||
|
||||
- name: Verify all
|
||||
hosts: all
|
||||
become: true
|
||||
vars:
|
||||
goss_version: v0.3.2
|
||||
goss_arch: amd64
|
||||
goss_dst: /usr/local/bin/goss
|
||||
goss_sha256sum: 2f6727375db2ea0f81bee36e2c5be78ab5ab8d5981f632f761b25e4003e190ec
|
||||
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
|
||||
goss_test_directory: /tmp
|
||||
goss_format: documentation
|
||||
tasks:
|
||||
- name: Download and install Goss
|
||||
get_url:
|
||||
url: "{{ goss_url }}"
|
||||
dest: "{{ goss_dst }}"
|
||||
sha256sum: "{{ goss_sha256sum }}"
|
||||
mode: 0755
|
||||
register: download_goss
|
||||
until: download_goss is succeeded
|
||||
retries: 3
|
||||
|
||||
- name: Copy Goss tests to remote
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ goss_test_directory }}/{{ item | basename }}"
|
||||
with_fileglob:
|
||||
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_all.yml"
|
||||
|
||||
- name: Register test files
|
||||
shell: "ls {{ goss_test_directory }}/test_all.yml"
|
||||
register: test_files
|
||||
|
||||
- name: Execute Goss tests
|
||||
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
|
||||
register: test_results
|
||||
with_items: "{{ test_files.stdout_lines }}"
|
||||
|
||||
- name: Display details about the Goss results
|
||||
debug:
|
||||
msg: "{{ item.stdout_lines }}"
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Fail when tests fail
|
||||
fail:
|
||||
msg: "Goss failed to validate"
|
||||
when: item.rc != 0
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Verify clients
|
||||
hosts: all:!borgbackup_servers
|
||||
become: true
|
||||
vars:
|
||||
goss_version: v0.3.2
|
||||
goss_arch: amd64
|
||||
goss_dst: /usr/local/bin/goss
|
||||
goss_sha256sum: 2f6727375db2ea0f81bee36e2c5be78ab5ab8d5981f632f761b25e4003e190ec
|
||||
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
|
||||
goss_test_directory: /tmp
|
||||
goss_format: documentation
|
||||
tasks:
|
||||
- name: Download and install Goss
|
||||
get_url:
|
||||
url: "{{ goss_url }}"
|
||||
dest: "{{ goss_dst }}"
|
||||
sha256sum: "{{ goss_sha256sum }}"
|
||||
mode: 0755
|
||||
register: download_goss
|
||||
until: download_goss is succeeded
|
||||
retries: 3
|
||||
|
||||
- name: Copy Goss tests to remote
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ goss_test_directory }}/{{ item | basename }}"
|
||||
with_fileglob:
|
||||
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_client*.yml"
|
||||
|
||||
- name: Register test files
|
||||
shell: "ls {{ goss_test_directory }}/test_client*.yml"
|
||||
register: test_files
|
||||
|
||||
- name: Execute Goss tests
|
||||
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
|
||||
register: test_results
|
||||
with_items: "{{ test_files.stdout_lines }}"
|
||||
|
||||
- name: Display details about the Goss results
|
||||
debug:
|
||||
msg: "{{ item.stdout_lines }}"
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Fail when tests fail
|
||||
fail:
|
||||
msg: "Goss failed to validate"
|
||||
when: item.rc != 0
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Verify backup servers
|
||||
hosts: borgbackup_servers
|
||||
become: true
|
||||
vars:
|
||||
goss_version: v0.3.2
|
||||
goss_arch: amd64
|
||||
goss_dst: /usr/local/bin/goss
|
||||
goss_sha256sum: 2f6727375db2ea0f81bee36e2c5be78ab5ab8d5981f632f761b25e4003e190ec
|
||||
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
|
||||
goss_test_directory: /tmp
|
||||
goss_format: documentation
|
||||
tasks:
|
||||
- name: Download and install Goss
|
||||
get_url:
|
||||
url: "{{ goss_url }}"
|
||||
dest: "{{ goss_dst }}"
|
||||
sha256sum: "{{ goss_sha256sum }}"
|
||||
mode: 0755
|
||||
register: download_goss
|
||||
until: download_goss is succeeded
|
||||
retries: 3
|
||||
|
||||
- name: Copy Goss tests to remote
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ goss_test_directory }}/{{ item | basename }}"
|
||||
with_fileglob:
|
||||
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_server*.yml"
|
||||
|
||||
- name: Register test files
|
||||
shell: "ls {{ goss_test_directory }}/test_server*.yml"
|
||||
register: test_files
|
||||
|
||||
- name: Execute Goss tests
|
||||
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
|
||||
register: test_results
|
||||
with_items: "{{ test_files.stdout_lines }}"
|
||||
|
||||
- name: Display details about the Goss results
|
||||
debug:
|
||||
msg: "{{ item.stdout_lines }}"
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Fail when tests fail
|
||||
fail:
|
||||
msg: "Goss failed to validate"
|
||||
when: item.rc != 0
|
||||
with_items: "{{ test_results.results }}"
|
2
molecule/generic_files/tests/.flake8
Normal file
2
molecule/generic_files/tests/.flake8
Normal file
@ -0,0 +1,2 @@
|
||||
[flake8]
|
||||
ignore = E501
|
6
molecule/generic_files/tests/test_all.py
Normal file
6
molecule/generic_files/tests/test_all.py
Normal file
@ -0,0 +1,6 @@
|
||||
def test_borg_binary(host):
|
||||
borg = host.file("/usr/local/bin/borg")
|
||||
assert borg.exists
|
||||
assert borg.user == "root"
|
||||
assert borg.group == "root"
|
||||
assert borg.mode == 0o755
|
@ -1,9 +0,0 @@
|
||||
# Molecule managed
|
||||
|
||||
---
|
||||
file:
|
||||
/usr/local/bin/borg:
|
||||
exists: true
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
45
molecule/generic_files/tests/test_client.py
Normal file
45
molecule/generic_files/tests/test_client.py
Normal file
@ -0,0 +1,45 @@
|
||||
import os
|
||||
import pytest
|
||||
import re
|
||||
from testinfra.utils.ansible_runner import AnsibleRunner
|
||||
|
||||
testinfra_hosts = ["ansible://all:!borgbackup_servers"]
|
||||
|
||||
|
||||
def test_log(host):
|
||||
logfile = host.file("/var/log/borg-backup.log")
|
||||
assert logfile.contains("Backup succeeded")
|
||||
assert logfile.user == "root"
|
||||
assert logfile.group == "root"
|
||||
|
||||
|
||||
# to do read inventory variable : export BORG_PASSPHRASE="{{ borgbackup_passphrase }}"
|
||||
def test_passphrase(host):
|
||||
pfile = host.file("/root/.borg.passphrase")
|
||||
assert pfile.contains("BORG_PASSPHRASE=")
|
||||
assert pfile.user == "root"
|
||||
assert pfile.group == "root"
|
||||
|
||||
|
||||
@pytest.mark.parametrize('server', AnsibleRunner(os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('borgbackup_servers'))
|
||||
def test_sshconfig(host, server):
|
||||
sshconf = host.file("/root/.ssh/config")
|
||||
assert sshconf.contains(" ANSIBLE MANAGED BLOCK %s " % server)
|
||||
assert sshconf.contains("Host %s" % server)
|
||||
assert sshconf.user == "root"
|
||||
assert sshconf.group == "root"
|
||||
|
||||
|
||||
def test_scriptfile(host):
|
||||
script = host.file("/usr/local/bin/borg-backup")
|
||||
assert script.user == "root"
|
||||
assert script.group == "root"
|
||||
assert script.mode == 0o744
|
||||
|
||||
|
||||
@pytest.mark.parametrize('server', AnsibleRunner(os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('borgbackup_servers'))
|
||||
def test_list_backups(host, server):
|
||||
command = host.run("bash /usr/local/bin/borg-backup list")
|
||||
assert command.rc == 0
|
||||
assert command.stderr == ''
|
||||
assert re.match("Archives on %s :\n[0-9]{8}-[0-9]{4}.*" % server, command.stdout) is not None
|
@ -1,38 +0,0 @@
|
||||
# Molecule managed
|
||||
|
||||
---
|
||||
file:
|
||||
/var/log/borg-backup.log:
|
||||
exists: true
|
||||
owner: root
|
||||
group: root
|
||||
contains:
|
||||
- "Backup succeeded"
|
||||
/root/.borg.passphrase:
|
||||
exists: true
|
||||
owner: root
|
||||
group: root
|
||||
contains:
|
||||
- 'export BORG_PASSPHRASE="{{ borgbackup_passphrase }}"'
|
||||
/root/.ssh/config:
|
||||
exists: true
|
||||
owner: root
|
||||
group: root
|
||||
contains:
|
||||
{% for item in borgbackup_servers %}
|
||||
- 'ANSIBLE MANAGED BLOCK {{ item.fqdn }}'
|
||||
{% endfor %}
|
||||
/usr/local/bin/borg-backup:
|
||||
exists: true
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0744"
|
||||
|
||||
command:
|
||||
bash /usr/local/bin/borg-backup list:
|
||||
exit-status: 0
|
||||
stdout:
|
||||
{% for item in borgbackup_servers %}
|
||||
- "Archives on {{ item.fqdn }}"
|
||||
{% endfor %}
|
||||
- "/[[:digit:]]{8}-[[:digit:]]{4}.*/"
|
9
molecule/generic_files/tests/test_client_folders.py
Normal file
9
molecule/generic_files/tests/test_client_folders.py
Normal file
@ -0,0 +1,9 @@
|
||||
testinfra_hosts = ["ansible://folders"]
|
||||
|
||||
|
||||
def test_include_exclude(host):
|
||||
script = host.file("/usr/local/bin/borg-backup")
|
||||
assert script.contains("/var/cache")
|
||||
assert script.contains("--exclude '/var/cache/apt'")
|
||||
assert script.user == "root"
|
||||
assert script.group == "root"
|
24
molecule/generic_files/tests/test_client_restore.py
Normal file
24
molecule/generic_files/tests/test_client_restore.py
Normal file
@ -0,0 +1,24 @@
|
||||
import os
|
||||
import pytest
|
||||
from testinfra.utils.ansible_runner import AnsibleRunner
|
||||
|
||||
testinfra_hosts = ["ansible://all:!borgbackup_servers"]
|
||||
|
||||
|
||||
def test_client_sample_file(host):
|
||||
sample = host.file("/root/sample.txt")
|
||||
assert sample.is_file
|
||||
|
||||
|
||||
@pytest.mark.parametrize('server', AnsibleRunner(os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('borgbackup_servers'))
|
||||
def test_client_dir(host, server):
|
||||
command = host.run("diff -s /root/sample.txt /root/restore/%s/root/sample.txt" % server)
|
||||
assert command.rc == 0
|
||||
assert "Files /root/sample.txt and /root/restore/%s/root/sample.txt are identical" % server in command.stdout
|
||||
|
||||
|
||||
@pytest.mark.parametrize('server', AnsibleRunner(os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('borgbackup_servers'))
|
||||
def test_client_verify(host, server):
|
||||
vcommand = host.run("/root/restore.sh verify")
|
||||
assert vcommand.rc == 0
|
||||
assert vcommand.stdout.rstrip("verifying on %s" % server)
|
@ -1,18 +0,0 @@
|
||||
---
|
||||
file:
|
||||
/root/sample.txt:
|
||||
exists: true
|
||||
|
||||
command:
|
||||
{% for item in borgbackup_servers %}
|
||||
diff -s /root/sample.txt /root/restore/{{ item.fqdn }}/root/sample.txt:
|
||||
exit-status: 0
|
||||
stdout:
|
||||
- "Files /root/sample.txt and /root/restore/{{ item.fqdn }}/root/sample.txt are identical"
|
||||
{% endfor %}
|
||||
/root/restore.sh verify:
|
||||
exit-status: 0
|
||||
stdout:
|
||||
{% for item in borgbackup_servers %}
|
||||
- "verifying on {{ item.fqdn }}"
|
||||
{% endfor %}
|
16
molecule/generic_files/tests/test_lamp.py
Normal file
16
molecule/generic_files/tests/test_lamp.py
Normal file
@ -0,0 +1,16 @@
|
||||
testinfra_hosts = ["ansible://lamp"]
|
||||
|
||||
|
||||
def test_lamp_default(host):
|
||||
script = host.file("/usr/local/bin/borg-backup")
|
||||
assert script.contains("/usr/sbin/automysqlbackup")
|
||||
assert script.contains("/var/lib/automysqlbackup")
|
||||
assert script.contains("/var/www")
|
||||
assert script.user == "root"
|
||||
assert script.group == "root"
|
||||
|
||||
|
||||
def test_lamp_automysqlbackup(host):
|
||||
backup_dir = host.file("/var/lib/automysqlbackup/daily")
|
||||
assert backup_dir.exists
|
||||
assert backup_dir.is_directory
|
18
molecule/generic_files/tests/test_mgt.py
Normal file
18
molecule/generic_files/tests/test_mgt.py
Normal file
@ -0,0 +1,18 @@
|
||||
import os
|
||||
import pytest
|
||||
from testinfra.utils.ansible_runner import AnsibleRunner
|
||||
|
||||
testinfra_hosts = ["ansible://borgbackup_management"]
|
||||
|
||||
|
||||
# to do read inventory variable : export BORG_PASSPHRASE="{{ borgbackup_passphrase }}"
|
||||
@pytest.mark.parametrize('client', AnsibleRunner(os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all:!borgbackup_management:!borgbackup_servers'))
|
||||
def test_prune_script(host, client):
|
||||
prune = host.file("/root/prune.sh")
|
||||
assert prune.user == "root"
|
||||
assert prune.group == "root"
|
||||
assert prune.mode == 0o700
|
||||
assert prune.contains("/usr/local/bin/borg prune")
|
||||
assert prune.contains("export BORG_PASSPHRASE=")
|
||||
assert prune.contains("Host: %s" % client)
|
||||
assert prune.contains(":/var/backup/repos/%s" % client)
|
23
molecule/generic_files/tests/test_server.py
Normal file
23
molecule/generic_files/tests/test_server.py
Normal file
@ -0,0 +1,23 @@
|
||||
import os
|
||||
import pytest
|
||||
from testinfra.utils.ansible_runner import AnsibleRunner
|
||||
|
||||
testinfra_hosts = ["ansible://borgbackup_servers"]
|
||||
|
||||
|
||||
def test_client_parent_dir(host):
|
||||
parentdir = host.file("/var/backup/repos")
|
||||
assert parentdir.is_directory
|
||||
|
||||
|
||||
@pytest.mark.parametrize('client', AnsibleRunner(os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all:!borgbackup_servers'))
|
||||
def test_client_dir(host, client):
|
||||
clientdir = host.file("/var/backup/repos/%s" % client)
|
||||
assert clientdir.is_directory
|
||||
|
||||
|
||||
@pytest.mark.parametrize('client', AnsibleRunner(os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all:!borgbackup_servers'))
|
||||
def test_ssh_client_conf(host, client):
|
||||
sshconf = host.file("/var/backup/.ssh/authorized_keys")
|
||||
assert sshconf.is_file
|
||||
assert sshconf.contains("%s;borg serve" % client)
|
@ -1,28 +0,0 @@
|
||||
# Molecule managed
|
||||
|
||||
---
|
||||
file:
|
||||
{% for item in borgbackup_servers %}
|
||||
{% if item.fqdn == inventory_hostname %}
|
||||
{{ item.home }}:
|
||||
exists: true
|
||||
owner: "{{ item.user }}"
|
||||
group: "{{ item.user }}"
|
||||
{% for host in groups.all|difference(groups.borgbackup_servers) %}
|
||||
{{ item.home }}/repos/{{ host }}:
|
||||
exists: true
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% for item in borgbackup_servers %}
|
||||
{% if item.fqdn == inventory_hostname %}
|
||||
{{ item.home }}/.ssh/authorized_keys:
|
||||
exists: true
|
||||
owner: "{{ item.user }}"
|
||||
group: "{{ item.user }}"
|
||||
contains:
|
||||
{% for host in groups.all|difference(groups.borgbackup_servers) %}
|
||||
- "{{ host }};borg serve"
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
@ -39,6 +39,6 @@ provisioner:
|
||||
scenario:
|
||||
name: lamp
|
||||
verifier:
|
||||
name: goss
|
||||
name: testinfra
|
||||
lint:
|
||||
name: yamllint
|
||||
name: flake8
|
||||
|
1
molecule/lamp/tests
Symbolic link
1
molecule/lamp/tests
Symbolic link
@ -0,0 +1 @@
|
||||
../generic_files/tests
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_all.yml
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_client.yml
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_client_restore.yml
|
@ -1,17 +0,0 @@
|
||||
# Molecule managed
|
||||
|
||||
---
|
||||
file:
|
||||
/etc/hosts:
|
||||
exists: true
|
||||
owner: root
|
||||
group: root
|
||||
/usr/local/bin/borg-backup:
|
||||
exists: true
|
||||
owner: root
|
||||
group: root
|
||||
contains:
|
||||
- "automysqlbackup"
|
||||
- "/var/www"
|
||||
/var/lib/automysqlbackup/daily:
|
||||
exists: true
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_server.yml
|
@ -1,200 +0,0 @@
|
||||
---
|
||||
# This is an example playbook to execute goss tests.
|
||||
# Tests need distributed to the appropriate ansible host/groups
|
||||
# prior to execution by `goss validate`.
|
||||
|
||||
- name: Verify all
|
||||
hosts: all
|
||||
become: true
|
||||
vars:
|
||||
goss_version: v0.3.2
|
||||
goss_arch: amd64
|
||||
goss_dst: /usr/local/bin/goss
|
||||
goss_sha256sum: 2f6727375db2ea0f81bee36e2c5be78ab5ab8d5981f632f761b25e4003e190ec
|
||||
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
|
||||
goss_test_directory: /tmp
|
||||
goss_format: documentation
|
||||
tasks:
|
||||
- name: Download and install Goss
|
||||
get_url:
|
||||
url: "{{ goss_url }}"
|
||||
dest: "{{ goss_dst }}"
|
||||
sha256sum: "{{ goss_sha256sum }}"
|
||||
mode: 0755
|
||||
register: download_goss
|
||||
until: download_goss is succeeded
|
||||
retries: 3
|
||||
|
||||
- name: Copy Goss tests to remote
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ goss_test_directory }}/{{ item | basename }}"
|
||||
with_fileglob:
|
||||
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_all.yml"
|
||||
|
||||
- name: Register test files
|
||||
shell: "ls {{ goss_test_directory }}/test_all.yml"
|
||||
register: test_files
|
||||
|
||||
- name: Execute Goss tests
|
||||
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
|
||||
register: test_results
|
||||
with_items: "{{ test_files.stdout_lines }}"
|
||||
|
||||
- name: Display details about the Goss results
|
||||
debug:
|
||||
msg: "{{ item.stdout_lines }}"
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Fail when tests fail
|
||||
fail:
|
||||
msg: "Goss failed to validate"
|
||||
when: item.rc != 0
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Verify clients
|
||||
hosts: all:!borgbackup_servers
|
||||
become: true
|
||||
vars:
|
||||
goss_version: v0.3.2
|
||||
goss_arch: amd64
|
||||
goss_dst: /usr/local/bin/goss
|
||||
goss_sha256sum: 2f6727375db2ea0f81bee36e2c5be78ab5ab8d5981f632f761b25e4003e190ec
|
||||
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
|
||||
goss_test_directory: /tmp
|
||||
goss_format: documentation
|
||||
tasks:
|
||||
- name: Download and install Goss
|
||||
get_url:
|
||||
url: "{{ goss_url }}"
|
||||
dest: "{{ goss_dst }}"
|
||||
sha256sum: "{{ goss_sha256sum }}"
|
||||
mode: 0755
|
||||
register: download_goss
|
||||
until: download_goss is succeeded
|
||||
retries: 3
|
||||
|
||||
- name: Copy Goss tests to remote
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ goss_test_directory }}/{{ item | basename }}"
|
||||
with_fileglob:
|
||||
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_client*.yml"
|
||||
|
||||
- name: Register test files
|
||||
shell: "ls {{ goss_test_directory }}/test_client*.yml"
|
||||
register: test_files
|
||||
|
||||
- name: Execute Goss tests
|
||||
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
|
||||
register: test_results
|
||||
with_items: "{{ test_files.stdout_lines }}"
|
||||
|
||||
- name: Display details about the Goss results
|
||||
debug:
|
||||
msg: "{{ item.stdout_lines }}"
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Fail when tests fail
|
||||
fail:
|
||||
msg: "Goss failed to validate"
|
||||
when: item.rc != 0
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Verify lamp clients
|
||||
hosts: lamp
|
||||
become: true
|
||||
vars:
|
||||
goss_version: v0.3.2
|
||||
goss_arch: amd64
|
||||
goss_dst: /usr/local/bin/goss
|
||||
goss_sha256sum: 2f6727375db2ea0f81bee36e2c5be78ab5ab8d5981f632f761b25e4003e190ec
|
||||
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
|
||||
goss_test_directory: /tmp
|
||||
goss_format: documentation
|
||||
tasks:
|
||||
- name: Download and install Goss
|
||||
get_url:
|
||||
url: "{{ goss_url }}"
|
||||
dest: "{{ goss_dst }}"
|
||||
sha256sum: "{{ goss_sha256sum }}"
|
||||
mode: 0755
|
||||
register: download_goss
|
||||
until: download_goss is succeeded
|
||||
retries: 3
|
||||
|
||||
- name: Copy Goss tests to remote
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ goss_test_directory }}/{{ item | basename }}"
|
||||
with_fileglob:
|
||||
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_lamp*.yml"
|
||||
|
||||
- name: Register test files
|
||||
shell: "ls {{ goss_test_directory }}/test_lamp*.yml"
|
||||
register: test_files
|
||||
|
||||
- name: Execute Goss tests
|
||||
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
|
||||
register: test_results
|
||||
with_items: "{{ test_files.stdout_lines }}"
|
||||
|
||||
- name: Display details about the Goss results
|
||||
debug:
|
||||
msg: "{{ item.stdout_lines }}"
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Fail when tests fail
|
||||
fail:
|
||||
msg: "Goss failed to validate"
|
||||
when: item.rc != 0
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Verify backup servers
|
||||
hosts: borgbackup_servers
|
||||
become: true
|
||||
vars:
|
||||
goss_version: v0.3.2
|
||||
goss_arch: amd64
|
||||
goss_dst: /usr/local/bin/goss
|
||||
goss_sha256sum: 2f6727375db2ea0f81bee36e2c5be78ab5ab8d5981f632f761b25e4003e190ec
|
||||
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
|
||||
goss_test_directory: /tmp
|
||||
goss_format: documentation
|
||||
tasks:
|
||||
- name: Download and install Goss
|
||||
get_url:
|
||||
url: "{{ goss_url }}"
|
||||
dest: "{{ goss_dst }}"
|
||||
sha256sum: "{{ goss_sha256sum }}"
|
||||
mode: 0755
|
||||
register: download_goss
|
||||
until: download_goss is succeeded
|
||||
retries: 3
|
||||
|
||||
- name: Copy Goss tests to remote
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ goss_test_directory }}/{{ item | basename }}"
|
||||
with_fileglob:
|
||||
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_server*.yml"
|
||||
|
||||
- name: Register test files
|
||||
shell: "ls {{ goss_test_directory }}/test_server*.yml"
|
||||
register: test_files
|
||||
|
||||
- name: Execute Goss tests
|
||||
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
|
||||
register: test_results
|
||||
with_items: "{{ test_files.stdout_lines }}"
|
||||
|
||||
- name: Display details about the Goss results
|
||||
debug:
|
||||
msg: "{{ item.stdout_lines }}"
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Fail when tests fail
|
||||
fail:
|
||||
msg: "Goss failed to validate"
|
||||
when: item.rc != 0
|
||||
with_items: "{{ test_results.results }}"
|
@ -71,6 +71,6 @@ provisioner:
|
||||
scenario:
|
||||
name: mgt
|
||||
verifier:
|
||||
name: goss
|
||||
name: testinfra
|
||||
lint:
|
||||
name: yamllint
|
||||
name: flake8
|
||||
|
1
molecule/mgt/tests
Symbolic link
1
molecule/mgt/tests
Symbolic link
@ -0,0 +1 @@
|
||||
../generic_files/tests
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_all.yml
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_client.yml
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_client_restore.yml
|
@ -1,16 +0,0 @@
|
||||
# Molecule managed
|
||||
|
||||
---
|
||||
file:
|
||||
/root/prune.sh:
|
||||
exists: true
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0700"
|
||||
contains:
|
||||
{% for host in groups.all|difference(groups.borgbackup_servers) %}
|
||||
- "Host: {{ host }}"
|
||||
- "export BORG_PASSPHRASE={{ borgbackup_passphrase }}"
|
||||
- ":/var/backup/repos/{{ host }}"
|
||||
{% endfor %}
|
||||
- "/usr/local/bin/borg prune"
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_server.yml
|
@ -1,200 +0,0 @@
|
||||
---
|
||||
# This is an example playbook to execute goss tests.
|
||||
# Tests need distributed to the appropriate ansible host/groups
|
||||
# prior to execution by `goss validate`.
|
||||
|
||||
- name: Verify all
|
||||
hosts: all
|
||||
become: true
|
||||
vars:
|
||||
goss_version: v0.3.2
|
||||
goss_arch: amd64
|
||||
goss_dst: /usr/local/bin/goss
|
||||
goss_sha256sum: 2f6727375db2ea0f81bee36e2c5be78ab5ab8d5981f632f761b25e4003e190ec
|
||||
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
|
||||
goss_test_directory: /tmp
|
||||
goss_format: documentation
|
||||
tasks:
|
||||
- name: Download and install Goss
|
||||
get_url:
|
||||
url: "{{ goss_url }}"
|
||||
dest: "{{ goss_dst }}"
|
||||
sha256sum: "{{ goss_sha256sum }}"
|
||||
mode: 0755
|
||||
register: download_goss
|
||||
until: download_goss is succeeded
|
||||
retries: 3
|
||||
|
||||
- name: Copy Goss tests to remote
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ goss_test_directory }}/{{ item | basename }}"
|
||||
with_fileglob:
|
||||
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_all.yml"
|
||||
|
||||
- name: Register test files
|
||||
shell: "ls {{ goss_test_directory }}/test_all.yml"
|
||||
register: test_files
|
||||
|
||||
- name: Execute Goss tests
|
||||
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
|
||||
register: test_results
|
||||
with_items: "{{ test_files.stdout_lines }}"
|
||||
|
||||
- name: Display details about the Goss results
|
||||
debug:
|
||||
msg: "{{ item.stdout_lines }}"
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Fail when tests fail
|
||||
fail:
|
||||
msg: "Goss failed to validate"
|
||||
when: item.rc != 0
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Verify mgt
|
||||
hosts: borgbackup_management
|
||||
become: true
|
||||
vars:
|
||||
goss_version: v0.3.2
|
||||
goss_arch: amd64
|
||||
goss_dst: /usr/local/bin/goss
|
||||
goss_sha256sum: 2f6727375db2ea0f81bee36e2c5be78ab5ab8d5981f632f761b25e4003e190ec
|
||||
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
|
||||
goss_test_directory: /tmp
|
||||
goss_format: documentation
|
||||
tasks:
|
||||
- name: Download and install Goss
|
||||
get_url:
|
||||
url: "{{ goss_url }}"
|
||||
dest: "{{ goss_dst }}"
|
||||
sha256sum: "{{ goss_sha256sum }}"
|
||||
mode: 0755
|
||||
register: download_goss
|
||||
until: download_goss is succeeded
|
||||
retries: 3
|
||||
|
||||
- name: Copy Goss tests to remote
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ goss_test_directory }}/{{ item | basename }}"
|
||||
with_fileglob:
|
||||
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_mgt.yml"
|
||||
|
||||
- name: Register test files
|
||||
shell: "ls {{ goss_test_directory }}/test_mgt.yml"
|
||||
register: test_files
|
||||
|
||||
- name: Execute Goss tests
|
||||
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
|
||||
register: test_results
|
||||
with_items: "{{ test_files.stdout_lines }}"
|
||||
|
||||
- name: Display details about the Goss results
|
||||
debug:
|
||||
msg: "{{ item.stdout_lines }}"
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Fail when tests fail
|
||||
fail:
|
||||
msg: "Goss failed to validate"
|
||||
when: item.rc != 0
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Verify clients
|
||||
hosts: all:!borgbackup_servers
|
||||
become: true
|
||||
vars:
|
||||
goss_version: v0.3.2
|
||||
goss_arch: amd64
|
||||
goss_dst: /usr/local/bin/goss
|
||||
goss_sha256sum: 2f6727375db2ea0f81bee36e2c5be78ab5ab8d5981f632f761b25e4003e190ec
|
||||
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
|
||||
goss_test_directory: /tmp
|
||||
goss_format: documentation
|
||||
tasks:
|
||||
- name: Download and install Goss
|
||||
get_url:
|
||||
url: "{{ goss_url }}"
|
||||
dest: "{{ goss_dst }}"
|
||||
sha256sum: "{{ goss_sha256sum }}"
|
||||
mode: 0755
|
||||
register: download_goss
|
||||
until: download_goss is succeeded
|
||||
retries: 3
|
||||
|
||||
- name: Copy Goss tests to remote
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ goss_test_directory }}/{{ item | basename }}"
|
||||
with_fileglob:
|
||||
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_client*.yml"
|
||||
|
||||
- name: Register test files
|
||||
shell: "ls {{ goss_test_directory }}/test_client*.yml"
|
||||
register: test_files
|
||||
|
||||
- name: Execute Goss tests
|
||||
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
|
||||
register: test_results
|
||||
with_items: "{{ test_files.stdout_lines }}"
|
||||
|
||||
- name: Display details about the Goss results
|
||||
debug:
|
||||
msg: "{{ item.stdout_lines }}"
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Fail when tests fail
|
||||
fail:
|
||||
msg: "Goss failed to validate"
|
||||
when: item.rc != 0
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Verify backup servers
|
||||
hosts: borgbackup_servers
|
||||
become: true
|
||||
vars:
|
||||
goss_version: v0.3.2
|
||||
goss_arch: amd64
|
||||
goss_dst: /usr/local/bin/goss
|
||||
goss_sha256sum: 2f6727375db2ea0f81bee36e2c5be78ab5ab8d5981f632f761b25e4003e190ec
|
||||
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
|
||||
goss_test_directory: /tmp
|
||||
goss_format: documentation
|
||||
tasks:
|
||||
- name: Download and install Goss
|
||||
get_url:
|
||||
url: "{{ goss_url }}"
|
||||
dest: "{{ goss_dst }}"
|
||||
sha256sum: "{{ goss_sha256sum }}"
|
||||
mode: 0755
|
||||
register: download_goss
|
||||
until: download_goss is succeeded
|
||||
retries: 3
|
||||
|
||||
- name: Copy Goss tests to remote
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ goss_test_directory }}/{{ item | basename }}"
|
||||
with_fileglob:
|
||||
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_server*.yml"
|
||||
|
||||
- name: Register test files
|
||||
shell: "ls {{ goss_test_directory }}/test_server*.yml"
|
||||
register: test_files
|
||||
|
||||
- name: Execute Goss tests
|
||||
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
|
||||
register: test_results
|
||||
with_items: "{{ test_files.stdout_lines }}"
|
||||
|
||||
- name: Display details about the Goss results
|
||||
debug:
|
||||
msg: "{{ item.stdout_lines }}"
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Fail when tests fail
|
||||
fail:
|
||||
msg: "Goss failed to validate"
|
||||
when: item.rc != 0
|
||||
with_items: "{{ test_results.results }}"
|
@ -66,6 +66,6 @@ provisioner:
|
||||
scenario:
|
||||
name: multiple
|
||||
verifier:
|
||||
name: goss
|
||||
name: testinfra
|
||||
lint:
|
||||
name: yamllint
|
||||
name: flake8
|
||||
|
1
molecule/multiple/tests
Symbolic link
1
molecule/multiple/tests
Symbolic link
@ -0,0 +1 @@
|
||||
../generic_files/tests
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_all.yml
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_client.yml
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_client_restore.yml
|
@ -1 +0,0 @@
|
||||
../../generic_files/tests/test_server.yml
|
@ -1,151 +0,0 @@
|
||||
---
|
||||
# This is an example playbook to execute goss tests.
|
||||
# Tests need distributed to the appropriate ansible host/groups
|
||||
# prior to execution by `goss validate`.
|
||||
|
||||
- name: Verify all
|
||||
hosts: all
|
||||
become: true
|
||||
vars:
|
||||
goss_version: v0.3.2
|
||||
goss_arch: amd64
|
||||
goss_dst: /usr/local/bin/goss
|
||||
goss_sha256sum: 2f6727375db2ea0f81bee36e2c5be78ab5ab8d5981f632f761b25e4003e190ec
|
||||
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
|
||||
goss_test_directory: /tmp
|
||||
goss_format: documentation
|
||||
tasks:
|
||||
- name: Download and install Goss
|
||||
get_url:
|
||||
url: "{{ goss_url }}"
|
||||
dest: "{{ goss_dst }}"
|
||||
sha256sum: "{{ goss_sha256sum }}"
|
||||
mode: 0755
|
||||
register: download_goss
|
||||
until: download_goss is succeeded
|
||||
retries: 3
|
||||
|
||||
- name: Copy Goss tests to remote
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ goss_test_directory }}/{{ item | basename }}"
|
||||
with_fileglob:
|
||||
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_all.yml"
|
||||
|
||||
- name: Register test files
|
||||
shell: "ls {{ goss_test_directory }}/test_all.yml"
|
||||
register: test_files
|
||||
|
||||
- name: Execute Goss tests
|
||||
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
|
||||
register: test_results
|
||||
with_items: "{{ test_files.stdout_lines }}"
|
||||
|
||||
- name: Display details about the Goss results
|
||||
debug:
|
||||
msg: "{{ item.stdout_lines }}"
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Fail when tests fail
|
||||
fail:
|
||||
msg: "Goss failed to validate"
|
||||
when: item.rc != 0
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Verify clients
|
||||
hosts: all:!borgbackup_servers
|
||||
become: true
|
||||
vars:
|
||||
goss_version: v0.3.2
|
||||
goss_arch: amd64
|
||||
goss_dst: /usr/local/bin/goss
|
||||
goss_sha256sum: 2f6727375db2ea0f81bee36e2c5be78ab5ab8d5981f632f761b25e4003e190ec
|
||||
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
|
||||
goss_test_directory: /tmp
|
||||
goss_format: documentation
|
||||
tasks:
|
||||
- name: Download and install Goss
|
||||
get_url:
|
||||
url: "{{ goss_url }}"
|
||||
dest: "{{ goss_dst }}"
|
||||
sha256sum: "{{ goss_sha256sum }}"
|
||||
mode: 0755
|
||||
register: download_goss
|
||||
until: download_goss is succeeded
|
||||
retries: 3
|
||||
|
||||
- name: Copy Goss tests to remote
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ goss_test_directory }}/{{ item | basename }}"
|
||||
with_fileglob:
|
||||
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_client*.yml"
|
||||
|
||||
- name: Register test files
|
||||
shell: "ls {{ goss_test_directory }}/test_client*.yml"
|
||||
register: test_files
|
||||
|
||||
- name: Execute Goss tests
|
||||
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
|
||||
register: test_results
|
||||
with_items: "{{ test_files.stdout_lines }}"
|
||||
|
||||
- name: Display details about the Goss results
|
||||
debug:
|
||||
msg: "{{ item.stdout_lines }}"
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Fail when tests fail
|
||||
fail:
|
||||
msg: "Goss failed to validate"
|
||||
when: item.rc != 0
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Verify backup servers
|
||||
hosts: borgbackup_servers
|
||||
become: true
|
||||
vars:
|
||||
goss_version: v0.3.2
|
||||
goss_arch: amd64
|
||||
goss_dst: /usr/local/bin/goss
|
||||
goss_sha256sum: 2f6727375db2ea0f81bee36e2c5be78ab5ab8d5981f632f761b25e4003e190ec
|
||||
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
|
||||
goss_test_directory: /tmp
|
||||
goss_format: documentation
|
||||
tasks:
|
||||
- name: Download and install Goss
|
||||
get_url:
|
||||
url: "{{ goss_url }}"
|
||||
dest: "{{ goss_dst }}"
|
||||
sha256sum: "{{ goss_sha256sum }}"
|
||||
mode: 0755
|
||||
register: download_goss
|
||||
until: download_goss is succeeded
|
||||
retries: 3
|
||||
|
||||
- name: Copy Goss tests to remote
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ goss_test_directory }}/{{ item | basename }}"
|
||||
with_fileglob:
|
||||
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_server*.yml"
|
||||
|
||||
- name: Register test files
|
||||
shell: "ls {{ goss_test_directory }}/test_server*.yml"
|
||||
register: test_files
|
||||
|
||||
- name: Execute Goss tests
|
||||
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
|
||||
register: test_results
|
||||
with_items: "{{ test_files.stdout_lines }}"
|
||||
|
||||
- name: Display details about the Goss results
|
||||
debug:
|
||||
msg: "{{ item.stdout_lines }}"
|
||||
with_items: "{{ test_results.results }}"
|
||||
|
||||
- name: Fail when tests fail
|
||||
fail:
|
||||
msg: "Goss failed to validate"
|
||||
when: item.rc != 0
|
||||
with_items: "{{ test_results.results }}"
|
Loading…
Reference in New Issue
Block a user