1. 基础环境
[root@linux-node1 ~]# cd /srv/salt/prod/modules[root@linux-node1 modules]# lshaproxy keepalived memcached pcre pkg userjdk libevent nginx php tomcat[root@linux-node1 modules]# mkdir jdk && mkdir tomcat
modules是我存放功能模块的的目录,每个服务尽量能单独写一个状态文件,具有通用性。
2. Installing jdk-8u45-linux-x64
[root@linux-node1 modules]# cd jdk[root@linux-node1 jdk]# mkdir files #存放安装包[root@linux-node1 jdk]# vim jdk-install.sls #编写安装状态文件jdk-installl: file.managed: - name: /server/tools/jdk-8u45-linux-x64.tar.gz - source: salt://modules/jdk/files/jdk-8u45-linux-x64.tar.gz - user: root - group: root - mode: 755 cmd.run: - name: cd /server/tools/jdk-8u45-linux-x64.tar.gz && tar zxf jdk-8u45-linux-x64.tar.gz && mv jdk1.8.0_45 /application/jdk && chown -R root:root /application/jdk - unless: test -d /application/jdk - requrie: - file: jdk-installjdk-config: file.append: - name: /etc/profile - text: - export JAVA_HOME=/application/jdk - export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH - export CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar
上面安装了jdk环境
3. Installing Tomcat
[root@linux-node1 modules]# cd tomcat[root@linux-node1 tomcat]# mkdir files #存放tomcat的安装包[root@linux-node1 tomcat]# vim install.sls #编写安装状态文件include: - modules.jdk.installtomcta-install: file.managed: - name: /server/tools/apache-tomcat-8.0.23.tar.gz - source: salt://modules/tomcat/files/apache-tomcat-8.0.23.tar.gz - user: root - group: root - mode: 755 cmd.run: - name: cd /server/tools/ && tar zxf apache-tomcat-8.0.23.tar.gz && mv apache-tomcat-8.0.23 /application/ && ln -s /application/apache-tomcat-8.0.23 /application/tomcat && chown -R root:root /application/tomcat8 - unless: test -d /application/tomcattomcat-config: file.append: - name: /etc/profile - text: - export TOMCAT_HOME=/application/tomcat