Reputation: 11
I need to set the saltstack configuration of a salt minion from a salt master. The salt.modules.config
only appears to support getting configuration from the minion.
https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.config.html
salt '*' config.get file_roots
returns the file_roots
from each minion, but surprisingly you can't execute
salt '*' config.set file_roots <custom configuration>
The only solution I can think of is to edit the /etc/salt/minion
file using the salt.states.file
module (https://docs.saltstack.com/en/latest/ref/states/all/salt.states.file.html) and restart the salt-minion
service. However, I have a hunch there is a better solution.
Upvotes: 0
Views: 1236
Reputation: 38777
You should manage the files in /etc/salt/minion.d/
using Salt states.
An example (there are other ways to manage the restart):
/etc/salt/minion.d/default_env.conf:
file.serialize:
- dataset:
saltenv: base
pillarenv_from_saltenv: true
- formatter: yaml
/etc/salt/minion.d/logging.conf:
file.serialize:
- dataset:
log_fmt_console: '[%(levelname)s] %(message)s %(jid)s'
log_fmt_logfile: '%(asctime)s,%(msecs)03d [%(name)-17s][%(levelname)-8s] %(message)s %(jid)s'
logstash_udp_handler:
host: logstash
port: 10514
version: 1
msg_type: saltstack
- formatter: yaml
salt-minion:
service.running:
- enable: true
- watch:
- file: /etc/salt/minion.d/*
Stop state.apply to allow minion restart:
test.fail_without_changes:
- order: 1
- failhard: true
- onchanges:
- service: salt-minion
Upvotes: 0
Reputation: 3959
Yes, Salt can Salt itself!
We use the salt-formula to salt minions. The master might also be salted using this formula.
Upvotes: 0