Georg Pfuetzenreuter
2698d18625
All checks were successful
ci/lysergic/push/pipeline Pipeline was successful
Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
35 lines
1.0 KiB
Python
Executable File
35 lines
1.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Prepares a minion for local testing of Salt code in this repository. Requires roles to be written as grains, as development and pipeline containers generally do not have access to our roles API. Consider nbroles_to_grains.sh first if this is the case.
|
|
|
|
import roles
|
|
import os
|
|
import yaml
|
|
import socket
|
|
|
|
roles = roles.get()
|
|
grainsfile = '/etc/salt/grains'
|
|
idfile = 'pillar/id/' + socket.gethostname() + '.sls'
|
|
configfile = '/etc/salt/minion.d/local.conf'
|
|
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')
|
|
|
|
# to-do: include formulas automatically, maybe from some YAML file?
|
|
with open(configfile, mode='w') as configfh:
|
|
configfh.write('''# written by prepare_minion.py
|
|
file_roots:
|
|
production:
|
|
- /srv/salt
|
|
- /srv/formulas/salt-formula
|
|
- /srv/formulas/users-formula
|
|
''')
|
|
|
|
os.symlink(mypwd + '/salt', '/srv/salt')
|
|
os.symlink(mypwd + '/pillar', '/srv/pillar')
|