DevOps Classroom notes 05/Nov/2026

Setup Readhat 10 node

  • pre-request:
  1. crate user ansible
sudo useradd -m -s /bin/bash ansible
sudo  passwd ansible
  • -m will create dirrectory /home/ansible
  • -s set login shell permissions
  1. provide sudo permissions – root permissions
  2. make user No password for command
    echo "ansible ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/ansible
    sudo chmod 0440 /etc/sudoers.d/ansible
    sudo visudo -cf /etc/sudoers.d/ansible
sudo usermod -aG wheel ansible
  1. allow ssh password based
sudo sshd -T | grep -i passwordauthentication

sudo grep -ri PasswordAuthentication /etc/ssh/sshd_config.d/ # serach
vi /etc/ssh/sshd_config.d/50-cloud-init.conf
PasswordAuthentication yes

sudo systemctl reload sshd

id ansible

# login user 

ssh ansible@<ipaddress> 

# run sample cmd
sudo yum update
  1. python3

Ansible Handler

  • Handler are special tasks that execute only when another task run
  • notifies
  • Handler are mostly uses for service cmds
    • restart
    • start
    • reload
- name: "Scholar Website"
  hosts: all
  become: yes

  tasks:
    - name: "Install wget and unzip"
      ansible.builtin.dnf:
        name:
          - wget
          - unzip
        state: present
        update_cache: yes

    - name: "Install Apache2"
      ansible.builtin.dnf:
        name: httpd
        state: present
      notify: "Restart Apache2"

    - name: "Download website template"
      ansible.builtin.get_url:
        url: "https://templatemo.com/tm-zip-files-2020/templatemo_586_scholar.zip"
        dest: /tmp/templatemo_586_scholar.zip
        mode: '0644'

    - name: "Unzip website template"
      ansible.builtin.unarchive:
        src: /tmp/templatemo_586_scholar.zip
        dest: /tmp/
        remote_src: yes

    - name: "Ensure Apache document root exists"
      ansible.builtin.file:
        path: /var/www/html
        state: directory
        owner: apache
        group: apache
        mode: '0755'

    - name: "Copy website files to Apache document root"
      ansible.builtin.copy:
        src: /tmp/templatemo_586_scholar/
        dest: /var/www/html/
        remote_src: yes
        owner: apache
        group: apache
        mode: '0755'
      notify: "Restart Apache2"
  
  handlers:
    - name: "Restart Apache2"
      ansible.builtin.systemd_service:
        name: httpd
        state: restarted

Task:

  1. try to install nop application follow below referance
  2. linux nop installation docs

Leave a comment

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
Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube