一、建立目錄linux
cd /srv/salt/packagec++
mkdir haproxyvim
mkdir -p haproxy/filesless
mkdir -p haproxy/pkgide
二、編寫依賴包模塊ui
cat pkg/pkg-init.slsspa
pkg-init: 3d
pkg.installed: blog
- names: ssl
- gcc
- gcc-c++
- glibc
- make
- autoconf
- openssl
- openssl-devel
- htop
- vim
- lrzsz
三、安裝包準備
ls -l haproxy/files
-rw-r--r-- 1 root root 1538976 Nov 23 02:16 haproxy-1.6.2.tar.gz
四、啓動腳本獲取
在master端
cp haproxy/files/haproxy-1.6.2.tar.gz /usr/local/src/
cd /usr/local/src
tar xvf haproxy-1.6.2.tar.gz
cd haproxy-1.6.2/examples
sed -i 's/\/usr\/sbin\/'\$BASENAME'/\/usr\/local\/haproxy\/sbin\/'\$BASENAME'/g' haproxy.init
cp haproxy.init /srv/salt/package/haproxy/files/
五、編寫haproxy安裝文件
cat /srv/salt/package/haproxy/init.sls
include:
- package.haproxy.pkg.pkg-init
haproxy_source:
file.managed:
- name: /usr/local/src/haproxy-1.6.2.tar.gz
- source: salt://package/haproxy/files/haproxy-1.6.2.tar.gz
- user: root
- group: root
- mode: 755
cmd.run:
- name: cd /usr/local/src && tar zvxf haproxy-1.6.2.tar.gz && cd haproxy-1.6.2 && make TARGET=linux26 PREFIX=/usr/local/haproxy && make install PREFIX=/usr/local/haproxy
- unless: test -d /usr/local/haproxy
- require:
- file: haproxy_source
haproxy_init:
file.managed:
- name: /usr/lib/systemd/system/haproxy.service
- source: salt://package/haproxy/files/haproxy.init
- user: root
- group: root
- mode: 755
haproxy-config-dir:
file.directory:
- name: /etc/haproxy
- user: root
- group: root
- mode: 755
六、入口文件
cat /srv/salt/package/init.sls
include:
- package.http
- package.haproxy
七、執行
salt 'salt-minion' state.sls package.haproxy
那個錯誤是由於vim已經裝過了
八、檢查minion端
在master使用salt命令檢查: