-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(inspec): expand unittests for archive format
- Loading branch information
1 parent
1f86f4a
commit b074bd3
Showing
8 changed files
with
173 additions
and
26 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 |
---|---|---|
@@ -1,7 +1,70 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
|
||
{#- Get the `tplroot` from `tpldir` #} | ||
{%- set tplroot = tpldir.split('/')[0] %} | ||
{%- from tplroot ~ "/map.jinja" import golang with context %} | ||
{%- set sls_archive_install = tplroot ~ '.archive.install' %} | ||
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} | ||
{%- if grains.kernel|lower == 'linux' and golang.linux.altpriority|int > 0 %} | ||
include: | ||
- .args | ||
- .file | ||
- .environ | ||
- {{ sls_archive_install }} | ||
golang-package-archive-install-home-alternative-install: | ||
cmd.run: | ||
- name: update-alternatives --install {{ golang.go_root }} golang-home {{ golang.base_dir }}/go {{ golang.linux.altpriority }} | ||
- watch: | ||
- archive: golang-package-archive-install-archive-extracted | ||
- require: | ||
- sls: {{ sls_archive_install }} | ||
- onlyif: {{ grains.os_family in ('Suse',) }} | ||
alternatives.install: | ||
- name: golang-home | ||
- link: {{ golang.go_root }} | ||
- path: {{ golang.base_dir }}/go | ||
- priority: {{ golang.linux.altpriority }} | ||
- order: 10 | ||
- watch: | ||
- archive: golang-package-archive-install-archive-extracted | ||
- unless: {{ grains.os_family in ('Suse',) }} | ||
- require: | ||
- sls: {{ sls_archive_install }} | ||
golang-package-archive-install-home-alternative-set: | ||
alternatives.set: | ||
- name: golang-home | ||
- path: {{ golang.base_dir }}/go | ||
- require: | ||
- alternatives: golang-package-archive-install-home-alternative-install | ||
- unless: {{ grains.os_family in ('Suse',) }} | ||
{% for i in ['go', 'godoc', 'gofmt'] %} | ||
golang-package-archive-install-{{ i }}-alternative-install: | ||
cmd.run: | ||
- name: update-alternatives --install /usr/bin/{{i}} link-{{i}} {{ golang.base_dir }}/go/bin/{{i}} {{golang.linux.altpriority}} | ||
- require: | ||
- cmd: golang-package-archive-install-home-alternative-install | ||
- onlyif: {{ grains.os_family in ('Suse',) }} | ||
alternatives.install: | ||
- name: link-{{ i }} | ||
- link: /usr/bin/{{ i }} | ||
- path: {{ golang.base_dir }}/go/bin/{{ i }} | ||
- priority: {{ golang.linux.altpriority }} | ||
- order: 10 | ||
- require: | ||
- alternatives: golang-package-archive-install-home-alternative-install | ||
- unless: {{ grains.os_family in ('Suse',) }} | ||
golang-package-archive-install-{{ i }}-alternative-set: | ||
alternatives.set: | ||
- name: link-{{ i }} | ||
- path: {{ golang.base_dir }}/go/bin/{{ i }} | ||
- require: | ||
- alternatives: golang-package-archive-install-{{ i }}-alternative-install | ||
- unless: {{ grains.os_family in ('Suse',) }} | ||
{% endfor %} | ||
{%- endif %} |
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 |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
# vim: ft=yaml | ||
--- | ||
prometheus: | ||
dir: | ||
root: /opt | ||
version: '2.10.0' | ||
pkg: | ||
name: prometheus | ||
|
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,50 @@ | ||
# Default InSpec Profile | ||
|
||
This shows the implementation of the Default InSpec [profile](https://github.com/inspec/inspec/blob/master/docs/profiles.md). | ||
|
||
## Verify a profile | ||
|
||
InSpec ships with built-in features to verify a profile structure. | ||
|
||
```bash | ||
$ inspec check default | ||
Summary | ||
------- | ||
Location: default | ||
Profile: profile | ||
Controls: 4 | ||
Timestamp: 2019-06-24T23:09:01+00:00 | ||
Valid: true | ||
|
||
Errors | ||
------ | ||
|
||
Warnings | ||
-------- | ||
``` | ||
|
||
## Execute a profile | ||
|
||
To run all **supported** controls on a local machine use `inspec exec /path/to/profile`. | ||
|
||
```bash | ||
$ inspec exec default | ||
.. | ||
|
||
Finished in 0.0025 seconds (files took 0.12449 seconds to load) | ||
8 examples, 0 failures | ||
``` | ||
|
||
## Execute a specific control from a profile | ||
|
||
To run one control from the profile use `inspec exec /path/to/profile --controls name`. | ||
|
||
```bash | ||
$ inspec exec default --controls package | ||
. | ||
|
||
Finished in 0.0025 seconds (files took 0.12449 seconds to load) | ||
1 examples, 0 failures | ||
``` | ||
|
||
See an [example control here](https://github.com/inspec/inspec/blob/master/examples/profile/controls/example.rb). |
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,12 @@ | ||
control 'template configuration environment' do | ||
title 'should match desired lines' | ||
|
||
describe file('/etc/default/prometheus.sh') do | ||
it { should be_file } | ||
it { should be_owned_by 'root' } | ||
it { should be_grouped_into 'root' } | ||
its('mode') { should cmp '0644' } | ||
its('content') { should include 'Your changes may be overwritten' } | ||
its('content') { should include 'export PATH=${PATH}:/opt/prometheus-2.10.0.linux-amd64' } | ||
end | ||
end |
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