码迷,mamicode.com
首页 > 其他好文 > 详细

SaltStack部署配置Tomcat

时间:2017-10-16 16:29:06      阅读:362      评论:0      收藏:0      [点我收藏+]

标签:saltstack   --   6.4   org   name   out   srv   tde   环境变量   

实验目标

简单部署tomcat及安装java环境

编写salt的状态模块

[root@linux-node1 web]# pwd
/srv/salt/base/web
[root@linux-node1 web]# cat tomcat.sls 
jdk-install:
  pkg.installed:
    - name: java-1.8.0-openjdk #rpm包安装不需要添加环境变量

tomcat-install:
  file.managed:
    - name: /usr/local/src/apache-tomcat-8.0.46.tar.gz
    - source: salt://web/files/apache-tomcat-8.0.46.tar.gz
    - user: root
    - group: root
    - mode: 755
  cmd.run:
    - name: cd /usr/local/src && tar zxf apache-tomcat-8.0.46.tar.gz && mv apache-tomcat-8.0.46 /usr/local/ && ln -s /usr/local/apache-tomcat-8.0.46 /usr/local/tomcat
    - unless: test -L /usr/local/tomcat && test -d /usr/local/apache-tomcat-8.0.46

上传apache-tomcat-8.0.46到salt的文件管理目录下

[root@linux-node1 src]# ll /srv/salt/base/web/files/apache-tomcat-8.0.46.tar.gz 
-rw-r--r-- 1 root root 9352747 Oct 16  2017 /srv/salt/base/web/files/apache-tomcat-8.0.46.tar.gz

执行状态模块

技术分享
[root@linux-node1 web]# salt "linux-node2*" state.sls web.tomcat
linux-node2.example.com:
----------
          ID: jdk-install
    Function: pkg.installed
        Name: java-1.8.0-openjdk
      Result: True
     Comment: The following packages were installed/updated: java-1.8.0-openjdk
     Started: 00:50:55.027164
    Duration: 46213.48 ms
     Changes:   
              ----------
              chkconfig:
                  ----------
                  new:
                      1.7.4-1.el7
                  old:
                      1.3.61-5.el7_2.1
              copy-jdk-configs:
                  ----------
                  new:
                      2.2-3.el7
                  old:
              giflib:
                  ----------
                  new:
                      4.1.6-9.el7
                  old:
              java-1.8.0-openjdk:
                  ----------
                  new:
                      1:1.8.0.144-0.b01.el7_4
                  old:
              java-1.8.0-openjdk-headless:
                  ----------
                  new:
                      1:1.8.0.144-0.b01.el7_4
                  old:
              javapackages-tools:
                  ----------
                  new:
                      3.4.1-11.el7
                  old:
              libICE:
                  ----------
                  new:
                      1.0.9-9.el7
                  old:
              libSM:
                  ----------
                  new:
                      1.2.2-2.el7
                  old:
              libXcomposite:
                  ----------
                  new:
                      0.4.4-4.1.el7
                  old:
              libXext:
                  ----------
                  new:
                      1.3.3-3.el7
                  old:
              libXfont:
                  ----------
                  new:
                      1.5.2-1.el7
                  old:
              libXi:
                  ----------
                  new:
                      1.7.9-1.el7
                  old:
              libXrender:
                  ----------
                  new:
                      0.9.10-1.el7
                  old:
              libXtst:
                  ----------
                  new:
                      1.2.3-1.el7
                  old:
              libfontenc:
                  ----------
                  new:
                      1.1.3-3.el7
                  old:
              lksctp-tools:
                  ----------
                  new:
                      1.0.17-2.el7
                  old:
              nspr:
                  ----------
                  new:
                      4.13.1-1.0.el7_3
                  old:
                      4.11.0-1.el7_2
              nss:
                  ----------
                  new:
                      3.28.4-12.el7_4
                  old:
                      3.21.0-9.el7_2
              nss-pem:
                  ----------
                  new:
                      1.0.3-4.el7
                  old:
              nss-softokn:
                  ----------
                  new:
                      3.28.3-8.el7_4
                  old:
                      3.16.2.3-14.2.el7_2
              nss-softokn-freebl:
                  ----------
                  new:
                      3.28.3-8.el7_4
                  old:
                      3.16.2.3-14.2.el7_2
              nss-sysinit:
                  ----------
                  new:
                      3.28.4-12.el7_4
                  old:
                      3.21.0-9.el7_2
              nss-tools:
                  ----------
                  new:
                      3.28.4-12.el7_4
                  old:
                      3.21.0-9.el7_2
              nss-util:
                  ----------
                  new:
                      3.28.4-3.el7
                  old:
                      3.21.0-2.2.el7_2
              python-javapackages:
                  ----------
                  new:
                      3.4.1-11.el7
                  old:
              python-lxml:
                  ----------
                  new:
                      3.2.1-4.el7
                  old:
              ttmkfdir:
                  ----------
                  new:
                      3.0.9-42.el7
                  old:
              tzdata-java:
                  ----------
                  new:
                      2017b-1.el7
                  old:
              xorg-x11-font-utils:
                  ----------
                  new:
                      1:7.5-20.el7
                  old:
              xorg-x11-fonts-Type1:
                  ----------
                  new:
                      7.5-9.el7
                  old:
----------
          ID: tomcat-install
    Function: file.managed
        Name: /usr/local/src/apache-tomcat-8.0.46.tar.gz
      Result: True
     Comment: File /usr/local/src/apache-tomcat-8.0.46.tar.gz updated
     Started: 00:51:41.243020
    Duration: 496.457 ms
     Changes:   
              ----------
              diff:
                  New file
              mode:
                  0755
----------
          ID: tomcat-install
    Function: cmd.run
        Name: cd /usr/local/src && tar zxf apache-tomcat-8.0.46.tar.gz && mv apache-tomcat-8.0.46 /usr/local/ && ln -s /usr/local/apache-tomcat-8.0.46 /usr/local/tomcat
      Result: True
     Comment: Command "cd /usr/local/src && tar zxf apache-tomcat-8.0.46.tar.gz && mv apache-tomcat-8.0.46 /usr/local/ && ln -s /usr/local/apache-tomcat-8.0.46 /usr/local/tomcat" run
     Started: 00:51:41.740160
    Duration: 1288.003 ms
     Changes:   
              ----------
              pid:
                  9742
              retcode:
                  0
              stderr:
              stdout:

Summary
------------
Succeeded: 3 (changed=3)
Failed:    0
------------
Total states run:     3
salt "linux-node2*" state.sls web.tomcat

 

SaltStack部署配置Tomcat

标签:saltstack   --   6.4   org   name   out   srv   tde   环境变量   

原文地址:http://www.cnblogs.com/xiewenming/p/7676986.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!