community.general icon indicating copy to clipboard operation
community.general copied to clipboard

community.general.selective does not print task output to file

Open alex-weiner-waters opened this issue 2 years ago • 1 comments

Summary

When I set ANSIBLE_LOG_PATH and also set environment variable ANSIBLE_STDOUT_CALLBACK="community.general.selective" , the console output works well for tasks that are tagged with tags: [print_action], but I do not see the task output in the log file. If I increase verbosity I will get ansible messages in the log file, but not the task output.

I get the same result if I set stdout_callback=community.general.selective rather than using environment variable.

Issue Type

Bug Report

Component Name

community.general.selective

Ansible Version

$ ansible [core 2.11.9] 
  config file = /workspaces/ciinfrastructurescripts_TSD-2370_ImplementAgentLevelTesting/build-slaves/playbook/ansible.cfg
  configured module search path = ['/home/vscode/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/vscode/.local/lib/python3.8/site-packages/ansible
  ansible collection location = /home/vscode/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/vscode/.local/bin/ansible
  python version = 3.8.10 (default, Jun  2 2021, 10:49:15) [GCC 9.4.0]
  jinja version = 3.1.0
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general

```# /home/vscode/.local/lib/python3.8/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 3.4.0  

# /home/vscode/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 2.5.1  


### Configuration

```console (paste below)
$ PS /workspaces/ciinfrastructurescripts_TSD-2370_ImplementAgentLevelTesting/build-slaves/playbook> ansible-config dump --only-changed                 
DEFAULT_HOST_LIST(/workspaces/ciinfrastructurescripts_TSD-2370_ImplementAgentLevelTesting/build-slaves/playbook/ansible.cfg) = ['/workspaces/ciinfrastructurescripts_TSD-2370_ImplementAgentLevelTesting/build-slaves/playbook/prod-inventory.yaml']
DEFAULT_LOG_PATH(env: ANSIBLE_LOG_PATH) = /workspaces/ciinfrastructurescripts_TSD-2370_ImplementAgentLevelTesting/build-slaves/playbook/agent_tests/logs/AgentTests_vs2022slaves2022-06-17T13.59.20.txt
DEFAULT_STDOUT_CALLBACK(env: ANSIBLE_STDOUT_CALLBACK) = community.general.selective
DEFAULT_VAULT_PASSWORD_FILE(/workspaces/ciinfrastructurescripts_TSD-2370_ImplementAgentLevelTesting/build-slaves/playbook/ansible.cfg) = /workspaces/ciinfrastructurescripts_TSD-2370_ImplementAgentLevelTesting/build-slaves/playbook/vault_password_file.py
HOST_KEY_CHECKING(/workspaces/ciinfrastructurescripts_TSD-2370_ImplementAgentLevelTesting/build-slaves/playbook/ansible.cfg) = False
TRANSFORM_INVALID_GROUP_CHARS(/workspaces/ciinfrastructurescripts_TSD-2370_ImplementAgentLevelTesting/build-slaves/playbook/ansible.cfg) = ignore

OS / Environment

Running in a dev container in Visual Studio Code, this is what I get from this command:
uname -r | awk -F- '{print $1}' 5.10.102.1-microsoft-standard-WSL2

With devcontainer.json specifying: "name": "Ubuntu", "build": { "dockerfile": "Dockerfile", // Update 'VARIANT' to pick an Ubuntu version. Rebuild the container // if it already exists to update. Available variants: 18.04, 20.04 "args": { "VARIANT": "20.04" } },

Steps to Reproduce

Set these values in defaults section of ansible.cfg log_path = ./logfile.txt stdout_callback=community.general.selective

With certain Tasks tagged with tags: [print_action]

Run the play with no verbose flags. The console output will show only the task output for tasks tagged with print_action, as expected. However, the log file will have no entries.

Remove the entries in the ansible.cfg file and the default console output will return and will be logged in to logfile.txt

Expected Results

With stdout_callback=community.general.selective, I expected the tagged task output that is sent to the console to also get sent to the log file.

Actual Results

No output was sent to the log file.

Code of Conduct

  • [X] I agree to follow the Ansible Code of Conduct

alex-weiner-waters avatar Jun 17 '22 14:06 alex-weiner-waters

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 avatar Jun 17 '22 14:06 ansibullbot