Saltstack Study Notes (i)

Source: Internet
Author: User
Tags saltstack

Salt Introduction:

Salt (saltstack) is an infrastructure automation and configuration management tool, according to the official documentation, salt is a configuration management system capable of maintaining a remote node to a specified state (for example, to ensure that the specified package is installed and that the specified service is running). And can be distributed on the remote node to execute command and query data.


Installation

This document is Ubuntu 15.10 as test, and master and minion for the same machine

sudo apt-get install Python-software-propertiessudo add-apt-repository ppa:saltstack/saltsudo apt-get Updatesudo Apt-get Install salt-mastersudo apt-get install Salt-minionservice salt-master startservice salt-minion start


Configure Master to be localhost or 127.0.0.1 and restart Minion (you can also configure the ID)

Service Salt-minion Restart

View Salt-key

Salt-key-l

Accept Salt-key

Salt-key-a ' hostname '


Use

Here are some examples of use cases


For Nginx (install Nginx and start service)

Salt ' * ' pkg.install nginxsalt ' * ' Service.start nginx


For VIM (installation)

Salt ' * ' pkg.install vim


List NIC Information

Salt ' * ' network.intgerfaces


Execute shell command

Salt ' * ' cmd.run ' ls-l/etc '


Grains

A salt comes with an interface that can get some information from the bottom


See all grains in Minion

Salt ' * ' grains.ls


List data for grains

Salt ' * ' grains.data


Match all operating systems are CentOS minion, and Ping

Salt-g ' Os:centos ' test.ping


Matches the minion of the 64-bit CPU architecture and returns the core number of the CPU

Salt-g ' cpuarch:x86_64 ' Grains.item Num_cpus


To add new grain data

Open the Minion configuration file

/etc/salt/minion

Search Grains

Grains:roles:-Webserver-memcache Deployment:mydatacenter

You can modify the grain data for your custom

Roles:-Webserver-memcachedeployment:mydatacente

Restart Minion, you can query the master side to the new grains data


Wrong row

View debug information for master and minion

Salt-master-l debugsalt-minion-l Debug


Use the NC command in master to view port information for a Minion connection

Nc-v-Z salt.master.ip 4505nc-v-Z salt.master.ip 4506


Debug information for Salt-call

Salt-call-l Debug State.highstate


Front desk operation

Salt-minion &


Salt validation

List all keys on master

Salt-key-l


Accept all the keys

Slat-key-a


Set the root directory of the salt file

Edit Master configuration file

/etc/salt/master

Add to

Base:-/srv/salt/dev:-/srv/salt/dev/services-/srv/salt/dev/states prod:-/srv/salt/prod/services- /srv/salt/prod/states
/srv/salt/dev/states/srv/salt/dev/pillars


Salt states

Configure the following on master

/srv/salt/top.sls
#Code to add base: ' * ':-Webserve


This article is from the "Linux is belong to You" blog, make sure to keep this source http://jwh5566.blog.51cto.com/7394620/1836566

Saltstack Study Notes (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.