Skip to content

Commit 79257d5

Browse files
committed
test: standardise use of share suite & _mapdata state [skip ci]
* Automated using myii/ssf-formula#302
1 parent c2e9774 commit 79257d5

File tree

8 files changed

+52
-4
lines changed

8 files changed

+52
-4
lines changed

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Layout/LineLength:
77
# Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`)
88
Max: 88
99
Metrics/BlockLength:
10-
ExcludedMethods:
10+
IgnoredMethods:
1111
- control
1212
- describe
1313
# Increase from default of `25`

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ source 'https://rubygems.org'
55
# Use the latest version of `inspec` prior to `4.23.4`, which introduces a
66
# regression where the diff isn't displayed when comparing using `eq`.
77
gem 'inspec', '~> 4.22.22'
8-
# Install the `kitchen-docker` gem from GitHub because the latest version
8+
# Install the `kitchen-docker` gem using `git` because the latest version
99
# currently available (`2.10.0`) doesn't include a recent fix for Gentoo.
1010
# rubocop:disable Layout/LineLength
1111
gem 'kitchen-docker', git: 'https://gitlab.com/saltstack-formulas/infrastructure/kitchen-docker', branch: 'ssf'

kitchen.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ suites:
367367
state_top:
368368
base:
369369
'*':
370+
- packages._mapdata
370371
- node
371372
- packages
372373
pillars:
@@ -405,6 +406,7 @@ suites:
405406
state_top:
406407
base:
407408
'*':
409+
- packages._mapdata
408410
- golang.package
409411
- packages
410412
pillars:
@@ -429,6 +431,7 @@ suites:
429431
state_top:
430432
base:
431433
'*':
434+
- packages._mapdata
432435
- packages
433436
pillars:
434437
top.sls:
@@ -460,6 +463,7 @@ suites:
460463
state_top:
461464
base:
462465
'*':
466+
- packages._mapdata
463467
- epel
464468
- packages
465469
pillars:
@@ -492,6 +496,7 @@ suites:
492496
state_top:
493497
base:
494498
'*':
499+
- packages._mapdata
495500
- epel
496501
- packages
497502
pillars:
@@ -519,6 +524,7 @@ suites:
519524
state_top:
520525
base:
521526
'*':
527+
- packages._mapdata
522528
- epel
523529
- packages
524530
pillars:
@@ -544,6 +550,7 @@ suites:
544550
state_top:
545551
base:
546552
'*':
553+
- packages._mapdata
547554
- packages
548555
pillars:
549556
top.sls:
@@ -564,6 +571,7 @@ suites:
564571
state_top:
565572
base:
566573
'*':
574+
- packages._mapdata
567575
- packages
568576
pillars:
569577
top.sls:
@@ -589,6 +597,7 @@ suites:
589597
state_top:
590598
base:
591599
'*':
600+
- packages._mapdata
592601
- packages
593602
pillars:
594603
top.sls:

packages/_mapdata/_mapdata.jinja

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# yamllint disable rule:indentation rule:line-length
2+
# {{ grains.get("osfinger", grains.os) }}
3+
---
4+
{#- use salt.slsutil.serialize to avoid encoding errors on some platforms #}
5+
{{ salt["slsutil.serialize"](
6+
"yaml",
7+
map,
8+
default_flow_style=False,
9+
allow_unicode=True,
10+
)
11+
| regex_replace("^\s+'$", "'", multiline=True)
12+
| trim
13+
}}

packages/_mapdata/init.sls

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=sls
3+
---
4+
{#- Get the `tplroot` from `tpldir` #}
5+
{%- set tplroot = tpldir.split("/")[0] %}
6+
{%- from tplroot ~ "/map.jinja" import packages with context %}
7+
8+
{%- set _mapdata = {
9+
"values": packages,
10+
} %}
11+
{%- do salt["log.debug"]("### MAP.JINJA DUMP ###\n" ~ _mapdata | yaml(False)) %}
12+
13+
{%- set output_dir = "/temp" if grains.os_family == "Windows" else "/tmp" %}
14+
{%- set output_file = output_dir ~ "/salt_mapdata_dump.yaml" %}
15+
16+
{{ tplroot }}-mapdata-dump:
17+
file.managed:
18+
- name: {{ output_file }}
19+
- source: salt://{{ tplroot }}/_mapdata/_mapdata.jinja
20+
- template: jinja
21+
- context:
22+
map: {{ _mapdata | yaml }}

test/integration/default/inspec.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ supports:
1717
- platform-name: opensuse
1818
- platform-name: suse
1919
- platform-name: freebsd
20+
- platform-name: openbsd
2021
- platform-name: amazon
2122
- platform-name: oracle
2223
- platform-name: arch

test/integration/share/inspec.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ supports:
1414
- platform-name: opensuse
1515
- platform-name: suse
1616
- platform-name: freebsd
17+
- platform-name: openbsd
1718
- platform-name: amazon
1819
- platform-name: oracle
1920
- platform-name: arch

test/integration/share/libraries/system.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def build_platform_name
3838
case inspec.platform[:name]
3939
when 'amazon', 'oracle'
4040
"#{inspec.platform[:name]}linux"
41-
when 'windows_8.1_pro', 'windows_server_2019_datacenter'
42-
'windows'
41+
when /^windows_/
42+
inspec.platform[:family]
4343
else
4444
inspec.platform[:name]
4545
end
@@ -63,6 +63,8 @@ def build_platform_release
6363
'8.1'
6464
when 'windows_server_2019_datacenter'
6565
'2019-server'
66+
when 'windows_server_2016_datacenter'
67+
'2016-server'
6668
else
6769
inspec.platform[:release]
6870
end

0 commit comments

Comments
 (0)