首页 > 代码库 > saltstack-haproxy安装

saltstack-haproxy安装

1、创建目录

cd /srv/salt/package

mkdir haproxy

mkdir -p haproxy/files

mkdir -p haproxy/pkg

技术分享


2、编写依赖包模块

cat pkg/pkg-init.sls

pkg-init:               

  pkg.installed:        

    - names:            

      - gcc

      - gcc-c++

      - glibc

      - make

      - autoconf

      - openssl

      - openssl-devel

      - htop

      - vim

      - lrzsz

技术分享


3、安装包准备

ls -l haproxy/files

-rw-r--r-- 1 root root 1538976 Nov 23 02:16 haproxy-1.6.2.tar.gz

技术分享


4、启动脚本获取

在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/


5、编写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

技术分享


6、入口文件

cat /srv/salt/package/init.sls

include:

  - package.http

  - package.haproxy

技术分享


7、执行

salt ‘salt-minion‘ state.sls package.haproxy

技术分享

技术分享

那个错误是因为vim已经装过了

技术分享


8、检查minion端

在master使用salt命令检查:

技术分享

技术分享




本文出自 “Linux” 博客,请务必保留此出处http://syklinux.blog.51cto.com/9631548/1893415

saltstack-haproxy安装