docker build -t salt-stack:2017.7.6 .
docker run -it salt-stack:2017.7.6 /bin/bash
-
Salt Master
/master -
Salt API
/master -
Salt Minion
minion1 : /minion1
minion2 : /minion2
minion3 : /minion3 -
Salt Custom Module
/salt_extmods/base/_modules
/salt_extmods/dev/_modules
/salt_extmods/prod/_modules -
Salt Custom State
/salt_extmods/base
/salt_extmods/dev
/salt_extmods/prod -
Salt Custom Pillar
/salt_pillar/base
cd /root
./start_salt_stack.sh
salt '*' cmd.run 'whoami' runas=test
salt -L 'minion1, minion2' cmd.run 'echo TEST'
salt -G 'os:centos' cmd.run 'echo test'
salt '*' grains.ls
salt '*' grains.item os osrelease oscodename
salt minion2 pkg.install httpd
Detailed documentation : https://docs.saltstack.com/en/latest/ref/modules/all/index.html
- Get an authentication token
curl -XPOST localhost:32001/login \
-H 'Content-Type: application/json' \
-d '
{
"eauth": "pam",
"username":"test",
"password":"test"
}
'
{
"return": [
{
"perms": [".*", "@runner"],
"start": 1526355255.599695,
"token": "[TOKEN]",
"expire": 1526398455.599696,
"user": "test",
"eauth": "pam"
}
]
}
- Run 'local' client through API
curl -XPOST localhost:32001/run \
-H 'Content-Type: application/json' \
-H 'X-Auth-Token: [TOKEN]' \
-d '
{
"tgt_type": "glob",
"tgt": "*",
"client":"local",
"fun": "cmd.run",
"arg":["echo whoami", "runas=test"]
}
'
- Run 'local' client, 'list' tgt through API
curl -XPOST localhost:32001/run \
-H 'Content-Type: application/json' \
-H 'X-Auth-Token: [TOKEN]' \
-d '
{
"tgt_type": "list",
"tgt": ["minion1", "minion2"],
"client":"local",
"fun": "cmd.run",
"arg":["echo whoami", "runas=test"]
}
'
- Run 'local_async' client, 'list' tgt through API
curl -XPOST localhost:32001/run \
-H 'Content-Type: application/json' \
-H 'X-Auth-Token: [TOKEN]' \
-d '
{
"tgt_type": "list",
"tgt": ["minion1", "minion2"],
"client":"local_async",
"fun": "cmd.run",
"arg":["echo whoami", "runas=test"]
}
'
{
"return": [
{
"jid": "[JID]",
"minions": ["minion1", "minion2"]
}
]
}
curl -XGET localhost:32001/jobs/[JID] \
-H 'Content-Type: application/json' \
-H 'X-Auth-Token: [TOKEN]'
- Sync 'base' saltenv
salt '*' saltutil.sync_modules
salt '*' saltutil.sync_states
salt '*' saltutil.refresh_pillar
- Sync 'other' saltenv
salt '*' saltutil.sync_modules saltenv=other
salt '*' saltutil.sync_states saltenv=other
salt '*' nhn.test
salt '*' nhn.test_param d=123 a b c
salt '*' nhn.dunder_salt test
salt '*' nhn.dunder_pillar
salt '*' pillar.get location
salt '*' pillar.get pkgs
salt '*' pillar.get pkgs:apache
salt '*' pillar.raw
salt '*' state.apply state_test.run_cmd
salt '*' state.apply state_test.run_cmd pillar='{"pkgs":{"apache":"parameterized pillar"}}'
salt '*' state.apply state_test.apache
salt minion1 schedule.list
salt '*' state.apply state_test.monitor
salt '*' schedule.list
salt minion1 schedule.delete write_to_file
tail -f /tmp/scheduled_writing
salt '*' nhn.test
salt '*' saltutil.sync_modules saltenv=dev
salt '*' nhn.test