Skip to content

Commit

Permalink
Merge pull request #136 from myii/test/standardise-map.jinja-verifica…
Browse files Browse the repository at this point in the history
…tion

test(map): standardise `map.jinja` verification
  • Loading branch information
myii authored Dec 22, 2020
2 parents a0fdc61 + 97ccbb3 commit baf61f9
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
/docs/AUTHORS.rst @saltstack-formulas/ssf
/docs/CHANGELOG.rst @saltstack-formulas/ssf
/docs/TOFS_pattern.rst @saltstack-formulas/ssf
/*/_mapdata/ @saltstack-formulas/ssf
/*/libsaltcli.jinja @saltstack-formulas/ssf
/*/libtofs.jinja @saltstack-formulas/ssf
/test/integration/**/_mapdata_spec.rb @saltstack-formulas/ssf
/test/integration/**/libraries/system.rb @saltstack-formulas/ssf
/test/integration/**/inspec.yml @saltstack-formulas/ssf
/test/integration/**/README.md @saltstack-formulas/ssf
/.gitignore @saltstack-formulas/ssf
Expand Down
26 changes: 26 additions & 0 deletions test/integration/default/files/_mapdata/amazonlinux-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# yamllint disable rule:indentation rule:line-length
# Amazon Linux AMI-2018
---
bin_dir: null
conf_dir: /etc/openvpn
conf_ext: conf
dh_files:
- '512'
dsaparam: false
external_repo_enabled: true
external_repo_supported: []
external_repo_version: stable
group: openvpn
log_user: null
manage_group: true
manage_user: true
multi_services: false
network_manager_pkgs:
- network-manager-openvpn
- network-manager-openvpn-gnome
pkgs:
- openvpn
- openssl
service: openvpn
service_function: running
user: openvpn
26 changes: 26 additions & 0 deletions test/integration/default/files/_mapdata/centos-6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# yamllint disable rule:indentation rule:line-length
# CentOS-6
---
bin_dir: null
conf_dir: /etc/openvpn
conf_ext: conf
dh_files:
- '512'
dsaparam: false
external_repo_enabled: true
external_repo_supported: []
external_repo_version: stable
group: openvpn
log_user: null
manage_group: true
manage_user: true
multi_services: false
network_manager_pkgs:
- network-manager-openvpn
- network-manager-openvpn-gnome
pkgs:
- openvpn
- openssl
service: openvpn
service_function: running
user: openvpn
8 changes: 5 additions & 3 deletions test/integration/share/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ Its goal is to share the libraries between all profiles.
The `system` library provides easy access to system dependent information:

- `system.platform`: based on `inspec.platform`, modify to values that are more consistent from a SaltStack perspective
- `system.platform[:family]` provide a family name for Arch
- `system.platform[:name]` modify `amazon` to `amazonlinux`
- `system.platform[:release]` tweak Arch and Amazon Linux:
- `system.platform[:family]` provide a family name for Arch and Gentoo
- `system.platform[:name]` append `linux` to both `amazon` and `oracle`; ensure Windows platforms are resolved as simply `windows`
- `system.platform[:release]` tweak Arch, Amazon Linux, Gentoo and Windows:
- `Arch` is always `base-latest`
- `Amazon Linux` release `2018` is resolved as `1`
- `Gentoo` release is trimmed to its major version number and then the init system is appended (i.e. `sysv` or `sysd`)
- `Windows` uses the widely-used release number (e.g. `8.1` or `2019-server`) in place of the actual system release version
- `system.platform[:finger]` is the concatenation of the name and the major release number (except for Ubuntu, which gives `ubuntu-20.04` for example)
2 changes: 1 addition & 1 deletion test/integration/share/inspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# vim: ft=yaml
---
name: share
title: openvpn formula
title: InSpec shared resources
maintainer: SaltStack Formulas
license: Apache-2.0
summary: shared resources
Expand Down
14 changes: 6 additions & 8 deletions test/integration/share/libraries/system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,19 @@ def build_platform

def build_platform_family
case inspec.platform[:name]
when 'arch'
'arch'
when 'arch', 'gentoo'
inspec.platform[:name]
else
inspec.platform[:family]
end
end

def build_platform_name
case inspec.platform[:name]
when 'amazon'
'amazonlinux'
when 'windows_8.1_pro'
when 'amazon', 'oracle'
"#{inspec.platform[:name]}linux"
when 'windows_8.1_pro', 'windows_server_2019_datacenter'
'windows'
when 'windows_server_2019_datacenter'
'windows-server'
else
inspec.platform[:name]
end
Expand All @@ -60,7 +58,7 @@ def build_platform_release
when 'windows_8.1_pro'
'8.1'
when 'windows_server_2019_datacenter'
'2019'
'2019-server'
else
inspec.platform[:release]
end
Expand Down

0 comments on commit baf61f9

Please sign in to comment.