cancel
Showing results for 
Search instead for 
Did you mean: 
MRMW
Cadet
Cadet
  • 108 Views

The following modules failed to execute: ansible.legacy.setup

Jump to solution

Hi,
I am having issues trying to run playbooks against a server.
I created a simple ansible fact gathering example playbook.
When I run the playbook without become, no issues
But as soon as I add the uncomment the lines below so I run as was, an error occurs.
What is causing this simple playbook to not run?


1. Playbook runs, no errors
---
- name: Gather and display facts
hosts: "TEST"
gather_facts: true
# become: yes
# become_user: was
vars:
# ansible_become_pass: "xxxxxxxxxx"
ansible_python_interpreter: /usr/bin/python3
# ansible_become_method: sudo
tasks:
- name: Display gathered facts
debug:
var: ansible_facts

Works fine
========================================================================
2. Uncommented lines so we sudo to was and we get an error
---
- name: Gather and display facts
hosts: "TEST"
gather_facts: true
become: yes
become_user: was
vars:
ansible_become_pass: "xxxxxx"
ansible_python_interpreter: /usr/bin/python3
ansible_become_method: sudo
tasks:
- name: Display gathered facts
debug:
var: ansible_facts

Error:
TASK [Gathering Facts] *************************************************************************
fatal: [testserver]: FAILED! => changed=false
ansible_facts: {}
failed_modules:
ansible.legacy.setup:
failed: true
module_stderr: |-
Shared connection to testserver closed.
module_stdout: ""
msg: |-
MODULE FAILURE
See stdout/stderr for the exact error
rc: 1
msg: |-
The following modules failed to execute: ansible.legacy.setup
========================================================================

Labels (1)
Tags (1)
1 Solution

Accepted Solutions
MRMW
Cadet
Cadet
  • 95 Views

Solved:

Added:

become_method: enable

 

---
- name: Gather and display facts
hosts: "TEST"
gather_facts: true
become: yes
become_user: was
become_method: enable
vars:
ansible_become_pass: "xxxxxx"
ansible_python_interpreter: /usr/bin/python3
ansible_become_method: sudo
tasks:
- name: Display gathered facts
debug:
var: ansible_facts

Reference:

https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_privilege_escalation.html#become-co...

View solution in original post

2 Replies
MRMW
Cadet
Cadet
  • 96 Views

Solved:

Added:

become_method: enable

 

---
- name: Gather and display facts
hosts: "TEST"
gather_facts: true
become: yes
become_user: was
become_method: enable
vars:
ansible_become_pass: "xxxxxx"
ansible_python_interpreter: /usr/bin/python3
ansible_become_method: sudo
tasks:
- name: Display gathered facts
debug:
var: ansible_facts

Reference:

https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_privilege_escalation.html#become-co...

Chetan_Tiwary_
Community Manager
Community Manager
  • 91 Views

Thanks @MRMW for confirming that your issue was resolved.

0 Kudos
Join the discussion
You must log in to join this conversation.