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.
Merge pull request #107 from jaredledvina/feature/fixup-module-tests
Tests: Use filetree to include all module tests
- Loading branch information
Showing
17 changed files
with
200 additions
and
246 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,27 +1,27 @@ | ||
--- | ||
- name: restart sensu-backend | ||
- name: Restart sensu-backend | ||
service: | ||
name: sensu-backend | ||
state: restarted | ||
notify: wait for sensu-backend to accept connections | ||
notify: Wait for sensu-backend to accept connections | ||
when: sensu_go_final_services.backend.state != 'stopped' | ||
|
||
- name: wait for sensu-backend to accept connections | ||
- name: Wait for sensu-backend to accept connections | ||
wait_for: | ||
port: 8081 | ||
connect_timeout: 1 | ||
|
||
- name: restart sensu-agent | ||
- name: Restart sensu-agent | ||
service: | ||
name: sensu-agent | ||
state: restarted | ||
when: sensu_go_final_services.agent.state != 'stopped' | ||
|
||
- name: update apt cache | ||
- name: Update apt cache | ||
apt: | ||
update_cache: true | ||
|
||
- name: yum-clean-metadata | ||
- name: Clean yum metadata | ||
command: yum clean metadata | ||
args: | ||
warn: no |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
--- | ||
- name: Ensure https on http fails | ||
sensu_go_check: | ||
name: check_test | ||
host: localhost | ||
state: present | ||
command: /bin/true | ||
interval: 120 | ||
protocol: https | ||
register: https_on_http | ||
failed_when: https_on_http is not failed | ||
- name: Ensure agent port fails | ||
sensu_go_check: | ||
name: check_test | ||
host: localhost | ||
state: present | ||
command: /bin/true | ||
interval: 120 | ||
port: 8081 | ||
validate_certs: False | ||
register: agent_port | ||
failed_when: agent_port is not failed | ||
- name: Ensure unknown host fails | ||
sensu_go_check: | ||
name: check_test | ||
state: present | ||
command: /bin/true | ||
interval: 120 | ||
host: what.is.this | ||
register: unknown_host | ||
failed_when: unknown_host is not failed | ||
- name: Ensure bad password fails | ||
sensu_go_check: | ||
name: check_test | ||
host: localhost | ||
state: present | ||
command: /bin/true | ||
interval: 120 | ||
password: thisisnottherightpassword | ||
register: bad_password | ||
failed_when: bad_password is not failed | ||
- name: Ensure nonexistant namespace fails | ||
sensu_go_check: | ||
name: check_test | ||
host: localhost | ||
state: present | ||
command: /bin/true | ||
interval: 120 | ||
namespace: thisdoesnotexist | ||
register: bad_namespace | ||
failed_when: bad_namespace is not failed | ||
- name: Ensure interval and cron fails | ||
sensu_go_check: | ||
name: check_test | ||
host: localhost | ||
state: present | ||
command: /bin/true | ||
interval: 120 | ||
cron: "* * * * * *" | ||
register: interval_and_cron | ||
failed_when: interval_and_cron is not failed | ||
- name: Ensure check_example is configured | ||
sensu_go_check: | ||
name: check_example | ||
host: localhost | ||
command: /bin/true | ||
interval: 300 | ||
subscriptions: all | ||
- name: Ensure check_example is already configured | ||
sensu_go_check: | ||
name: check_example | ||
host: localhost | ||
command: /bin/true | ||
interval: 300 | ||
subscriptions: all | ||
register: check_example_already_configured | ||
failed_when: check_example_already_configured is changed | ||
- name: Ensure check_example is changed | ||
sensu_go_check: | ||
name: check_example | ||
host: localhost | ||
command: /bin/true | ||
interval: 120 | ||
timeout: 120 | ||
metadata: | ||
annotations: | ||
ansible_managed: "true" | ||
ttl: 300 | ||
subscriptions: all | ||
- name: Ensure check_example is absent | ||
sensu_go_check: | ||
name: check_example | ||
host: localhost | ||
state: absent | ||
- name: Ensure check_example is already absent | ||
sensu_go_check: | ||
name: check_example | ||
host: localhost | ||
state: absent | ||
register: check_example_is_already_absent | ||
failed_when: check_example_is_already_absent is changed |
Oops, something went wrong.