Skip to content

Commit 78ff678

Browse files
committed
bootstrap.test updates
1 parent 971d323 commit 78ff678

2 files changed

Lines changed: 36 additions & 19 deletions

File tree

bootstrap/pillar.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ bootstrap:
1717
foo: salt://files/foo.deb
1818
baz: ftp://someothersite.org/baz.deb
1919
qux: /minion/path/to/qux.deb
20+
#test:
21+
# resolv: works # just check resolving works, skip checking 8.8.8.8, 8.8.4.4, 1.1.1.1 in resolvers
22+
# skip_domain_in_resolv_conf: True # skip testing resolver domain
2023

2124
files: # optional, see https://github.com/microdevops-com/microdevops-formula/tree/master/_include/file_manager
2225
managed: # recurse|directory|symlink|managed|absent

bootstrap/test.sls

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,52 @@
1-
resolvers_test:
1+
test_resolv:
22
cmd.run:
3+
# If pillar["bootstrap"]["test"]["resolv"] is set to "works", only check resolving works, otherwise check for specific resolvers
4+
{% if pillar["bootstrap"].get("test", {}).get("resolv") == "works" %}
5+
- name: |
6+
ping -c 1 google.com && \
7+
ping -c 1 cloudflare.com
8+
{% else %}
9+
{%- if grains["oscodename"] in ["bionic", "focal", "jammy", "bookworm", "noble", "trixie"] %}
310
- name: |
4-
{% if grains["oscodename"] in ["bionic", "focal", "jammy", "bookworm", "noble", "trixie"] %}
511
grep "nameserver 8.8.8.8" /run/systemd/resolve/resolv.conf && \
612
grep "nameserver 8.8.4.4" /run/systemd/resolve/resolv.conf && \
713
grep "nameserver 1.1.1.1" /run/systemd/resolve/resolv.conf
8-
{% elif grains["oscodename"] == "bullseye" %}
9-
grep "nameserver 1.1.1.1" /etc/resolv.conf
10-
{% elif grains["osfinger"] == "CentOS Linux-7" %}
11-
grep "nameserver 8.8.8.8" /etc/resolv.conf && \
12-
grep "nameserver 8.8.4.4" /etc/resolv.conf && \
13-
grep "nameserver 1.1.1.1" /etc/resolv.conf
14+
{%- endif %}
1415
{% endif %}
1516

16-
full_hostname:
17+
full_hostname_in_hostname:
18+
cmd.run:
19+
- name: |
20+
grep {{ grains["id"] }} /etc/hostname
21+
22+
full_hostname_in_hosts:
23+
cmd.run:
24+
- name: |
25+
grep {{ grains["id"] }} /etc/hosts
26+
27+
full_hostname_hostname_cmd:
28+
cmd.run:
29+
- name: |
30+
hostname | grep {{ grains["id"] }}
31+
32+
full_hostname_hostname_f_cmd:
33+
cmd.run:
34+
- name: |
35+
hostname -f | grep {{ grains["id"] }}
36+
37+
# Skip this if pillar["bootstrap"]["test"]["skip_domain_in_resolv_conf"] is set to True, otherwise check for specific search domain
38+
{% if not pillar["bootstrap"].get("test", {}).get("skip_domain_in_resolv_conf") %}
39+
domain_in_resolv_conf:
1740
cmd.run:
1841
- name: |
19-
grep {{ grains["id"] }} /etc/hostname && \
20-
grep {{ grains["id"] }} /etc/hosts && \
21-
hostname | grep {{ grains["id"] }} && \
22-
hostname -f | grep {{ grains["id"] }} && \
2342
{%- if "domain" in pillar["bootstrap"] %}
2443
grep "search {{ pillar["bootstrap"]["domain"] }}" /etc/resolv.conf
2544
{%- elif "network" in pillar["bootstrap"] and "domain" in pillar["bootstrap"]["network"] %}
2645
grep "search {{ pillar["bootstrap"]["network"]["domain"] }}" /etc/resolv.conf
2746
{%- else %}
2847
grep "search local" /etc/resolv.conf
2948
{%- endif %}
30-
31-
memory_accounting:
32-
cmd.run:
33-
- name: |
34-
grep cgroup_enable=memory /proc/cmdline && \
35-
grep swapaccount=1 /proc/cmdline
49+
{% endif %}
3650

3751
{% if grains["virtual"] == "physical" %}
3852
smartd_test:

0 commit comments

Comments
 (0)