Pre-requisite
- Ansible is 2.3.1.0 installed in Linux (RHEL)
Tomcat Instllation and
Deployment Playbook
- Inventory File (inventory.txt)
[hosts]
licremmt06.gl.avaya.com
http_port=8080
licremmt07.gl.avaya.com
http_port=8080
|
- Tomcat Installation Playbook (tomcat-install.yml)
---
- hosts: all
tasks:
- name: Make sure
that we can connect to the machine
ping:
- name: add group
"tomcat"
group:
name=tomcat
- name: add user
"tomcat"
user:
name=tomcat group=tomcat createhome=yes
become: true
- name: copy Tomcat
copy:
src=./apache-tomcat-8.5.16.tar.gz dest=/opt/apache-tomcat-8.5.16.tar.gz
- name: Extract
Tomcat archive
command: tar
zxvf /opt/apache-tomcat-8.5.16.tar.gz -C /opt/
creates=/opt/apache-tomcat-8.5.16
- name: Change
ownership of Tomcat installation
file:
path=/opt/apache-tomcat-8.5.16 owner=tomcat group=tomcat state=directory
recurse=yes
- name: Configure
Tomcat server
template:
src=server.xml dest=/opt/apache-tomcat-8.5.16/conf/
- name: Configure
Tomcat users
template:
src=tomcat-users.xml dest=/opt/apache-tomcat-8.5.16/conf/
- name: Start Tomcat
command: nohup
/opt/apache-tomcat-8.5.16/bin/startup.sh
become: true
become_user:
tomcat
- name: wait for
tomcat to start
wait_for:
port={{http_port}}
|
- WAR Deploy playbook (tomcat-deploy.yml)
---
- hosts: all
tasks:
- name: Make sure
that we can connect to the machine
ping:
- name: copy war
copy:
src=./osm-phs-1.0.6.war
dest=/opt/apache-tomcat-8.5.16/webapps/osm-phs-1.0.6.war owner=tomcat
group=tomcat mode=0744
|
- Tomcat removal playbook (tomcat-remove.yml)
---
- hosts: all
tasks:
- name: Make sure
that we can connect to the machine
ping:
- name: Stop Tomcat
command: sh
/opt/apache-tomcat-8.5.16/bin/shutdown.sh
become: true
become_user:
tomcat
- name: Remove
Tomcat
file:
path:
/opt/apache-tomcat-8.5.16
state:
absent
- name: remove user
"tomcat"
user:
name:
tomcat
state:
absent
- name: remove group
"tomcat"
group:
name:
tomcat
state:
absent
|
- Commands to execute
$ansible-playbook -i
ansible-inventory tomcat-install.yml -k
|
Thank You!
Thank you for sharing vauable infromation.
ReplyDeleteDevOps Training
DevOps Online Training
DevOps Training in Ameerpet
linux training
ReplyDeletemulesoft training
web methods training
business analyst online training