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
========================================================================
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:
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:
Thanks @MRMW for confirming that your issue was resolved.
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.