How to add a new host to Ansible
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"
}
One Comment
Comments are closed.