Skip to content

Commit

Permalink
test(pillar): use static test/salt/pillar/top.sls
Browse files Browse the repository at this point in the history
The kitchen-salt provisionner have the `pillars_from_directories`
option to recusively copy directories under target pillar root.

This has 3 advantages:

- simplify `kitchen.yml`

- manage pillar assignment with standard salt targetting mechanism,
  this avoid the dedicated `gentoo` suite (it could have been done
  from `kitchen.yml` itself by the way)

- ease the test outside kitchen by running `salt-call` directly with
  `--pillar-root` like:
  ```
  salt-call --local --id test-minion.example.net \
    --file-root=template-formula/ \
    --pillar-root=template-formula/test/salt/pillar/ \
    state.show_sls TEMPLATE
  ```

* test/salt/pillar/top.sls: limit `gentoo` pillars based on `os_family`
  grain.

* kitchen.yml (suites): remove the now useless `gentoo` suite.
  Define an empty required `pillars` to not override static `top.sls`.
  Define `pillars_from_directories` to copy them under `pillar_root`.
  • Loading branch information
baby-gnu committed Aug 18, 2021
1 parent b4b0385 commit f1b657b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 50 deletions.
53 changes: 3 additions & 50 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -429,64 +429,17 @@ verifier:

suites:
- name: default
excludes:
- gentoo-stage3-latest-master-py3
- gentoo-stage3-systemd-master-py3
- gentoo-stage3-latest-3003-1-py3
- gentoo-stage3-systemd-3003-1-py3
- gentoo-stage3-latest-3002-6-py3
- gentoo-stage3-systemd-3002-6-py3
- gentoo-stage3-latest-3001-7-py3
- gentoo-stage3-systemd-3001-7-py3
- gentoo-stage3-latest-3000-9-py3
- gentoo-stage3-systemd-3000-9-py3
provisioner:
state_top:
base:
'*':
- TEMPLATE._mapdata
- TEMPLATE
pillars:
top.sls:
base:
'*':
- TEMPLATE
- define_roles
pillars: {}
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-1-py3
- gentoo-stage3-systemd-3003-1-py3
- gentoo-stage3-latest-3002-6-py3
- gentoo-stage3-systemd-3002-6-py3
- gentoo-stage3-latest-3001-7-py3
- gentoo-stage3-systemd-3001-7-py3
- gentoo-stage3-latest-3000-9-py3
- gentoo-stage3-systemd-3000-9-py3
provisioner:
state_top:
base:
'*':
- TEMPLATE._mapdata
- TEMPLATE
pillars:
top.sls:
base:
'*':
- TEMPLATE
- gentoo
- define_roles
pillars_from_files:
TEMPLATE.sls: pillar.example
gentoo.sls: test/salt/pillar/gentoo.sls
define_roles.sls: test/salt/pillar/define_roles.sls
pillars_from_directories:
- test/salt/pillar
verifier:
inspec_tests:
- path: test/integration/default
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:
'*':
- TEMPLATE
- define_roles
'os_family:Gentoo':
- match: grain
- gentoo
...

0 comments on commit f1b657b

Please sign in to comment.