Construction and basic use of saltstack

Source: Internet
Author: User
Tags gpg disk usage metalink saltstack

Saltstack is an automated management tool developed based on the Python language, which is easy to use. Please see Baidu for specific compliments. Saltstack and Puppet, chef and other comparable

Today I share with you the installation deployment and basic usage experience.

Author Environment

Two Test machines

pc1:centos6.5 as Saltstack master node: 192.168.1.111

pc2:centos6.5 as Saltstack minion (slave) node: 192.168.1.115

Since Saltstack is based on Python, it relies on some python packages, and the author has a lot of work to do here, so share it with everyone.

Because of the Saltstack branching feature, first say

=========saltstack's master node ============

Everyone may need to install salt-master before installing Pyyaml. Here the author to provide you with the next Pyyaml installation path

wget ftp://ftp.sunet.se/pub/Linux/distributions/fedora/epel/6/x86_64/PyYAML-3.10-3.el6.x86_64.rpm

Here is the author from saltstack official web download down Epel Source:

[Epel]
Name=extra Packages for Enterprise Linux 6-$basearch
#baseurl =http://download.fedoraproject.org/pub/epel/6/$basearch
Mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch= $basearch
Failovermethod=priority
Enabled=1
Gpgcheck=1
Gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-epel-6

[Epel-debuginfo]
Name=extra Packages for Enterprise Linux 6-$basearch-debug
#baseurl =http://download.fedoraproject.org/pub/epel/6/$basearch/debug
Mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch= $basearch
Failovermethod=priority
Enabled=0
Gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-epel-6
Gpgcheck=1

[Epel-source]
Name=extra Packages for Enterprise Linux 6-$basearch-source
#baseurl =http://download.fedoraproject.org/pub/epel/6/srpms
Mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch= $basearch
Failovermethod=priority
Enabled=0
Gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-epel-6
Gpgcheck=1

If this is true, there should be no need for a direct yum-y install Salt-master.

Master node remember, after installation, check which boot entry is on for the default service

[Email protected] tmp]# Chkconfig--list | grep salt

Here we say, Salt-master and salt-minion communication ports are 4505 and 4506 (default)

4505 the port of the message distribution system for salt

4506 ports for Master and minion-side communication

Confirmation is complete, the service can be started

Chkconfig salt-master on && service salt-master start

Configuration of master node (simple configuration), default location/etc/salt/master

interface:192.168.1.111 # Listening Interface, here the value can be FQDN also can be an IP address

User:root # defines which user to manage

Auto_accept:true # Whether to turn on the automatic receive function, this function can let the Minion node automatically synchronizes the PublicKey to the master node, the default is False, here I manually changed to True. Note that this can be set to true in case of security.

Configuration Complete, restart service

[Email protected] ~]# salt-key-laccepted keys:test1-minion #这里出现了minion中id的信息即为传递成功Unaccepted Keys:

=========saltstack Minion Node ============

The installation configuration from the node needs to execute yum-y install salt-minion, but it is possible to rely on M2crypto this package, the author here to provide you with an address

Http://pkgs.org/centos-6/centos-x86_64/m2crypto-0.20.2-9.el6.x86_64.rpm.html

You can use wget to download, RPM or Yum installation.

No problem, let the Minion node install salt-minion using the Master node's Epel source.

Yum-y Install Salt-minion

The installation completes the check port and whether the boot starts

Service Salt-minion Start

Configuration of the Minion node: (simple configuration) default location/etc/salt/minion

Master:salt # Master node is salt, corresponding to master node
master:192.168.1.111 # The IP address of the master node.

Id:test1-minion # ID is a global ID, the name of the Minion node must be unique, if you do not give default to the FQDN of the server (Baidu search meaning) after the definition for the name, note that in the case of multiple Minion nodes must be unique.

The following are the operations on the master node

Master sends commands to minion

1. Send a ping command to see if the network is unblocked

[[email protected] ~]# Salt ' * ' test.ping
Test1-minion:
True

2. View the disk usage of the Minion node

① [[email protected] ~]# salt  ' * '  cmd.run  ' df -h '       test1-minion:    Filesystem             Size  Used Avail Use% Mounted on     /dev/mapper/vg0-root   20g  445m   19g   3% /     tmpfs                  116m     0  116m   0% /dev/shm     /dev/sda1              194m   30m  155m  16% /boot    /dev/mapper/ vg0-usr   9.9g  2.5g  7.0g  27% /usr     /dev/mapper/vg0-var    20G  578M   19G   4% /var     ②salt  ' * '  disk.usage    [[email protected] ~]# salt  ' * '  disk.usage    test1-minion:    ----------     /:        ----------         1K-blocks:            20642428         available:             19138256        capacity:             3%        filesystem:

.... Space is limited, do not repeat.

3, more useful method salt ' * ' Cmd.run "COMMAND"

Salt here is also the method of invoking the command module, where command is the most commands you execute under the shell command line!

Such as

: [[email protected] ~]# Salt ' * ' Cmd.run "date" test1-minion:

Saltstack's function is still unusually strong, later I will slowly update rich content!

Construction and basic use of saltstack

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.