# Tomcat 安装管理标签:8.0,tomcat,46,usr,apache,SaltStack,local From: https://blog.51cto.com/u_13940603/5886237
1. vim tomcat.sls
jdk-install:
pkg.installed:
- name: java-1.8.0-openjdk
tomcat-install:
file.managed:
- name: /usr/local/src/apache-tomcat-8.0.46.tar.gz
- source: salt://web/apache-tomcat-8.0.46.tar.gz
- user: root
- group: root
- mode: 755
cmd.run:
- name: cd /usr/local && 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
2. salt '192.168.2.104*' state.sls web.tomcat
# 执行效果如下:
#---------------------------------------------------------------------------
192.168.2.104:
----------
ID: jdk-install
Function: pkg.installed
Name: java-1.8.0-openjdk
Result: True
Comment: Package java-1.8.0-openjdk is already installed.
Started: 09:17:51.683726
Duration: 796.258 ms
Changes:
----------
ID: tomcat-install
Function: file.managed
Name: /usr/local/apache-tomcat-8.0.46.tar.gz
Result: True
Comment: File /usr/local/apache-tomcat-8.0.46.tar.gz is in the correct state
Started: 09:17:52.481986
Duration: 163.66 ms
Changes:
----------
ID: tomcat-install
Function: cmd.run
Name: cd /usr/local/ && tar zxf apache-tomcat-8.0.46.tar.gz && mv apache-tomcat-8.0.46 /usr/local/tomcat && ln -s /usr/local/apache-tomcat-8.0.46 /usr/local/tomcat
Result: True
Comment: Command "cd /usr/local/ && tar zxf apache-tomcat-8.0.46.tar.gz && mv apache-tomcat-8.0.46 /usr/local/tomcat && ln -s /usr/local/apache-tomcat-8.0.46 /usr/local/tomcat" run
Started: 09:17:52.646182
Duration: 207.545 ms
Changes:
----------
pid:
8610
retcode:
0
stderr:
stdout:
Summary
------------
Succeeded: 3 (changed=1)
Failed: 0
------------
Total states run: 3
#---------------------------------------------------------------------------
3. salt '*' state.sls web.tomcat