SALTStack with php

190 views
Skip to first unread message

R

unread,
Jan 31, 2017, 2:35:58 PM1/31/17
to Salt-users
Hi All,

Greetings,

I am novice to SALT. I have installed SALT master and minion (remote host) and was able to execute a Shell script on remote host (minion) successfully. I want to capture the response in a html page for which I have to write a php wrapper.  Could you please help me with a code snippet where with a button click on a php page, triggers the shell scripts to run them on Salt Minions and extract the output back to the browser.. If anybody has done this, I kindly request you to provide me an idea as to how to go about this.

Webpage   -------------------->  Salt Master -----------------------> Salt Minion
                   button click                           shell script execution

Webpage  <----------------------- Salt Master  <------------------------ Salt Minion
                   response(output                      
                    of Shell script)

FYI, I have Apache and php installed on the salt Master.

Thanks in advance
R

Daniel Wallace

unread,
Feb 1, 2017, 11:41:04 AM2/1/17
to salt-...@googlegroups.com
There are a couple api libraries, one for python and one for Java which interact with the salt-api.  https://docs.saltstack.com/en/latest/ref/netapi/all/salt.netapi.rest_cherrypy.html

You could interact with your salt master in the same way and use the api to run commands and query the job cache for the results.

Daniel

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/799150e0-2eaf-42ec-877e-03826d82e6ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

R

unread,
Feb 1, 2017, 8:01:00 PM2/1/17
to Salt-users
Thanks a lot Daniel for the link. I went through the link, I am not very clear how to use it for my need. Could you please let me know how to leverage this api to extract the information from SALT Master and dump it in html. If you can give me a snippet of code I will build on it.

Thanks again


On Wednesday, February 1, 2017 at 8:41:04 AM UTC-8, Daniel Wallace wrote:
There are a couple api libraries, one for python and one for Java which interact with the salt-api.  https://docs.saltstack.com/en/latest/ref/netapi/all/salt.netapi.rest_cherrypy.html

You could interact with your salt master in the same way and use the api to run commands and query the job cache for the results.

Daniel
On Tue, Jan 31, 2017 at 1:26 PM, R <emailn...@gmail.com> wrote:
Hi All,

Greetings,

I am novice to SALT. I have installed SALT master and minion (remote host) and was able to execute a Shell script on remote host (minion) successfully. I want to capture the response in a html page for which I have to write a php wrapper.  Could you please help me with a code snippet where with a button click on a php page, triggers the shell scripts to run them on Salt Minions and extract the output back to the browser.. If anybody has done this, I kindly request you to provide me an idea as to how to go about this.

Webpage   -------------------->  Salt Master -----------------------> Salt Minion
                   button click                           shell script execution

Webpage  <----------------------- Salt Master  <------------------------ Salt Minion
                   response(output                      
                    of Shell script)

FYI, I have Apache and php installed on the salt Master.

Thanks in advance
R

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.

Daniel Wallace

unread,
Feb 2, 2017, 10:53:20 AM2/2/17
to salt-...@googlegroups.com
If you use php-curl, you can make api calls to the salt api to ask for jobs information from the master and then also kick off state runs or other module commands on targeted minions.  I do not know of any examples of this in php, but the php-curl library can do get and post calls to the salt-api, so I would start there.

Daniel

To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/9e1e5e7a-f913-4367-a79f-a18770ebbb6e%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages