From f1b657bb1535794886dcf866f06277276a03aaed Mon Sep 17 00:00:00 2001 From: Daniel Dehennin Date: Wed, 18 Aug 2021 11:53:35 +0200 Subject: [PATCH] test(pillar): use static test/salt/pillar/top.sls 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`. --- kitchen.yml | 53 +++------------------------------------- test/salt/pillar/top.sls | 11 +++++++++ 2 files changed, 14 insertions(+), 50 deletions(-) create mode 100644 test/salt/pillar/top.sls diff --git a/kitchen.yml b/kitchen.yml index 2542afc6..6e4e8df4 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -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 diff --git a/test/salt/pillar/top.sls b/test/salt/pillar/top.sls new file mode 100644 index 00000000..aa62ecfb --- /dev/null +++ b/test/salt/pillar/top.sls @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +--- +base: + '*': + - TEMPLATE + - define_roles + 'os_family:Gentoo': + - match: grain + - gentoo +...