ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
832 stars 1.53k forks source link

community.general.diy callback clarification #5104

Open alice-rc opened 2 years ago

alice-rc commented 2 years ago

Summary

In the documentation it shows: playbook_on_include_msg: Output to be used for callback playbook_on_include. Configuration: INI entry: [callback_diy] playbook_on_include_msg = None

And the community.general.diy callback documentation it states:

  1. Condition for all msg options: if value is None or omit, then the option is not being used. Effect: use of the default callback plugin for output
  2. Condition for all msg options: if value is not None and not omit and length is not greater than 0, then the option is being used without output. Effect: suppress output
  3. Condition for all msg options: if value is not None and not omit and length is greater than 0, then the option is being used with output. Effect: render value as template and output

Statement #2 and #3 work as expected. But option #1 does not. It in fact just prints the string 'None' or 'omit'. I believe that you would need to use "{{ None }}" or "{{ omit }}".

Issue Type

Documentation Report

Component Name

community.general.diy

Ansible Version

$ ansible --version
ansible [core 2.13.0]
  config file = XXX/ansible.cfg
  configured module search path = ['XXX/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = XXX/lib64/python3.9/site-packages/ansible
  ansible collection location = XXX/collections:/usr/share/ansible/plugins/modules
  executable location = XXX/bin/ansible
  python version = 3.9.7 (default, Apr 11 2022, 06:30:15) [GCC 8.5.0 20210514 (Red Hat 8.5.0-10.0.1)]
  jinja version = 3.0.3
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general
# XXX/collections/ansible_collections
Collection        Version
----------------- -------
community.general 5.4.0

Configuration

$ ansible-config dump --only-changed
COLLECTIONS_PATHS(XXX/ansible.cfg) = ['XXX/collections', '/usr/share/ansible/plugins/modules']
DEFAULT_STDOUT_CALLBACK(XXX/ansible.cfg) = community.general.diy
DEPRECATION_WARNINGS(XXX/ansible.cfg) = False
DISPLAY_SKIPPED_HOSTS(XXXX/ansible.cfg) = False
GALAXY_SERVER_LIST(XXX/ansible.cfg) = ['automation_hub', 'public_galaxy']
USE_PERSISTENT_CONNECTIONS(XXX/ansible.cfg) = True

OS / Environment

Oracle Linux Server 8.6

Additional Information

ansible.cfg:

[defaults]
stdout_callback = community.general.diy
[callback_diy]
playbook_on_include_msg = None

diy_test.yml:

---
- hosts: localhost
  gather_facts: no
  tasks:
    - ansible.builtin.include_tasks: diy_test_include.yml

diy_test_include.yml:

---
- name: In test_diy_include.yml
  ansible.builtin.debug:
    msg: "Test debug message"

Playbook run:

$ ansible-playbook diy_test.yml
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

PLAY [localhost] *****************************************************************************************************************************************************

TASK [ansible.builtin.include_tasks] *********************************************************************************************************************************
None

TASK [In test_diy_include.yml] ***************************************************************************************************************************************
ok: [localhost] => {
    "msg": "Test debug message"
}

PLAY RECAP ***********************************************************************************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Code of Conduct

ansibullbot commented 2 years ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 2 years ago

cc @theque5t click here for bot help