saltstack seems to be a framework for large-scale, self-motivated operations and cloud management, similar to the SDK, and not just as a tool for puppet. Based on well-designed APIs and clear ideas, Making the salt two development is very easy. Writing very little code can combine the salt with an existing operations system. Saltstack is implemented in Python language, assuming that Saltstack itself is developed for two times, it has to be Python language . The saltstack is made up of several separate modules, These can be used as Saltstack APIs. Then the basic development in the upper layer can be done by invoking the modules of these Saltstack APIs. By importing the appropriate API modules into Python, you can implement the functions you want to implement. Then write your own requirements code. Simple case: Call the API Module of Saltstack. Since Saltstack is implemented in Python, Python's own shell is more dementia than Ubuntu's default VI editor, So install Ipython as a tool to develop Python. Ipython is a python interactive shell with powerful features. Just like Ubuntu installs other software sudo apt-getinstall ipython will be able to install . after the installation is complete, enter the Ipython interface, and then through the Ipython of the completion function, see the salt module such as the following: here to Salt.client as a sample, Describe the call to the API for Saltstack. First into the Ipython interface,importsalt.client (introduced salt.client module) client = salt.client.localclient () (Localclient is a good class at the bottom.) Ret = client.cmd (' 1st ', ' Cmd.run ', [' hostname ']) RET can be used to show the value of hostname on the 1st control side. The specific client module functions are described in this article: Http://docs.saltstack.com/ref/clients/index.html#client-apis then other like the Salt.grains module, is the collection of information modules. Like Introducing grainsmodule, Import salt.grains.core can then call its function functions. SALT.GRAINS.CORE.IP4 () (this is the Echo IP address information, Can be judged by the name of the function) Salt-api in order to quickly integrate Saltstack into a third-party system, the SALT-API module is officially provided. SALT-API is a module interface for Saltstack, which provides a range of interfaces to perform saltstack systems. When Saltstack needs to integrate with a third-party system, it needs to be salt-api to intervene in the middle of the connection. Salt-api as a module interface, so the first is to install the configuration. First install the SALT-API on the Salt-master server. Then configure the Salt-master configuration file, Enable the module that executes the SALT-API. Then install the dynamic link library required for SALT-API or the software you want to execute. Finally, start the SALT-API, and restart all configurations. When configuring the master file for a salt, different software The options you need to configure are different. In the master configuration file, Salt-api provides PAM for authentication and permission partitioning, editing salt master configuration Files /etc/salt/ master , edit external_auth that part, specify the user and the permissions he has . api is to record the authentication information through the cookie, So call must save the cookie, we call the API when the first need authentication, send the request to /login. Simple Case: Here is an example of tornado this webserver. Because this is a python-enabled server. First crossing the network, install the tornado under Ubuntu. And then run. It's very clear, but the details are on their own. Address http:/ opython.com/or on the website to the demo demo Salt-api call. saltstack official has a webui called halite A UI to perform management on the page. The back end is salt-api official website: http://salt-api.readthedocs.org/en/latest/. ButThis last discovery is even more obscure, and the required configuration files are not found at all. Summary through these days of study, find information. The API interface calls that I summarize as saltstack are relatively convenient, the online data is very small, and the SALT-API sample of the official website is relatively general, The online sample is a program that incorporates third parties through SALT-API access to saltstack. Personal Summary: Saltstack is an open source program, so its underlying code is transparent, So we can directly introduce the module of Saltstack API to develop accordingly. But the premise is to understand the function of the corresponding API, without having to delve into how the underlying code class is implemented, but only to know function functions. But in general development, Should not be directly to the Saltstack API call, but through SALT-API as a unified interface access. SALT-API provides the various API interfaces required by Saltstack. About the interface and invocation of the API to Saltstack, These are their own view of the comprehensive collation of information. But there are a lot of problems in the middle, the Internet can not find the answer to the question. You just have to measure it yourself. The official website is very easy to talk about, and it is not very clear. Anyway, Saltstack API interface is provided in the form of various modules, It can be used by Python for development. Then SALT-API as a standalone access module, the equivalent of an SDK environment, greatly simplifying the integration of saltstack into the existing operations environment.
Saltstack API interface and invocation method