Skip to content

Latest commit

 

History

History
57 lines (41 loc) · 958 Bytes

Ansible-setup-in-CentOS.md

File metadata and controls

57 lines (41 loc) · 958 Bytes

Setup Ansible in CentOS-9

Client Node setup

Add ansible to sudoers group for managed nodes

USER=user
sudo usermod -aG wheel $USER 
sudo echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USER

Allow connection from remote server

sed -i 's/#PubkeyAuthentication\syes/PubkeyAuthentication yes/' /etc/ssh/sshd_config
sed -i 's/#AuthorizedKeysFile\s.ssh\/authorized_keys/AuthorizedKeysFile .ssh\/authorized_keys/' /etc/ssh/sshd_config
systemctl restart sshd

Control Node setup

Install Ansible in control node

sudo dnf install -y epel-release
sudo dnf install -y ansible

Generate ssh-key and copy in client node

ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519
ssh-copy-id user@host

Add host groups

sudo tee -a /etc/ansible/hosts << EOF
[<hostgroup1>]
<host1>

[<hostgroup2>]
<host2>
<host3>
EOF

Test the connection

ansible all -m ping