Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] ansible modules broken if using ansible-core default installation #66640

Open
amalaguti opened this issue Jun 14, 2024 · 0 comments
Open
Labels
Bug broken, incorrect, or confusing behavior needs-triage

Comments

@amalaguti
Copy link

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

@amalaguti amalaguti added Bug broken, incorrect, or confusing behavior needs-triage labels Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior needs-triage
Projects
None yet
Development

No branches or pull requests

1 participant