Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ default-amazonlinux-2-master-py3: {extends: '.test_instance'}
default-oraclelinux-8-master-py3: {extends: '.test_instance'}
default-oraclelinux-7-master-py3: {extends: '.test_instance'}
default-arch-base-latest-master-py3: {extends: '.test_instance'}
gentoo-gentoo-stage3-latest-master-py3: {extends: '.test_instance'}
gentoo-gentoo-stage3-systemd-master-py3: {extends: '.test_instance'}
default-gentoo-stage3-latest-master-py3: {extends: '.test_instance'}
default-gentoo-stage3-systemd-master-py3: {extends: '.test_instance'}
default-almalinux-8-master-py3: {extends: '.test_instance'}
default-rockylinux-8-master-py3: {extends: '.test_instance'}
# default-debian-11-3003-3-py3: {extends: '.test_instance'}
Expand All @@ -217,8 +217,8 @@ default-rockylinux-8-master-py3: {extends: '.test_instance'}
# default-oraclelinux-8-3003-3-py3: {extends: '.test_instance'}
# default-oraclelinux-7-3003-3-py3: {extends: '.test_instance'}
# default-arch-base-latest-3003-3-py3: {extends: '.test_instance'}
# gentoo-gentoo-stage3-latest-3003-3-py3: {extends: '.test_instance'}
# gentoo-gentoo-stage3-systemd-3003-3-py3: {extends: '.test_instance'}
# default-gentoo-stage3-latest-3003-3-py3: {extends: '.test_instance'}
# default-gentoo-stage3-systemd-3003-3-py3: {extends: '.test_instance'}
# default-almalinux-8-3003-3-py3: {extends: '.test_instance'}
# default-debian-11-3002-7-py3: {extends: '.test_instance'}
# default-debian-10-3002-7-py3: {extends: '.test_instance'}
Expand All @@ -236,8 +236,8 @@ default-rockylinux-8-master-py3: {extends: '.test_instance'}
# default-oraclelinux-8-3002-7-py3: {extends: '.test_instance'}
# default-oraclelinux-7-3002-7-py3: {extends: '.test_instance'}
# default-arch-base-latest-3002-7-py3: {extends: '.test_instance'}
# gentoo-gentoo-stage3-latest-3002-7-py3: {extends: '.test_instance'}
# gentoo-gentoo-stage3-systemd-3002-7-py3: {extends: '.test_instance'}
# default-gentoo-stage3-latest-3002-7-py3: {extends: '.test_instance'}
# default-gentoo-stage3-systemd-3002-7-py3: {extends: '.test_instance'}
# default-debian-10-3001-8-py3: {extends: '.test_instance'}
# default-debian-9-3001-8-py3: {extends: '.test_instance'}
# default-ubuntu-2004-3001-8-py3: {extends: '.test_instance'}
Expand All @@ -253,8 +253,8 @@ default-rockylinux-8-master-py3: {extends: '.test_instance'}
# default-oraclelinux-8-3001-8-py3: {extends: '.test_instance'}
# default-oraclelinux-7-3001-8-py3: {extends: '.test_instance'}
# default-arch-base-latest-3001-8-py3: {extends: '.test_instance'}
# gentoo-gentoo-stage3-latest-3001-8-py3: {extends: '.test_instance'}
# gentoo-gentoo-stage3-systemd-3001-8-py3: {extends: '.test_instance'}
# default-gentoo-stage3-latest-3001-8-py3: {extends: '.test_instance'}
# default-gentoo-stage3-systemd-3001-8-py3: {extends: '.test_instance'}

###############################################################################
# `release` stage: `semantic-release`
Expand Down
16 changes: 8 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ jobs:
- env: INSTANCE=default-oraclelinux-8-master-py3
- env: INSTANCE=default-oraclelinux-7-master-py3
- env: INSTANCE=default-arch-base-latest-master-py3
- env: INSTANCE=gentoo-gentoo-stage3-latest-master-py3
- env: INSTANCE=gentoo-gentoo-stage3-systemd-master-py3
- env: INSTANCE=default-gentoo-stage3-latest-master-py3
- env: INSTANCE=default-gentoo-stage3-systemd-master-py3
- env: INSTANCE=default-almalinux-8-master-py3
- env: INSTANCE=default-rockylinux-8-master-py3
# - env: INSTANCE=default-debian-11-3003-3-py3
Expand All @@ -142,8 +142,8 @@ jobs:
# - env: INSTANCE=default-oraclelinux-8-3003-3-py3
# - env: INSTANCE=default-oraclelinux-7-3003-3-py3
# - env: INSTANCE=default-arch-base-latest-3003-3-py3
# - env: INSTANCE=gentoo-gentoo-stage3-latest-3003-3-py3
# - env: INSTANCE=gentoo-gentoo-stage3-systemd-3003-3-py3
# - env: INSTANCE=default-gentoo-stage3-latest-3003-3-py3
# - env: INSTANCE=default-gentoo-stage3-systemd-3003-3-py3
# - env: INSTANCE=default-almalinux-8-3003-3-py3
# - env: INSTANCE=default-debian-11-3002-7-py3
# - env: INSTANCE=default-debian-10-3002-7-py3
Expand All @@ -161,8 +161,8 @@ jobs:
# - env: INSTANCE=default-oraclelinux-8-3002-7-py3
# - env: INSTANCE=default-oraclelinux-7-3002-7-py3
# - env: INSTANCE=default-arch-base-latest-3002-7-py3
# - env: INSTANCE=gentoo-gentoo-stage3-latest-3002-7-py3
# - env: INSTANCE=gentoo-gentoo-stage3-systemd-3002-7-py3
# - env: INSTANCE=default-gentoo-stage3-latest-3002-7-py3
# - env: INSTANCE=default-gentoo-stage3-systemd-3002-7-py3
# - env: INSTANCE=default-debian-10-3001-8-py3
# - env: INSTANCE=default-debian-9-3001-8-py3
# - env: INSTANCE=default-ubuntu-2004-3001-8-py3
Expand All @@ -178,8 +178,8 @@ jobs:
# - env: INSTANCE=default-oraclelinux-8-3001-8-py3
# - env: INSTANCE=default-oraclelinux-7-3001-8-py3
# - env: INSTANCE=default-arch-base-latest-3001-8-py3
# - env: INSTANCE=gentoo-gentoo-stage3-latest-3001-8-py3
# - env: INSTANCE=gentoo-gentoo-stage3-systemd-3001-8-py3
# - env: INSTANCE=default-gentoo-stage3-latest-3001-8-py3
# - env: INSTANCE=default-gentoo-stage3-systemd-3001-8-py3
# <REMOVEME

# Test the conversion of `template-formula` into another formula
Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
/test/integration/**/libraries/system.rb @saltstack-formulas/ssf
/test/integration/**/inspec.yml @saltstack-formulas/ssf
/test/integration/**/README.md @saltstack-formulas/ssf
/test/salt/pillar/top.sls @saltstack-formulas/ssf
/.gitignore @saltstack-formulas/ssf
/.cirrus.yml @saltstack-formulas/ssf
/.gitlab-ci.yml @saltstack-formulas/ssf
Expand Down
50 changes: 2 additions & 48 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ provisioner:
salt_copy_filter:
- .kitchen
- .git
pillars_from_directories:
- test/salt/pillar

platforms:
## SALT `tiamat`
Expand Down Expand Up @@ -373,60 +375,12 @@ verifier:

suites:
- name: default
excludes:
- gentoo-stage3-latest-master-py3
- gentoo-stage3-systemd-master-py3
- gentoo-stage3-latest-3003-3-py3
- gentoo-stage3-systemd-3003-3-py3
- gentoo-stage3-latest-3002-7-py3
- gentoo-stage3-systemd-3002-7-py3
- gentoo-stage3-latest-3001-8-py3
- gentoo-stage3-systemd-3001-8-py3
provisioner:
state_top:
base:
'*':
- TEMPLATE._mapdata
- TEMPLATE
pillars:
top.sls:
base:
'*':
- TEMPLATE
- define_roles
pillars_from_files:
TEMPLATE.sls: pillar.example
define_roles.sls: test/salt/pillar/define_roles.sls
verifier:
inspec_tests:
- path: test/integration/default
- name: gentoo
includes:
- gentoo-stage3-latest-master-py3
- gentoo-stage3-systemd-master-py3
- gentoo-stage3-latest-3003-3-py3
- gentoo-stage3-systemd-3003-3-py3
- gentoo-stage3-latest-3002-7-py3
- gentoo-stage3-systemd-3002-7-py3
- gentoo-stage3-latest-3001-8-py3
- gentoo-stage3-systemd-3001-8-py3
provisioner:
state_top:
base:
'*':
- TEMPLATE._mapdata
- TEMPLATE
pillars:
top.sls:
base:
'*':
- TEMPLATE
- gentoo
- define_roles
Comment on lines -419 to -425
Copy link
Contributor

@myii myii Aug 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably can avoid a dedicated test/salt/pillar/top.sls and just adapt the same method used in other formulas under state_top.

Some examples:

Suggested change
pillars:
top.sls:
base:
'*':
- TEMPLATE
- gentoo
- define_roles
pillars:
top.sls:
base:
'*':
- TEMPLATE
- define_roles
'G@os_family:Gentoo':
- gentoo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, It could be done from kitchen.yml directly but the main point of having a dedicated top.sls is to be able to run it outside kitchen.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baby-gnu I haven't come across this idea before -- could you give me an example of this being run outside of Kitchen? Does this also apply to the using the state_top's top.sls as a separate file as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea came from user colttt on SaltStack matrix room to better validate formula since salt-lint does not cover all possible errors.

colttt uses the following command to compile the states:

salt-call --id=test-minion.example.de --local --file-root=/srv/salt/states --pillar-root=/srv/salt/pillars --retcode-passthrough state.show_sls

But it can't be done easily when the formula requires pillars.

Then, my idea is to provide all the necessary to try out a formula in two steps:

  1. clone the formula:
    git clone https://github.com/saltstack-formulas/template-formula.git && cd template-formula
    
    
  2. execute the formula locally with our test pillar values:
    salt-call --local --id test-minion.example.net --file-root=./ --pillar-root=./test/salt/pillar/ state.show_sls TEMPLATE
    

There is no point in having state_top's top.sls in a dedicated file too since there is no salt-call option to select that file and I think we should avoid having one in the formula directory referenced by the --file-root option above.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baby-gnu The example you've shared doesn't appear to work, because the TEMPLATE pillar (i.e. pillar.example) is not in that directory:

[ERROR   ] Specified SLS 'TEMPLATE' in environment 'base' is not available on the salt master
[ERROR   ] Template was specified incorrectly: False
[CRITICAL] Pillar render error: Specified SLS 'TEMPLATE' in environment 'base' is not available on the salt master
Error running 'state.show_sls': Pillar failed to render. Additional info follows:

- Specified SLS 'TEMPLATE' in environment 'base' is not available on the salt master

If I comment out the TEMPLATE line in the newly provided top.sls, then the state runs -- but obviously missing everything from pillar.example (the TEMPLATE pillar).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's an issue.

To be completely functional, the test/salt/pillar/ should contains all the required files, in which case:

  • the pillars_from_files is no more used
  • the pillar.example is just an example and not a seed for tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I push a second commit to move testing values from pillar.example to test/salt/pillar/TEMPLATE.sls and remove pillars_from_files from kitchen.yml.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baby-gnu If we're going to attempt to use these ideas across existing formulas then that's not going to be fun to refactor. There are more formulas using pillar.example in the CI than any other file. Due to that, it's the default value used from the ssf-formula as well.

We can discuss the relative merits of this idea in the upcoming meeting. I'm still not quite sure what the use cases are so it would great if you could demonstrate it.

pillars_from_files:
TEMPLATE.sls: pillar.example
gentoo.sls: test/salt/pillar/gentoo.sls
define_roles.sls: test/salt/pillar/define_roles.sls
verifier:
inspec_tests:
- path: test/integration/default
21 changes: 4 additions & 17 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
TEMPLATE:
lookup:
master: template-master
# Just for testing purposes
winner: lookup
added_in_lookup: lookup_value

# Using bash package and udev service as an example. This allows us to
# test the template formula itself. You should set these parameters to
Expand All @@ -30,28 +27,18 @@ TEMPLATE:
- osfinger
- os
- os_family

# All aspects of path/file resolution are customisable using the options below.
# This is unnecessary in most cases; there are sensible defaults.
# Default path: salt://< path_prefix >/< dirs.files >/< dirs.default >
# I.e.: salt://TEMPLATE/files/default
# I.e.: salt://TEMPLATE/files/default
# path_prefix: template_alt
# dirs:
# files: files_alt
# default: default_alt
# The entries under `source_files` are prepended to the default source files
# given for the state
# source_files:
# TEMPLATE-config-file-file-managed:
# - 'example_alt.tmpl'
# - 'example_alt.tmpl.jinja'

# For testing purposes
source_files:
TEMPLATE-config-file-file-managed:
- 'example.tmpl.jinja'
TEMPLATE-subcomponent-config-file-file-managed:
- 'subcomponent-example.tmpl.jinja'

# Just for testing purposes
winner: pillar
added_in_pillar: pillar_value
- 'example_alt.tmpl'
- 'example_alt.tmpl.jinja'
57 changes: 57 additions & 0 deletions test/salt/pillar/default.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
TEMPLATE:
lookup:
master: template-master
# Just for testing purposes
winner: lookup
added_in_lookup: lookup_value

# Using bash package and udev service as an example. This allows us to
# test the template formula itself. You should set these parameters to
# examples that make sense in the contexto of the formula you're writing.
pkg:
name: bash
service:
name: systemd-journald
config: /etc/template-formula.conf

tofs:
# The files_switch key serves as a selector for alternative
# directories under the formula files directory. See TOFS pattern
# doc for more info.
# Note: Any value not evaluated by `config.get` will be used literally.
# This can be used to set custom paths, as many levels deep as required.
files_switch:
- any/path/can/be/used/here
- id
- roles
- osfinger
- os
- os_family
# All aspects of path/file resolution are customisable using the options below.
# This is unnecessary in most cases; there are sensible defaults.
# Default path: salt://< path_prefix >/< dirs.files >/< dirs.default >
# I.e.: salt://TEMPLATE/files/default
# path_prefix: template_alt
# dirs:
# files: files_alt
# default: default_alt
# The entries under `source_files` are prepended to the default source files
# given for the state
# source_files:
# TEMPLATE-config-file-file-managed:
# - 'example_alt.tmpl'
# - 'example_alt.tmpl.jinja'

# For testing purposes
source_files:
TEMPLATE-config-file-file-managed:
- 'example.tmpl.jinja'
TEMPLATE-subcomponent-config-file-file-managed:
- 'subcomponent-example.tmpl.jinja'

# Just for testing purposes
winner: pillar
added_in_pillar: pillar_value
11 changes: 11 additions & 0 deletions test/salt/pillar/top.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
base:
'*':
- default
'G@os_family:Gentoo':
- gentoo
'os:*':
- define_roles
...