ansible-role-calibre/molecule/default/verify.yml

60 lines
1.8 KiB
YAML
Raw Permalink Normal View History

2023-06-09 15:41:22 +02:00
---
# 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 calibre
hosts:
- "calibre"
become: true
vars:
goss_version: "v0.3.16"
goss_arch: "amd64"
goss_dst: "/usr/local/bin/goss"
goss_sha256sum: "827e354b48f93bce933f5efcd1f00dc82569c42a179cf2d384b040d8a80bfbfb"
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
goss_test_directory:" /tmp"
goss_format: "documentation"
vars_files:
- ../../defaults/main.yml
tasks:
- name: "CALIBRE | Download and install Goss"
get_url:
url: "{{ goss_url }}"
dest: "{{ goss_dst }}"
checksum: "sha256:{{ goss_sha256sum }}"
mode: 0755
register: "download_goss"
until: "download_goss is succeeded"
retries: 3
- name: "CALIBRE | Copy Goss tests to remote"
template:
src: "{{ item }}"
dest: "{{ goss_test_directory }}/{{ item | basename }}"
with_fileglob:
- "tests/test_*.yml"
- name: "CALIBRE | Register test files"
shell: "ls {{ goss_test_directory }}/test_*.yml"
register: "test_files"
- name: "CALIBRE | Execute Goss tests"
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
register: "test_results"
with_items: "{{ test_files.stdout_lines }}"
ignore_errors: true
- name: "CALIBRE | Display details about the Goss results"
debug:
msg: "{{ item.stdout_lines }}"
with_items: "{{ test_results.results }}"
- name: "CALIBRE | Fail when tests fail"
fail:
msg: "Goss failed to validate"
when: item.rc != 0
with_items: "{{ test_results.results }}"