Skip to content

Commit

Permalink
test(inspec): verify the proper loading of “bar” role parameters
Browse files Browse the repository at this point in the history
- we must have a new top level key “added_in_role_bar”
- the “winner” key define in role “bar” must be overrode by pillars.
  • Loading branch information
baby-gnu committed Feb 14, 2020
1 parent b0a6551 commit f73f15e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions TEMPLATE/parameters/roles/bar.yaml
Original file line number Diff line number Diff line change
@@ -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'
9 changes: 9 additions & 0 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions test/integration/default/controls/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f73f15e

Please sign in to comment.