Creating an Ansible Controller
Basic requirements, test with any mixture of the following basic Ansible commands.
ansible <host> -m ping
ansible <hostgroup> -m ping
ansible <hostgroup> -m ping -u <user>
ansible <host> -m ping --private-key=/home/user/.ssh/key
ansible <host> -m ping -u <user> --private-key=/home/user/.ssh/key
2 hosts
- controller
- has ansible
- create ssh key as the ansible user
ssh-copy-id <worker>
- should be able to ssh with no password -
ssh <workstation>
as ansible user- If the above does not work, create
/home/USER/.ssh/config
and addIdentityFile /path/to/Private.key
, this will pass the key automatically when connecting as USER. - Ensure the host you are connecting to has the connecting key within the
~/.ssh/authorized_keys
file. - restart sshd.service -
sudo systemctl restart sshd.service
- If the above does not work, create
- worker
- has ansible
- has a known password, but can sudo without one.
-
<user> ALL=(ALL) ALL NOPASSWD:ALL
within sudoers
-