Anisble demo and how to connect using ssh.

1 . Install ( extra package of Enterprise)

wget <https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm>

2 . install epel packaged

  1. apt install update

    yum/apt install epel 
    
  2. install collection of give below package

apt install git python python-level python-pip openssl ansible
  1. configure ansible host
vi /etc/ansible/hosts
  1. edit and add group and add private IP Address

Group_Name IP-Address

[demo] 172.31.41.240

  1. Configure main file in anisble
vi /etc/ansible/ansible.cfg
adduser ansible (optional)
  1. Give sudo rights using command
visudo
  1. All root to run any command anywhere change

username ALL=(ALL) NOPASSWD: ALL using below command

ansible ALL=(ALL) NOPASSWD: ALL
  1. Ansible user login
su - ansible
  1. configure SSH
vi /etc/ssh/sshd_config
  1. Take SSH Connection
ssh [Private_IP]
  1. If Permission denied do this : -
service sshd restart

generate key because every time need password ( make trust Relation Ship )

Notes : You need to same user anisble & root

ssh-keygen

cd .ssh

ls

  1. Copy a file to node
ssh-copy-id ansible@NodePrivateIP

Host Patterner : How to Identify host for individual update


ansible all —list-hosts
ansible [group-name] —list-hosts
ansible [group_name][index_no] --list-hosts
ansible [group_name][rangeofnode:rangeofnode] --list-hosts
ansible [group_name][2:6] --list-hosts
ansible [group_name][1:6]:[unother-group_name][4:6]

For Better view Visit my Notion Site

https://www.notion.so/Ansible-Configuration-a4fd1725c7fc4fdfaa3da23144f03a19

Comments

Popular Posts