-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(unattended): add newer options from upstream
* upstream has new options now included in formula * updated pillar.example with new options * inspec tests for this new options are in place Also: * tests are included in travis Signed-off-by: Felipe Zipitria <fzipitria@perceptyx.com>
- Loading branch information
Felipe Zipitria
committed
Dec 18, 2019
1 parent
5178f0d
commit 49ee29c
Showing
8 changed files
with
220 additions
and
11 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
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 @@ | ||
# InSpec Profile: `unattended` | ||
|
||
This shows the implementation of the `unattended` 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 unattended | ||
Summary | ||
------- | ||
Location: unattended | ||
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 unattended | ||
.. | ||
|
||
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 unattended --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,46 @@ | ||
# frozen_string_literal: true | ||
|
||
audit = command( | ||
"/usr/bin/apt-config dump --no-empty --format '%f=%v%n' Unattended-Upgrade" | ||
).stdout | ||
|
||
options = { | ||
assignment_regex: /^\s*([^=]*?)\s*=\s*(.*?)\s*$/, | ||
multiple_values: true | ||
} | ||
|
||
control 'Apt unattended upgrades' do | ||
title 'should be configured' | ||
|
||
describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do | ||
it { should be_file } | ||
it { should be_owned_by 'root' } | ||
it { should be_grouped_into 'root' } | ||
its('mode') { should cmp '0644' } | ||
end | ||
|
||
describe file('/etc/apt/apt.conf.d/10periodic') do | ||
it { should exist } | ||
it { should be_owned_by 'root' } | ||
it { should be_grouped_into 'root' } | ||
its('mode') { should cmp '0644' } | ||
its(:content) do | ||
should match( | ||
'APT::Periodic::Enable "1";' | ||
) | ||
end | ||
end | ||
|
||
describe parse_config(audit, options) do | ||
its('Unattended-Upgrade::Allowed-Origins::') { should include 'origin1' } | ||
its('Unattended-Upgrade::Mail') { should include 'root' } | ||
its('Unattended-Upgrade::MailReport') { should include 'only-on-error' } | ||
its('Unattended-Upgrade::Package-Blacklist::') { should include 'salt-test' } | ||
its('Unattended-Upgrade::Automatic-Reboot') { should include 'False' } | ||
its('Unattended-Upgrade::SyslogEnable') { should include 'True' } | ||
its('Unattended-Upgrade::SyslogFacility') { should include 'auth' } | ||
its('Unattended-Upgrade::Remove-Unused-Dependencies') { should include 'True' } | ||
its('Unattended-Upgrade::Keep-Debs-After-Install') { should include 'False' } | ||
its('Unattended-Upgrade::Update-Days::') { should include 'Wed' } | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=yaml | ||
--- | ||
name: unattended | ||
title: apt formula | ||
maintainer: SaltStack Formulas | ||
license: Apache-2.0 | ||
summary: Verify that the apt unattended preferences are configured correctly | ||
supports: | ||
- platform-name: debian | ||
- platform-name: ubuntu |
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,33 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=yaml | ||
--- | ||
apt: | ||
unattended: | ||
allowed_origins: | ||
- origin1 | ||
package_blacklist: | ||
- salt-test | ||
origins_patterns: | ||
- origin=SaltStack | ||
- origin=Debian,archive=stable,label=Debian-Security | ||
auto_fix_interrupted_dpkg: true | ||
minimal_steps: false | ||
install_on_shutdown: false | ||
mail: root | ||
sender: root | ||
mail_report: 'always' | ||
remove_unused_dependencies: true | ||
automatic_reboot: false | ||
dl_limit: 0 | ||
enabled: 1 | ||
update_package_lists: 1 | ||
download_upgradeable_packages: 1 | ||
unattended_upgrade: 1 | ||
auto_clean_interval: 7 | ||
verbose: 2 | ||
syslog_enable: true | ||
syslog_facility: 'auth' | ||
dpkg_options: '--force-confold' | ||
update_days: ['Mon', 'Wed'] | ||
package_whitelist_strict: false | ||
keep_debs_after_install: false |