Ansible Contd
- Lets try to install tomcat 9 with open jdk 11
- We have two linux distributions
- ubuntu 20.04
- Redhat 7.x
- Ubuntu Tomcat manual implementation Refer Here
- Useradd:
sudo useradd -m -U -d /opt/tomcat -s /bin/false tomcat
- -m create home directory
- -U create a group with the same name as the user
- -d home directory (/opt/tomcat)
- -s login shell for the user
/bin/false
- tomcat => username
- Lets find a ansible module for useradd Refer Here
- Refer Here for examples of user module
- Refer Here
- We got the following failure group doesnot exists
- We have two options, create a group or donot pass group parameter. Refer Here for the changeset
-
Now lets login and check the user details on the ubuntu node by executing
cat /etc/passwd
- Download the tomcat to the /tmp directory
VERSION=9.0.60
wget https://dlcdn.apache.org/tomcat/tomcat-9/v${VERSION}/bin/apache-tomcat-${VERSION}.tar.gz -P /tmp
* The module for downloading from web is get_url Refer Here
* Refer Here for the changes done
* Now lets manually verify this
- Extract the tar file
sudo tar -xf /tmp/apache-tomcat-${VERSION}.tar.gz -C /opt/tomcat/
- Create a link to the new folder
sudo ln -s /opt/tomcat/apache-tomcat-${VERSION} /opt/tomcat/latest
* Now change the folder permissions
sudo chown -R tomcat: /opt/tomcat
sudo sh -c 'chmod +x /opt/tomcat/latest/bin/*.sh'