利用saltstack一键部署多台zookeeper

 

以上是saltstack上面sls文件存放zookeeper的路径和文件

以上是入口文件把文件夹做成包

重要安装配置在zoo.sls,以下是该sls的内容

zookeeper:
file.managed:
- name: /root/zookeeper-3.4.6.tar.gz
- source: salt://test/zoo/zookeeper-3.4.6.tar.gz
- user: root
- group: root
- mode: '644'

install-package:
cmd.run:
- cwd: /opt/
- name: tar zxvf /root/zookeeper-3.4.6.tar.gz

configure:
file.managed:
- name: /opt/zookeeper-3.4.6/conf/zoo.cfg
- source: salt://test/zoo/zoo.cfg
- user: root
- group: root
- mode: '644'

service_profile:
cmd.run:
- names:
- echo -e 'export ZK_HOME=/opt/zookeeper-3.4.6' >> /etc/profile
- echo -e 'export PATH=$ZK_HOME/bin:$PATH' >> /etc/profile
- source /etc/profile
- require:
- file: zookeeper

mkdir_log:
cmd.run:
- cwd: /opt/zookeeper-3.4.6
- name: mkdir log
- require:
- file: zookeeper

service_running:
 cmd.run:
 - name:
 - zkServer.sh start
 - require:
 - file: jdk

jdk:
 file.managed:
 - name: /root/jdk-8u151-linux-x64.tar.gz
 - source: salt://test/zoo/jdk-8u151-linux-x64.tar.gz
 - user: root
 - group: root
 - mode: '0755'

install_jdk:
 cmd.run:
 - cwd: /opt
 - name: tar zxvf /root/jdk-8u151-linux-x64.tar.gz

 

然后执行 salt “zookeeper” salt.sls  test.zoo

 

posted on 2018-11-30 16:22  匆匆到来  阅读(495)  评论(0编辑  收藏  举报

导航