Skip to content

Commit

Permalink
Update tomcat.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
lerndevops authored Feb 3, 2021
1 parent 9b01ed0 commit 5782b27
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions ansible/playbooks/tomcat.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,53 @@
---
- hosts: ubuntu
- hosts: web
become: yes
tasks:
- name: Install Java 1.8
apt:
name: openjdk-8-jdk
apt: ## apt-get install openjdk-8-jdk -y
name: openjdk-8-jdk
state: present

- name: add group "tomcat"
group:
group: ## groupadd tomcat
name: tomcat

- name: add user "tomcat"
user:
name: tomcat
group: tomcat
user: ## useradd tomcat -G tomcat
name: tomcat
group: tomcat
createhome: no

- name: Download Tomcat
get_url:
url: https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.40/bin/apache-tomcat-8.5.40.tar.gz
get_url: ### wget url -O /tmp/tomca.tgz
url: https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.40/bin/apache-tomcat-8.5.40.tar.gz
dest: /tmp/apache-tomcat-8.5.40.tar.gz

- name: Extract archive
unarchive:
src: /tmp/apache-tomcat-8.5.40.tar.gz
unarchive: ## tar -xzf tarfile ## by default source is always controller
src: /tmp/apache-tomcat-8.5.40.tar.gz
dest: /opt
remote_src: yes

- name: create symlink
file:
file: ## ln -s /opt/tomcat /opt/apache-tomcat-8.5.40
src: /opt/apache-tomcat-8.5.40
path: /opt/tomcat
state: link

- name: Change ownership of Tomcat installation
file:
path: /opt/tomcat
owner: tomcat
group: tomcat
mode: 0755
state: directory
file: ## chmod 755 -R /opt/tomcat , chown tomcat:tomcat -R /opt/tomcat
path: /opt/tomcat
owner: tomcat
group: tomcat
mode: 0755
state: directory
recurse: yes

- name: create tomcat.service file
file:
file: ## touch /etc/systemd/system/tomcat.service
path: /etc/systemd/system/tomcat.service
state: touch

- name: create tomcat service
blockinfile:
path: /etc/systemd/system/tomcat.service
Expand All @@ -58,8 +64,9 @@
ExecStop=/opt/tomcat/bin/shutdown.sh
[Install]
WantedBy=multi-user.target
- name: enable & start tomcat service
systemd:
systemd: ## systemctl enable tomcat, systecctl start tomcat
name: tomcat
state: started
enabled: yes

0 comments on commit 5782b27

Please sign in to comment.