saltstack 配置管理-keepalived

安装keepalived:
wget http://www.keepalived.org/software/keepalived-1.3.5.tar.gz tar zxf keepalived-1.3.5.tar.gz cd keepalived-1.3.5
然后怎么装,看一下./configure --help
./configure -- prefix=/usr/local/keepalived --disable-fwmark make make install
源码包提供的启动脚本在/usr/local/src/keepalived-1.3.5/keepalived/etc/init.d
这个目录下有个keepalived.init的文件,要修改这个启动脚本。
还有一个模板配置文件,/usr/local/src/keepalived-1.3.5/keepalived/etc/keepalived/keepalived.conf
这两个文件我们都需要,拷贝过去。

mkdir -p /srv/salt/prod/keepalived/files
cp /usr/local/src/keepalived-1.3.5/keepalived/etc/init.d/keepalived.init  /srv/salt/prod/keepalived/files
cp /usr/local/src/keepalived-1.3.5/keepalived/etc/keepalived/keepalived.conf  /srv/salt/prod/keepalived/files
cp /usr/local/keeplived/etc/sysconfig/keepalived  /srv/salt/prod/keepalived/files/keepalived.sysconfig

修改启动脚本啦:

start(){
    deamon /usr/local/keealived/sbin/keepalived $ {KEEPALIVED_OPTIONS}
}

配置文件改好以后就要写安装的脚本了。

cd /srv/salt/prod/keepalived 
vim install.sls
include:
  - pkg.pkg-init
keepalived-install:
  file.managed:
    - name: /usr/local/src/keepalived-1.3.5
    - sourcde: salt://keepalived/files/keepalived-1.3.5.tar.gz
    - user: root
    - gourp: root
    - mode: 755
  cmd.run:
    - name: cd /usr/local/src/ && tar zxf keepalived-1.3.5.tar.gz && cd  keepalived-1.3.5 && ./configure -- prefix=/usr/local/keepalived --disable-fwmark && make && make install
    - unless: test -d /usr/local/keepalived
    - require:
      - pkg: pkg-init
      - file: keepalived-install

keepalived-init:
  file.managed:
    - dource: salt:///keepalived/files/keeplived.init
    - user: root
    - group: root
    - mode: 755
  cmd.run:
    - name: chkconfig --add keepalived
    - unless: chkconfig --list| grep keepalived
    - require:
      - file: keepalived-init

/etc/sysconfig/keepalived:
  file.managed:
    - source: salt://keepalived/files/keepalived.sysconfig
    - user: root
    - group: root
    - mode: 644

/etc/keepalived:
  file.directory:
    - user: root
    - group: root
    - mode: 755

执行salt '*' state.sls keepalived.install env= prod

你可能感兴趣的:(saltstack 配置管理-keepalived)