From b01f06564f0cebb0715a300d91662767ecc3fb50 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sat, 26 Aug 2023 09:51:03 +0200 Subject: [PATCH] added tests state --- states/tests/custom.sls | 6 ++++++ states/tests/file.sls | 17 +++++++++++++++++ states/tests/mine_test.sls | 19 +++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 states/tests/custom.sls create mode 100644 states/tests/file.sls create mode 100644 states/tests/mine_test.sls diff --git a/states/tests/custom.sls b/states/tests/custom.sls new file mode 100644 index 0000000..692ff28 --- /dev/null +++ b/states/tests/custom.sls @@ -0,0 +1,6 @@ +--- +human_friendly_state_id: + custom.enforce_custom_thing: + - name: Nom + - foo: Valeur + - bar: false diff --git a/states/tests/file.sls b/states/tests/file.sls new file mode 100644 index 0000000..2310375 --- /dev/null +++ b/states/tests/file.sls @@ -0,0 +1,17 @@ +--- +#/tmp/postgresql.conf: +# file.keyvalue: +# - key_values: +# listen_addresses: "'localhost'" +# include: "'test'" +# - separator: ' = ' +# - uncomment: '# ' +# - key_ignore_case: True +# - append_if_not_found: True + +/etc/default/grub: + file.line: + - content: GRUB_CMDLINE_LINUX="texr" + - match: "^GRUB_CMDLINE_LINUX=" + - mode: ensure + - location: end diff --git a/states/tests/mine_test.sls b/states/tests/mine_test.sls new file mode 100644 index 0000000..88bd982 --- /dev/null +++ b/states/tests/mine_test.sls @@ -0,0 +1,19 @@ +{% set minion_ips = salt['mine.get']( + tgt='G@lb:true', + fun='internal_ip_addrs', + tgt_type='compound') %} + +#pkg-repo-test-absent: +# pkgrepo.absent: +# - name: deb http://repository.spotify.com stable non-free + +{% set a = [] %} +{%- for k,v in minion_ips.items() %} +{%- if k != salt['grains.get']('fqdn') %} +{%- for i in v %} +{% set _ = a.append(i) %} +{%- endfor %} +{%- endif %} +{%- endfor %} + +{{ a|sort|unique }}