From f73f15ec7cb5fab49ff9c03e17e072c48c6d8882 Mon Sep 17 00:00:00 2001 From: Daniel Dehennin Date: Sat, 15 Feb 2020 00:32:39 +0100 Subject: [PATCH] =?UTF-8?q?test(inspec):=20verify=20the=20proper=20loading?= =?UTF-8?q?=20of=20=E2=80=9Cbar=E2=80=9D=20role=20parameters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - we must have a new top level key “added_in_role_bar” - the “winner” key define in role “bar” must be overrode by pillars. --- TEMPLATE/parameters/roles/bar.yaml | 15 +++++++++++++++ pillar.example | 9 +++++++++ test/integration/default/controls/config_spec.rb | 6 ++++++ 3 files changed, 30 insertions(+) create mode 100644 TEMPLATE/parameters/roles/bar.yaml diff --git a/TEMPLATE/parameters/roles/bar.yaml b/TEMPLATE/parameters/roles/bar.yaml new file mode 100644 index 00000000..57402317 --- /dev/null +++ b/TEMPLATE/parameters/roles/bar.yaml @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +# +# Variables specific to the role "bar" looked up with salt['config.get']('roles'). +# +# This is only for demonstration and testing purpose: +# - we test the presence of parameter "added_in_role_bar" and the +# corresponding value +# - we make test that the "winner" parameter is properly overwritten +# by pillar +--- +strategy: 'overwrite' +values: + added_in_role_bar: 'bar_role_value' + winner: 'role bar' diff --git a/pillar.example b/pillar.example index 4583955a..6d7fd863 100644 --- a/pillar.example +++ b/pillar.example @@ -52,6 +52,15 @@ TEMPLATE: TEMPLATE-subcomponent-config-file-file-managed: - 'subcomponent-example.tmpl.jinja' + # Configure map.jinja to load formula parameters values + map: + sources: + - osarch + - os_family + - os + - osfinger + - roles + # Just for testing purposes winner: pillar added_in_pillar: pillar_value diff --git a/test/integration/default/controls/config_spec.rb b/test/integration/default/controls/config_spec.rb index 68b5b4bc..cebbfd1e 100644 --- a/test/integration/default/controls/config_spec.rb +++ b/test/integration/default/controls/config_spec.rb @@ -32,5 +32,11 @@ its('content') { should include '"arch": "amd64"' } its('content') { should include '"winner": "pillar"}' } its('content') { should include 'winner of the merge: pillar' } + its('content') do + should include( + '"map": {"sources": ["osarch", "os_family", "os", "osfinger", "roles"]}' + ) + end + its('content') { should include '"added_in_role_bar": "bar_role_value"' } end end