.::UPDATE-SOLVED::.
With must assistance form @wirap, it is now working. I've symlinked the script directory into /etc/salt/states/scripts
and using this test.sls
configuration it is now working.
/root/bin/updater/scripts/pam-setup-access:
file.managed:
- name: /tmp/pam-setup-access
- source: salt://scripts/pam-setup-access
- mode: 0700
run_script:
cmd.run:
- name: /tmp/pam-setup-access
file.absent:
- name: /tmp/pam-setup-access
I am new to salt-ssh and looking at some info here regarding how to run a script which resides on my admin box (/root/bin/updater/scripts/pam-setup-access
) on a remote node that I have root access too.
I've created a state
file (below) but not sure where to place it. The salt-ssh docs only mention /etc/salt/master
so I looked that up but those docs seem to be specific for vagrant and package installation.
add script:
file.managed:
- name: pam-setup-access
- source: /root/bin/updater/scripts/pam-setup-access
run script:
cmd.run:
- name: pam-setup-access
Lastly, I tried simply running the state file from the current directory as shown in the first link but I've only annoyed it. What am I missing?
# salt-ssh '*' state.apply test.sls
nod0:
[CRITICAL] Unable to import msgpack or msgpack_pure python modules
Function state.apply is not available
nod1:
[CRITICAL] Unable to import msgpack or msgpack_pure python modules
Function state.apply is not available
.:: UPDATE ::.
I need to use salt-ssh as several "minions" reside on a network separate from the master (DMZ). As I understand, the traditional salt setup requires minions to connect to the salt master.
Since posting, I've installed salt-ssh from the saltstack repo which seems to have gotten rid of the msgpack
error above. I've also modified some of the examples from the vagrant specific link above, adding a master
file and states
directory under /etc/salt
. I've placed the state file (above) under /etc/salt/states/test.sls
. Results are below.
I've added underscores between add script
and run script
, as suggested by @wirap. This has gotten me further as shown below. It seems there is some error involving the script path on the client, or server. Not sure yet. It seems I need to call state.apply
with the name of the .sls
file only (without the .sls extension).
/etc/salt/master:
file_roots:
base:
- /etc/salt/states
When I launch salt-ssh now, I get:
# salt-ssh '*' state.apply test
nod0:
----------
ID: add_script
Function: file.managed
Name: pam-setup-access
Result: False
Comment: Specified file pam-setup-access is not an absolute path
Started: 11:53:50.237379
Duration: 0.602 ms
Changes:
----------
ID: run_script
Function: cmd.run
Name: pam-setup-access
Result: False
Comment: Command "pam-setup-access" run
Started: 11:53:50.238629
Duration: 8.297 ms
Changes:
----------
pid:
1037
retcode:
127
stderr:
/bin/bash: pam-setup-access: command not found
stdout:
Summary for nod0
------------
Succeeded: 0 (changed=1)
Failed: 2
------------
Total states run: 2
Total run time: 8.899 ms
nod1:
----------
ID: add_script
Function: file.managed
Name: pam-setup-access
Result: False
Comment: Specified file pam-setup-access is not an absolute path
Started: 11:53:50.476743
Duration: 0.555 ms
Changes:
----------
ID: run_script
Function: cmd.run
Name: pam-setup-access
Result: False
Comment: Command "pam-setup-access" run
Started: 11:53:50.477906
Duration: 7.5 ms
Changes:
----------
pid:
30772
retcode:
127
stderr:
/bin/bash: pam-setup-access: command not found
stdout:
Summary for nod1
------------
Succeeded: 0 (changed=1)
Failed: 2
------------
Total states run: 2
Total run time: 8.055 ms
Best Answer
add script:
).Extra hints:
Update: When you use file.managed:
source
offile.managed
is the path on your master (relative to your state path), not the target.Example:
is the same as:
https://docs.saltstack.com/en/develop/ref/states/all/salt.states.file.html#module-salt.states.file
The same goes for cmd.run.
Read the general SaltStack tutorial. When you design states it does not matter if you use salt-ssh or salt. Don't let this confuse you.