saltstack-install-config-basic-command-helloworld

=

=

=

 
# centos, source preparation: use Alibaba Cloud's source
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
yum clean all && yum makecache
 
#install saltstack
        #salt-masterinstallation
        rpm -ivh salt-repo-latest-2.el6.noarch.rpm
        yum install -y python
        yum install -y salt-master
 
        #salt-minioninstallation
        rpm -ivh salt-repo-latest-2.el6.noarch.rpm
        yum install -y python
        yum install -y salt-minion
Note: If https cannot be downloaded, you need to change it to http download; at the same time, you need to modify the .repo file and change the https to http. See the previous article for details.
 
#Modify the configuration file
salt-master does not need to modify the configuration file;
salt-ninion needs to modify the configuration file:
vi / etc / salt / minion
Modification 1:
#master: salt 
#Change the salt string to the ip address of the salt-master
Modification 2:
#id:
#Set the minion's id logo after the colon; in fact, it can be left unset, so the host and other signs are used, which requires management specifications, such as more standardized machine naming, etc.;
 
#Add a minion node to the master, use the salt-key command
[root@june-test-10 june]# salt-key -L
Accepted Keys:
Denied Keys:
Unaccepted Keys:
june-test-11
june-test-12
Rejected Keys:
 
[root@june-test-10 june]# salt-key -A
The following keys are going to be accepted:
Unaccepted Keys:
june-test-11
june-test-12
proceed? [n/Y] AND
Key for minion june-test-11 accepted.
Key for minion june-test-12 accepted.
 
[root@june-test-10 june]# salt-key -L
Accepted Keys:
june-test-11
june-test-12
 
#Test the ping command to ensure that the master and minion are connected
[root@june-test-10 june]# salt "*" test.ping
june-test-12:
    True
june-test-11:
    True
 
#Execute command remotely:
[root@june-test-10 june]# salt '*' cmd.run 'uptime'
june-test-12:
     11:31:10 up 2 days,  1:04,  1 user,  load average: 0.00, 0.00, 0.00
june-test-11:
     11:31:10 up 2 days,  1:03,  1 user,  load average: 0.00, 0.00, 0.00
 
[root@june-test-10 june]# salt '*' cmd.run 'uptime'
june-test-12:
     11:31:10 up 2 days,  1:04,  1 user,  load average: 0.00, 0.00, 0.00
june-test-11:
     11:31:10 up 2 days,  1:03,  1 user,  load average: 0.00, 0.00, 0.00
 
[root@june-test-10 june]# salt '*' grains.item os
june-test-11:
    ----------
    you:
        CentOS
june-test-12:
    ----------
    you:
        CentOS
 
[root@june-test-10 june]# salt '*' cmd.exec_code python 'import sys; print sys.version'
june-test-12:
    2.6.6 (r266: 84292, Aug 18 2016, 15:13:37)
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
june-test-11:
    2.6.6 (r266: 84292, Aug 18 2016, 15:13:37)
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
 

=

=

=

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326176933&siteId=291194637