This repository has been archived by the owner on Jul 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update verify to test custom modules
Updates the verify task to also run any custom module tests to exercise those if included. Currently, this only includes some initial sensu_go_check tasks. Explicitly at the end of the molecule run to ensure we have a fully created sensu-backend/agent/ctl envirnoment that has alraedy passed the Inspec tests. Signed-off-by: Jared Ledvina <jared@techsmix.net>
- Loading branch information
1 parent
9e44f48
commit 2519433
Showing
8 changed files
with
91 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,3 +53,5 @@ verifier: | |
directory: ../shared/ | ||
lint: | ||
name: rubocop | ||
env: | ||
ANSIBLE_LIBRARY: ../../library/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
- name: Install system dependencies for Inspec | ||
package: | ||
name: "{{ item }}" | ||
state: present | ||
with_items: "{{ inspec_package_deps }}" | ||
|
||
- name: Download Inspec | ||
get_url: | ||
url: "{{ inspec_downloads[inspec_version]['url'] }}" | ||
dest: "{{ inspec_download_source_dir }}" | ||
sha256sum: "{{ inspec_downloads[inspec_version]['sha256'] }}" | ||
mode: 0755 | ||
register: inspec_download | ||
|
||
- name: Install Inspec | ||
yum: | ||
name: "{{ inspec_download.dest }}" | ||
state: latest | ||
when: ansible_pkg_mgr == 'yum' | ||
|
||
- name: Install Inspec | ||
dnf: | ||
name: "{{ inspec_download.dest }}" | ||
state: latest | ||
when: ansible_pkg_mgr == 'dnf' | ||
|
||
- name: Install Inspec | ||
apt: | ||
deb: "{{ inspec_download.dest }}" | ||
state: present | ||
when: ansible_pkg_mgr == 'apt' | ||
|
||
- name: Create Molecule directory for test files | ||
file: | ||
path: "{{ inspec_test_directory }}" | ||
state: directory | ||
|
||
- name: Copy Inspec tests to remote | ||
copy: | ||
src: "{{ item }}" | ||
dest: "{{ inspec_test_directory }}/{{ item | basename }}" | ||
with_fileglob: | ||
- "{{ playbook_dir }}/tests/test_*.rb" | ||
|
||
- name: Register test files | ||
shell: "ls {{ inspec_test_directory }}/test_*.rb" | ||
register: test_files | ||
|
||
- name: Execute Inspec tests | ||
command: "{{ inspec_bin }} exec --chef-license accept {{ item }} --no-color --reporter progress" | ||
register: test_results | ||
with_items: "{{ test_files.stdout_lines }}" | ||
ignore_errors: true | ||
|
||
- name: Display details about the Inspec results | ||
debug: | ||
msg: "{{ item.stdout_lines }}" | ||
with_items: "{{ test_results.results }}" | ||
|
||
- name: Fail when tests fail | ||
fail: | ||
msg: "Inspec failed to validate" | ||
when: item.rc != 0 | ||
with_items: "{{ test_results.results }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
# Debian Specific Things | ||
if os.debian? | ||
describe package('curl') do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters