Saltstack Configuration management function Module-haproxy

Source: Internet
Author: User
Tags haproxy saltstack

[Email protected] base]# mkdir/srv/salt/prod/pkg

[Email protected] base]# Mkdir/srv/salt/prod/haproxy

[Email protected] base]# Mkdir/srv/salt/prod/haproxy/files

[Email protected] base]# Cd/srv/salt/prod/haproxy/files

[Email protected] files]# rz-y

RZ waiting to receive.

Starting Zmodem transfer. Press CTRL + C to cancel.

Transferring haproxy-1.6.2.tar.gz ...

100% 1502 KB 1502 kb/sec 00:00:01 0 Errors


[[email protected] files]# ls

Haproxy-1.6.2.tar.gz

[[email protected] files]# cp haproxy-1.6.2.tar.gz/usr/local/src/=========================> copy files to/usr/loc AL/SRC below


[Email protected] base]# cd/srv/salt/prod/pkg/

[Email protected] base]# vim Pkg-init.sls

[[email protected] pkg]# Cat/srv/salt/prod/pkg/pkg-init.sls ================================> first need to install The following dependent packages

Pkg-init:

Pkg.installed:

-Names:

-GCC

-Gcc-c++

-GLIBC

-Make

-Autoconf

-OpenSSL

-Openssl-devel


[[email protected] files]# Salt ' * ' State.sls pkg.pkg-init env=prod ============================> execution status, installation according to Lai Bao


Installation Steps log:

cd/usr/local/src/

Tar XF haproxy-1.6.2.tar.gz

CD haproxy-1.6.2

Make target=linux26 prefix=/usr/local/haproxy && make install Prefix=/usr/local/haproxy


[Email protected] haproxy]# pwd

/srv/salt/prod/haproxy


[[email protected] haproxy]# ls

Files Install.sls


[email protected] haproxy]# cat Install.sls

Include

-Pkg.pkg-init ################ #先包含之前安装的依赖包 ####################


Haproxy-install: ########## #安装haproxy程序 ############

File.managed:

-Name:/usr/local/src/haproxy-1.6.2.tar.gz

-Source:salt://haproxy/files/haproxy-1.6.2.tar.gz

-User:root

-Group:root

-mode:755

Cmd.run:

-name:cd/usr/local/src/&& Tar XF haproxy-1.6.2.tar.gz && cd haproxy-1.6.2 && make Target=linux Prefix=/usr/local/haproxy && make install Prefix=/usr/local/haproxy

-unless:test-d/usr/local/haproxy ##### #判断一个目录是否存在 #########

-Require: ########## #检查依赖 ###########

-Pkg:pkg-init ######### #此处指明依赖哪个模块 ########

-File:haproxy-install ###### #一个id下一个模块只能用一次 #########



Haproxy-init:

File.managed: ######## #文件管理模块与方法 ###########

-Name:/etc/init.d/haproxy

-Source:salt://haproxy/files/haproxy.init ######### #启动脚本的位置 ###########

-User:root

-Group:root

-mode:755

-Require: ############# #检测依赖 ###############

-Cmd:haproxy-install ########### #检测是否装上 ###############

Cmd.run:

-Name:chkconfig--add Haproxy

-Unless:chkconfig--list | grep haproxy

-Require:

-File:haproxy-init


Net.ipv4.ip_nonlocal_bind:

Sysctl.present:

-Value:1


Haproxy-config-dir: ######## #创建一个配置文件目录 ###########

File.directory:

-Name:/etc/haproxy

-User:root

-Group:root

-mode:755


[[email protected] haproxy]# Salt ' * ' State.sls haproxy.install Env=prod

return Result:

Linux-node1.example.com:

..........................

Summary

-------------

Succeeded:13

failed:0

-------------

Total states Run:13

Linux-node2.example.com:

..........................

Summary

-------------

Succeeded:13

failed:0

-------------

Total states Run:13


Old boy Website: http://www.etiantian.org

qq:406564728

Welcome to Exchange

This article is from the "Linux" blog, so be sure to keep this source http://chenjisong.blog.51cto.com/7858025/1714331

Saltstack Configuration management function Module-haproxy

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.