-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #221 from myii/test/manage-map.jinja-verification
test(map): verify `map.jinja` dump using `_mapdata` state
- Loading branch information
Showing
23 changed files
with
3,983 additions
and
9 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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,13 @@ | ||
# yamllint disable rule:indentation rule:line-length | ||
# {{ grains.get('osfinger', grains.os) }} | ||
--- | ||
{#- use salt.slsutil.serialize to avoid encoding errors on some platforms #} | ||
{{ salt['slsutil.serialize']( | ||
'yaml', | ||
map, | ||
default_flow_style=False, | ||
allow_unicode=True, | ||
) | ||
| regex_replace("^\s+'$", "'", multiline=True) | ||
| trim | ||
}} |
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,19 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
--- | ||
{#- Get the `tplroot` from `tpldir` #} | ||
{%- set tplroot = tpldir.split('/')[0] %} | ||
{%- from tplroot ~ "/map.jinja" import php as mapdata with context %} | ||
{%- do salt['log.debug']('### MAP.JINJA DUMP ###\n' ~ mapdata | yaml(False)) %} | ||
{%- set output_dir = '/temp' if grains.os_family == 'Windows' else '/tmp' %} | ||
{%- set output_file = output_dir ~ '/salt_mapdata_dump.yaml' %} | ||
{{ tplroot }}-mapdata-dump: | ||
file.managed: | ||
- name: {{ output_file }} | ||
- source: salt://{{ tplroot }}/_mapdata/_mapdata.jinja | ||
- template: jinja | ||
- context: | ||
map: {{ mapdata | yaml }} |
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,23 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'yaml' | ||
|
||
control '`map.jinja` YAML dump' do | ||
title 'should match the comparison file' | ||
|
||
# Strip the `platform[:finger]` version number down to the "OS major release" | ||
mapdata_file = "_mapdata/#{system.platform[:finger].split('.').first}.yaml" | ||
|
||
# Load the mapdata from profile https://docs.chef.io/inspec/profiles/#profile-files | ||
mapdata_dump = YAML.safe_load(inspec.profile.file(mapdata_file)) | ||
|
||
# Derive the location of the dumped mapdata | ||
output_dir = platform[:family] == 'windows' ? '/temp' : '/tmp' | ||
output_file = "#{output_dir}/salt_mapdata_dump.yaml" | ||
|
||
describe 'File content' do | ||
it 'should match profile map data exactly' do | ||
expect(yaml(output_file).params).to eq(mapdata_dump) | ||
end | ||
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
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
Oops, something went wrong.