How to install Ansible on RHEL 9 ๐Ÿ˜‡

How to install Ansible on RHEL 9 ๐Ÿ˜‡

ยท

1 min read

Steps

  1. Login AWS and launch 3 Red Hat Instance (One Controller Node and 2 Target Node)

  1. Log in to controller node and perform following steps:

  • To update server : yum update -y

  • Install ansible : yum install ansible-core

  • update ansible inventory by copying public or private ip of target node

  • update /etc/ansible/host file : public-ip ansible_user=<user> ansible_password=<password>

  • do ansible all --list-host , you will see the hosts(target node ips)

  • In controller node do : ansible-config init --disabled > /etc/ansible/ansible.cfg

  • vim /etc/ansible/ansible.cfg and edit , save this file by doing this

      host_key_checking=False
    
  1. Now login one of the target node and perform following steps:

  • vim /etc/ssh/sshd_config.d/50-cloud-init.conf and write and save file with

      PasswordAuthentication yes
    
  • vim /etc/ssh/sshd_config and edit , save

      PermitRootLogin yes
    
  • restart sshd service

      systemctl restart sshd
    
  • Change root password

      passwd root
    
  1. Now repeat the 3rd process with other target node

  2. Login controller node and execute the below step to run any linux command on single , multiple or all hosts

ansible all -m command -a <linux-command>

Thank you for reading โฃ๏ธ

ย