I'm trying to install packages using Ansible but I keep getting the following error from both master and worker node
fatal: [masternode]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).", "unreachable": true}
fatal: [workernode]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).", "unreachable": true}
I'm using the following playbook
- hosts: all
user: ansible
become: True
tasks:
- name: Insall git
yum:
name: git
state: present
update_cache: True
I'm able to ping the master VM from my worker node and I'm able to ping the worker node from my master VM, so I'm not sure what the issue is.
I'm using CentOS 7 and GCP instances. I have an ansible.cfg file setup
[defaults]
inventory = hosts
host_key_checking = False
I also have a hosts file setup
10.128.0.3 (master node IP)
10.128.0.4 (worker node IP)
I also have the default hosts file setup (/etc/ansible/hosts)
[gcpnodes]
masternode ansible_ssh_host=10.128.0.3
workernode ansible_ssh_host=10.128.0.4