HomeLab/Ansible - Add New Host

From Wiki Aghanim
Revision as of 13:07, 5 September 2020 by imported>Aghanim
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

First, make sure that root login is permitted on the host.


Use your favorite text editor.


sudo vim /etc/ssh/sshd_config


Inside the config file, set permit root login to yes


PermitRootLogin Yes


Restart SSH Service


/etc/init.d/ssh restart


If you have not set a password for root, do it now.


passwd


Now, if you have not generated an ssh key, do it now.


ssh-keygen -t rsa -b 4096


Send this key to the host.


ssh-copy-id root@ip.addr_of_host


Add the host to Ansible


vim /etc/ansible/hosts

my_host ansible_hosts=ip.addr_of_host


To make sure ansible can reach the host, ping it with this command.


ansible my_host -m ping


The output should look like this


my_host | SUCCESS => {

   "changed": false,
   "ping": "pong"

}