File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919/docs /AUTHORS.rst @ saltstack-formulas/ssf
2020/docs /CHANGELOG.rst @ saltstack-formulas/ssf
2121/docs /TOFS_pattern.rst @ saltstack-formulas/ssf
22+ /* /_mapdata / @ saltstack-formulas/ssf
2223/* /libsaltcli.jinja @ saltstack-formulas/ssf
2324/* /libtofs.jinja @ saltstack-formulas/ssf
25+ /test /integration /** /_mapdata_spec.rb @ saltstack-formulas/ssf
26+ /test /integration /** /libraries /system.rb @ saltstack-formulas/ssf
2427/test /integration /** /inspec.yml @ saltstack-formulas/ssf
2528/test /integration /** /README.md @ saltstack-formulas/ssf
2629/.gitignore @ saltstack-formulas/ssf
Original file line number Diff line number Diff line change 33---
44{# - Get the `tplroot` from `tpldir` #}
55{%- set tplroot = tpldir.split(' /' )[0 ] %}
6- {%- from tplroot ~ " /map.jinja" import sudoers with context % }
6+ {%- from tplroot ~ " /map.jinja" import sudoers as mapdata with context % }
77
8- {%- set map = {
9- ' sudoers' : sudoers,
10- } % }
11- {%- do salt[' log.debug' ](' ### MAP.JINJA DUMP ###\n ' ~ map | yaml(False )) % }
8+ {%- do salt[' log.debug' ](' ### MAP.JINJA DUMP ###\n ' ~ mapdata | yaml(False )) % }
129
13- {%- set output_file = ' /tmp/salt_mapdata_dump.yaml' % }
10+ {%- set output_dir = ' /temp' if grains.os_family == ' Windows' else ' /tmp' % }
11+ {%- set output_file = output_dir ~ ' /salt_mapdata_dump.yaml' % }
1412
1513{{ tplroot }}- mapdata- dump:
1614 file .managed:
1715 - name: {{ output_file }}
1816 - source: salt:// {{ tplroot }}/ _mapdata/ _mapdata.jinja
1917 - template: jinja
2018 - context:
21- map : {{ map | yaml }}
19+ map : {{ mapdata | yaml }}
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
3+ require 'yaml'
4+
35control '`map.jinja` YAML dump' do
4- title 'should contain the lines '
6+ title 'should match the comparison file '
57
8+ # Strip the `platform[:finger]` version number down to the "OS major release"
69 mapdata_file = "_mapdata/#{ system . platform [ :finger ] . split ( '.' ) . first } .yaml"
7- mapdata_dump = inspec . profile . file ( mapdata_file )
810
9- describe file ( '/tmp/salt_mapdata_dump.yaml' ) do
10- it { should exist }
11- its ( 'content' ) { should eq mapdata_dump }
11+ # Load the mapdata from profile https://docs.chef.io/inspec/profiles/#profile-files
12+ mapdata_dump = YAML . safe_load ( inspec . profile . file ( mapdata_file ) )
13+
14+ # Derive the location of the dumped mapdata
15+ output_dir = platform [ :family ] == 'windows' ? '/temp' : '/tmp'
16+ output_file = "#{ output_dir } /salt_mapdata_dump.yaml"
17+
18+ describe 'File content' do
19+ it 'should match profile map data exactly' do
20+ expect ( yaml ( output_file ) . params ) . to eq ( mapdata_dump )
21+ end
1222 end
1323end
Original file line number Diff line number Diff line change 22
33This shows the implementation of the ` share ` InSpec [ profile] ( https://github.com/inspec/inspec/blob/master/docs/profiles.md ) .
44
5- It's goal is to share the libraries between all profiles.
5+ Its goal is to share the libraries between all profiles.
66
7- ## Verify a profile
7+ ## Libraries
88
9- InSpec ships with built-in features to verify a profile structure.
9+ ### ` system `
1010
11- ``` bash
12- $ inspec check share
13- Summary
14- -------
15- Location: share
16- Profile: profile
17- Controls: 4
18- Timestamp: 2019-06-24T23:09:01+00:00
19- Valid: true
11+ The ` system ` library provides easy access to system dependent information:
2012
21- Errors
22- ------
23-
24- Warnings
25- --------
26- ```
27-
28- ## Execute a profile
29-
30- To run all ** supported** controls on a local machine use ` inspec exec /path/to/profile ` .
31-
32- ``` bash
33- $ inspec exec share
34- ..
35-
36- Finished in 0.0025 seconds (files took 0.12449 seconds to load)
37- 8 examples, 0 failures
38- ```
13+ - ` system.platform ` : based on ` inspec.platform ` , modify to values that are more consistent from a SaltStack perspective
14+ - ` system.platform[:family] ` provide a family name for Arch and Gentoo
15+ - ` system.platform[:name] ` append ` linux ` to both ` amazon ` and ` oracle ` ; ensure Windows platforms are resolved as simply ` windows `
16+ - ` system.platform[:release] ` tweak Arch, Amazon Linux, Gentoo and Windows:
17+ - ` Arch ` is always ` base-latest `
18+ - ` Amazon Linux ` release ` 2018 ` is resolved as ` 1 `
19+ - ` Gentoo ` release is trimmed to its major version number and then the init system is appended (i.e. ` sysv ` or ` sysd ` )
20+ - ` Windows ` uses the widely-used release number (e.g. ` 8.1 ` or ` 2019-server ` ) in place of the actual system release version
21+ - ` system.platform[:finger] ` is the concatenation of the name and the major release number (except for Ubuntu, which gives ` ubuntu-20.04 ` for example)
Original file line number Diff line number Diff line change 22# vim: ft=yaml
33---
44name : share
5- title : sudoers formula
5+ title : InSpec shared resources
66maintainer : SaltStack Formulas
77license : Apache-2.0
88summary : shared resources
@@ -15,4 +15,7 @@ supports:
1515 - platform-name : suse
1616 - platform-name : freebsd
1717 - platform-name : amazon
18+ - platform-name : oracle
1819 - platform-name : arch
20+ - platform-name : gentoo
21+ - platform : windows
Original file line number Diff line number Diff line change @@ -27,22 +27,25 @@ def build_platform
2727
2828 def build_platform_family
2929 case inspec . platform [ :name ]
30- when 'arch'
31- 'arch'
30+ when 'arch' , 'gentoo'
31+ inspec . platform [ :name ]
3232 else
3333 inspec . platform [ :family ]
3434 end
3535 end
3636
3737 def build_platform_name
3838 case inspec . platform [ :name ]
39- when 'amazon'
40- 'amazonlinux'
39+ when 'amazon' , 'oracle'
40+ "#{ inspec . platform [ :name ] } linux"
41+ when 'windows_8.1_pro' , 'windows_server_2019_datacenter'
42+ 'windows'
4143 else
4244 inspec . platform [ :name ]
4345 end
4446 end
4547
48+ # rubocop:disable Metrics/MethodLength
4649 def build_platform_release
4750 case inspec . platform [ :name ]
4851 when 'amazon'
@@ -52,10 +55,15 @@ def build_platform_release
5255 'base-latest'
5356 when 'gentoo'
5457 "#{ inspec . platform [ :release ] . split ( '.' ) [ 0 ] } -#{ derive_gentoo_init_system } "
58+ when 'windows_8.1_pro'
59+ '8.1'
60+ when 'windows_server_2019_datacenter'
61+ '2019-server'
5562 else
5663 inspec . platform [ :release ]
5764 end
5865 end
66+ # rubocop:enable Metrics/MethodLength
5967
6068 def derive_gentoo_init_system
6169 case inspec . command ( 'systemctl' ) . exist?
You can’t perform that action at this time.
0 commit comments