1. 程式人生 > >yum安裝salt

yum安裝salt

salt

yum -y install epel-release

主: yum install -y salt-master salt-minion  奴才: yum install -y salt-minion

chkconfig salt-master on  

chkconfig salt-minion on

vim /etc/salt/minion

master: 192.168.106.133(主的ip)

service salt-master start 

service salt-minion start

主: salt-key -a 192*


測試:
[[email protected]
/* */ master]# salt ‘*‘ test.ping 192.168.106.134: True 192.168.106.133: True [[email protected] master]# salt ‘*‘ cmd.run ‘df‘ 192.168.106.134: Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/cl-root 17811456 1394608 16416848 8% / devtmpfs 493192 0 493192 0% /dev tmpfs 504196 12 504184 1% /dev/shm tmpfs 504196 6904 497292 2% /run tmpfs 504196 0 504196 0% /sys/fs/cgroup /dev/sda1 1038336 141744 896592 14% /boot tmpfs 100840 0 100840 0% /run/user/0 192.168.106.133: Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/cl-root 17811456 1395972 16415484 8% / devtmpfs 493192 0 493192 0% /dev tmpfs 504196 16 504180 1% /dev/shm tmpfs 504196 6880 497316 2% /run tmpfs 504196 0 504196 0% /sys/fs/cgroup /dev/sda1 1038336 141744 896592 14% /boot tmpfs 100840 0 100840 0% /run/user/0

使用:

vim /etc/salt/master
file_roots:
  base:
    - /srv/salt
    
mkdir -p /srv/salt

service salt-master restart

vim /srv/salt/apache.sls
apache-install:
  pkg.installed:
    - names:
      - httpd
      - httpd-devel

apache-service:
  service.running:
    - name: httpd
    - enable: True
    - reload: True

    
salt ‘*‘ state.sls apache
192.168.106.134:
----------
          ID: apache-install
    Function: pkg.installed
        Name: httpd
      Result: True
     Comment: Package httpd is already installed.
     Started: 18:00:36.804167
    Duration: 544.478 ms
     Changes:   
----------
          ID: apache-install
    Function: pkg.installed
        Name: httpd-devel
      Result: True
     Comment: Package httpd-devel is already installed.
     Started: 18:00:37.348794
    Duration: 0.355 ms
     Changes:   
----------
          ID: apache-service
    Function: service.running
        Name: httpd
      Result: True
     Comment: Service httpd is already enabled, and is in the desired state
     Started: 18:00:37.349596
    Duration: 151.231 ms
     Changes:   

Summary
------------
Succeeded: 3
Failed:    0
------------
Total states run:     3
192.168.106.133:
----------
          ID: apache-install
    Function: pkg.installed
        Name: httpd
      Result: True
     Comment: Package httpd is already installed.
     Started: 18:00:36.811434
    Duration: 552.655 ms
     Changes:   
----------
          ID: apache-install
    Function: pkg.installed
        Name: httpd-devel
      Result: True
     Comment: Package httpd-devel is already installed.
     Started: 18:00:37.364243
    Duration: 0.372 ms
     Changes:   
----------
          ID: apache-service
    Function: service.running
        Name: httpd
      Result: True
     Comment: Service httpd is already enabled, and is in the desired state
     Started: 18:00:37.365119
    Duration: 151.479 ms
     Changes:   

Summary
------------
Succeeded: 3
Failed:    0
------------
Total states run:     3
[[email protected]
/* */ salt]#


yum安裝salt