DevOps Classroomnotes 28/May/2023

Ansible contd..

Activity 2: Installing lamp server on ubuntu

  • Note: we will skip mysql installation for now
  • Manual steps are
sudo apt update
sudo apt install apache2 -y
sudo apt install php libapache2-mod-php php-mysql -y
# Create a file called as /var/www/html/info.php with below content
# <?php phpinfo(); ?>
sudo -i
echo '<?php phpinfo(); ?>' > /var/www/html/info.php
exit
sudo systemctl restart apache2
  • Refer Here for the changset containing playbook, inventory and file
  • Check for syntax of playbook
ansible-playbook -i <inventory-path> --syntax-check <playbook-path>
  • Now lets run the playbook ansible-playbook -i <inventory-path> <playbook-path>
    Preview
  • Verify the installation
    Preview
  • Problems to be addressed
    • during every playbook execution the apache service is getting restarted
      Preview

Activity 3: Install lamp stack on Redhat 9

  • Manual steps
sudo yum install httpd -y
sudo systemctl enable httpd
sudo systemctl start httpd
sudo yum install php -y
sudo -i
echo '<?php phpinfo(); ?>' > /var/www/html/info.php
exit
sudo systemctl restart httpd
  • Refer Here for the changeset for redhat
  • Execute playbook
    Preview
  • Problems

    • during every playbook execution the apache service is getting restarted
    • Why should we have two inventory files one for ubuntu and one for redhat
    • Can we have one playbook for both redhat and ubuntu
    • Bailout with proper failure message for unsupported operating systems

Exercies

  • Write playbooks to install the following on ubuntu 22.04
    • java 17
    • .net 7
    • nginx

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner