[BUG] ansible modules broken if using ansible-core default installation
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description
The ansible module does not work with the new ansible-core package (not the ansible community) due ansible-core, being a minimal installation, it does not include the json outputter required by Salt to parse the output from the module execution
$ salt-call ansible.playbooks playbook=/opt/playbooks/hellow_world.yml
[ERROR ] Command 'ansible-playbook' failed with return code: 1
[ERROR ] stderr: [WARNING]: provided hosts list is empty, only localhost is available. Note that
the implicit localhost does not match 'all'
ERROR! Invalid callback for stdout specified: json
[ERROR ] retcode: 1
local:
----------
pid:
78819
retcode:
1
stderr:
[WARNING]: provided hosts list is empty, only localhost is available. Note that
the implicit localhost does not match 'all'
ERROR! Invalid callback for stdout specified: json
stdout:
The fix is simple, install the plugin ansible.posix which includes the json outputter
$ ansible-galaxy collection install ansible.posix
Setup
Salt with ansible-core installed
Steps to Reproduce the behavior
Install Salt
Install ansible-core
Add ansible.posix to ansible-core
$ ansible-galaxy collection install ansible.posix
Test with the following simple playbook execution
$ cat /srv/salt/ansible_playbooks/hello_world.sls
run ansible playbook:
ansible.playbooks:
- name: /opt/playbooks/hellow_world.yml
$ cat /opt/playbooks/hellow_world.yml
---
# This playbook prints a simple debug message
- name: Echo
hosts: 127.0.0.1
connection: local
tasks:
- name: Print debug message
debug:
msg: Hello, world!
$ salt-call state.sls ansible_playbooks.hello_world
local:
----------
ID: run ansible playbook
Function: ansible.playbooks
Name: /opt/playbooks/hellow_world.yml
Result: True
Comment: No changes to be made from playbook /opt/playbooks/hellow_world.yml
Started: 13:32:53.933081
Duration: 2814.239 ms
Changes:
Summary for local
------------
Succeeded: 1
Failed: 0
------------
Total states run: 1
Total run time: 2.814 s
Expected behavior
Already suggested adding this info to the module documentation and maybe worth to check/try if the required module is present and provide a more descriptive message indicating the issue and fix
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Salt's ansible module and reproduce the failure using the ansible-core installation described in the issue, then inspect how the JSON callback is requested and its error is surfaced. Done means documenting the ansible.posix requirement and, if feasible, providing a clearer message when the callback is unavailable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ansible
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100