The ad-hoc ansible command runs without any error:
suchetla@xhdlc210320:/scratch$ ansible all -m ping -i /opt/hosts
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
xhdlc201168 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
xhdlc201164 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
xhdlc201166 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
But ansible-playbook command fails:
suchetla@xhdlc210320:/scratch$ ansible-playbook -i /opt/hosts mars.yml
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
Sudo password:
PLAY [xhd-hosts] ***************************************************************************************************************************
TASK [Gathering Facts] *********************************************************************************************************************
fatal: [xhdlc210319]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"ansible.legacy.setup": {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"}, "failed": true, "module_stderr": "Shared connection to xhdlc210319 closed.\r\n", "module_stdout": "\r\n/usr/bin/python3: can't open file '/home/suchetla/.ansible/tmp/ansible-tmp-1711451084.9141061-329683-269580434256761/AnsiballZ_setup.py': [Errno 13] Permission denied\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 2}}, "msg": "The following modules failed to execute: ansible.legacy.setup\n"}
Below is my playbook.yml:
---
- hosts: xhd-hosts
become: true
become_method: sudo
become_exe: "/tools/xgs/bin/sudo"
#become_exe: "sudo"
vars_prompt:
- name: "ansible_sudo_pass"
prompt: "Sudo password"
private: yes
tasks:
- name: Install Prometheus Node Exporter
apt:
name: device-tree-compiler
state: present
My inventory is in /opt/hosts:
hostname1
hostname2
hostname3
I created a public key on the ansible installed instance and copied on to the authorized keys on the destination servers.
Based on your logs, your problem is not related to the Network, but to your Filesystem permissions!
This line:
/usr/bin/python3: can't open file '/home/suchetla/.ansible/tmp/ansible-tmp-1711451084.9141061-329683-269580434256761/AnsiballZ_setup.py': [Errno 13] Permission deniedPlease check the path and see if there are any specific permission issues, or update your question with
ls -alh