diff options
author | Georg Pfuetzenreuter | 2023-01-15 09:18:15 +0100 |
---|---|---|
committer | Georg Pfuetzenreuter | 2023-01-15 09:18:15 +0100 |
commit | f1a4b0514c148d9b5477f5c2b11938445e4438b1 (patch) | |
tree | 003745428e583f6d3287f0259040dc1358503505 | |
download | salt-f1a4b0514c148d9b5477f5c2b11938445e4438b1.tar.gz salt-f1a4b0514c148d9b5477f5c2b11938445e4438b1.tar.bz2 salt-f1a4b0514c148d9b5477f5c2b11938445e4438b1.zip |
Init
Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
-rwxr-xr-x | bin/prepare_minion.py | 22 | ||||
-rwxr-xr-x | bin/prepare_mock.py | 13 | ||||
-rwxr-xr-x | bin/roles.py | 13 | ||||
-rw-r--r-- | salt/top.sls | 11 |
4 files changed, 59 insertions, 0 deletions
diff --git a/bin/prepare_minion.py b/bin/prepare_minion.py new file mode 100755 index 0000000..e89434a --- /dev/null +++ b/bin/prepare_minion.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +import roles +import os +import yaml +import socket + +roles = roles.get() +grainsfile = '/etc/salt/grains' +idfile = 'pillar/id/' + socket.gethostname() + '.sls' +mypwd = os.getcwd() + +grainsdata = {'roles': roles} + +with open(grainsfile, mode='w') as grainsfh: + yaml.dump(grainsdata, grainsfh) + +with open(idfile, mode='w') as idfh: + idfh.write('# empty') + +os.symlink(mypwd + '/salt', '/srv/salt') +os.symlink(mypwd + '/pillar', '/srv/pillar') diff --git a/bin/prepare_mock.py b/bin/prepare_mock.py new file mode 100755 index 0000000..982ca32 --- /dev/null +++ b/bin/prepare_mock.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +import os +import shutil +import socket + +iddir = 'pillar/id/' +secretiddir = 'pillar/secret/id/' +baseidfile = 'atvkdev02_home_lysergic_dev.sls' +myidfile = socket.gethostname() + '.sls' + +shutil.copyfile(iddir + baseidfile, iddir + myidfile) +shutil.copyfile(secretiddir + baseidfile, secretiddir + myidfile) diff --git a/bin/roles.py b/bin/roles.py new file mode 100755 index 0000000..1777f8c --- /dev/null +++ b/bin/roles.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +import os + +roles = [] +excluded = ['common-suse', 'minion'] + +def get(): + for file in os.listdir('salt/role'): + role = os.path.splitext(file)[0] + if not role in excluded: + roles.append(role) + return roles diff --git a/salt/top.sls b/salt/top.sls new file mode 100644 index 0000000..de9b24b --- /dev/null +++ b/salt/top.sls @@ -0,0 +1,11 @@ +{% set client_id = salt['grains.get']('id') %} +{% set roles = salt['grains.get']('roles', []) %} + +{{ saltenv }}: + '*': + - baseline + {% for role in roles %} + 'roles:{{ role }}': + - match: grain + - role.{{ role }} + {% endfor %} |