Setup Readhat 10 node
- crate user
ansible
sudo useradd -m -s /bin/bash ansible
sudo passwd ansible
-m will create dirrectory /home/ansible
-s set login shell permissions
- provide sudo permissions – root permissions
- 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
- 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
- python3
Ansible Handler
- Handler are special tasks that execute only when another task run
- notifies
- Handler are mostly uses for service cmds
- 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:
- try to install nop application follow below referance
- linux nop installation docs