DevOps Classroom notes 03/Aug/2025

Ansible

Adhoc commands

  • Ansible allows us to automate individual commands using adhoc commands
ansible  -m [module] -a "[module options]"  [pattern]
  • Lets Try file creation
 ansible -i hosts -m file -a "path=/tmp/1.txt state=touch" all
  • Lets try adding a user called as test
    • homedirectory = “/opt/test”
    • shell = “/bin/sh”
    • username = “test”
ansible -i hosts -m user -a "name=test home=/opt/test shell=/bin/sh" all

Tomcat configuration.

  • Manual steps
sudo apt update
sudo apt install openjdk-17-jdk -y
sudo useradd -m -d /opt/tomcat -U -s /bin/false tomcat
wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.25/bin/apache-tomcat-10.1.25.tar.gz -P /tmp
sudo mkdir /opt/tomcat
sudo tar -xvf /tmp/apache-tomcat-10.1.25.tar.gz -C /opt/tomcat --strip-components=1
sudo chown -R tomcat:tomcat /opt/tomcat
sudo chmod -R g+r /opt/tomcat/conf
sudo chmod g+x /opt/tomcat/conf
  • Ansible doesnot support –strip-components=1, so we need a workaround
    • if you dont find the right module there is a way to run raw linux command. The side effect of this approach is no desired state and it executes every time.
    • Change your manual steps accordingly

Lets take the approach 1: running raw linux commands

Better way

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube