DevOps Classroom notes 24/Feb/2024

Ansible contd

using modules

  • Ansible has lots of modules Refer Here
  • Using Module
<module-name>:
  <parameter-1-name>: <value>
  ...
  <state>: <desired state>
  • Refer paramters section in module documentation and fill the values

Activity 1: Install Nginx

sudo apt update
sudo apt install nginx
  • Testing manual steps
  • Find module for every manual step
  • Create a Playbook
  • Refer Here for the changes done
  • Lets perform syntax check
    Preview
  • Lets execute dry run (doesnot work in all cases)
    Preview
  • Now lets execute the playbook
    Preview
  • Navigate to public ip
    Preview

Activity 2: Install Apache

  • Overview
    Preview
  • Manual steps
# ubunu
sudo apt update
sudo apt install apache2 -y
sudo systemctl enable apache2
sudo systemctl start apache2

# redhat steps
sudo dnf install httpd
sudo systemctl enable httpd.service
sudo systemctl start httpd.service
  • Daemon: This is an application designed to run in background. To ensure this application starts when your machine is started we have to enable the daemon/service
sudo systemctl => control daemons
sudo service  => control daemons
  • Daemon in ubuntu: generally after install softwares the daemon is mostly enabled
  • Daemon in Redhat: we have to enable and start the daemon or service
  • Execute the ansible playbook
    Preview
  • Problems to be addressed:

    • redhat 9 issue
    • why check doesn’t work all the time

adhoc command

  • Ansible automation can be executed using two approaches
    • imperative: using ansible commands (adhoc)
    • declrative: writing playbooks
  • Adhoc command: Refer Here
ansible -i <inventory> -m "<module name>" -a "parameter1=value1 parameter2=value2"
  • Adhoc command for uninstallign ansible
ansible -i hosts -m apt -a "name=nginx purge=true state=absent"

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
Plugin for Social Media by Acurax Wordpress Design Studio

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