salt一键部署kafka

 1.准备工作:

2.salt关于kafka的部署脚本,就是上面的init.sls中的内容,至于下面的内容的每一项的意思在之前jdk的脚本中有写。

kafka-file:
  file.managed:
   - source: salt://kafka/kafka_2.11-0.9.0.0.tar.gz
   - name: /opt/kafka_2.11-0.9.0.0.tar.gz
   - user: root
   - group: root

kafka-install:
  cmd.run:
   - name: 'cd /opt && tar zxf kafka_2.11-0.9.0.0.tar.gz && ln -s kafka_2.11-0.9.0.0 kafka && chown -R hadoop:hadoop /opt/kafka*'
   - unless: 'test -d /opt/kafka_2.11-0.9.0.0'
   - require:
     - file: kafka-file
 
kafka-rmtgz:
  file.absent:
    - name: /opt/kafka_2.11-0.9.0.0.tar.gz
	- require:
     - cmd: kafka-install
	 
/etc/profile:
  file.append:
    - text:
      - export KAFKA_HOME=/opt/kafka
      - export PATH=$KAFKA_HOME/bin:$PATH
	- require:
      - file: kafka-rmtgz
	  
source-profile:
   cmd.run:
    - name: 'source /etc/profile'
	- require:
      - file: /etc/profile

3.salt执行该一键部署脚本

 内容显示如下:

s3:
----------
          ID: kafka-file
    Function: file.managed
        Name: /opt/kafka_2.11-0.9.0.0.tar.gz
      Result: True
     Comment: File /opt/kafka_2.11-0.9.0.0.tar.gz updated
     Started: 07:57:54.854046
    Duration: 1892.178 ms
     Changes:   
              ----------
              diff:
                  New file
              mode:
                  0644
----------
          ID: kafka-install
    Function: cmd.run
        Name: cd /opt && tar zxf kafka_2.11-0.9.0.0.tar.gz && ln -s kafka_2.11-0.9.0.0 kafka && chown -R hadoop:hadoop /opt/kafka*
      Result: True
     Comment: Command "cd /opt && tar zxf kafka_2.11-0.9.0.0.tar.gz && ln -s kafka_2.11-0.9.0.0 kafka && chown -R hadoop:hadoop /opt/kafka*" run
     Started: 07:57:56.747888
    Duration: 402.739 ms
     Changes:   
              ----------
              pid:
                  2806
              retcode:
                  0
              stderr:
              stdout:
----------
          ID: kafka-rmtgz
    Function: file.absent
        Name: /opt/kafka_2.11-0.9.0.0.tar.gz
      Result: True
     Comment: Removed file /opt/kafka_2.11-0.9.0.0.tar.gz
     Started: 07:57:57.150965
    Duration: 5.899 ms
     Changes:   
              ----------
              removed:
                  /opt/kafka_2.11-0.9.0.0.tar.gz
----------
          ID: /etc/profile
    Function: file.append
      Result: True
     Comment: Appended 2 lines
     Started: 07:57:57.157009
    Duration: 6.193 ms
     Changes:   
              ----------
              diff:
                  --- 
                  
                  +++ 
                  
                  @@ -91,3 +91,5 @@
                  
                   export master=bgs-5p173-wangwenting
                   
                   export PATH=/opt/python/bin:$PATH
                  +export KAFKA_HOME=/opt/kafka
                  +export PATH=$KAFKA_HOME/bin:$PATH
----------
          ID: source-profile
    Function: cmd.run
        Name: source /etc/profile
      Result: True
     Comment: Command "source /etc/profile" run
     Started: 07:57:57.163374
    Duration: 29.547 ms
     Changes:   
              ----------
              pid:
                  2811
              retcode:
                  0
              stderr:
              stdout:

Summary for s3
------------
Succeeded: 5 (changed=5)
Failed:    0
------------
Total states run:     5
Total run time:   2.337 s

4.其余的操作步骤和之前jdk,python类似这里就不写啦。

 

posted @ 2017-05-17 09:49  wyl9527  阅读(601)  评论(0编辑  收藏  举报