diff --git a/changelogs/fragments/no_target_syslog-var.yaml b/changelogs/fragments/no_target_syslog-var.yaml new file mode 100644 index 00000000000000..9929a690bd9040 --- /dev/null +++ b/changelogs/fragments/no_target_syslog-var.yaml @@ -0,0 +1,2 @@ +minor_changes: +- Added the ability to set ``DEFAULT_NO_TARGET_SYSLOG`` through the ``ansible_no_target_syslog`` variable on a task diff --git a/lib/ansible/config/base.yml b/lib/ansible/config/base.yml index 981c003b597414..dfb5fd136db809 100644 --- a/lib/ansible/config/base.yml +++ b/lib/ansible/config/base.yml @@ -897,10 +897,15 @@ DEFAULT_NO_LOG: DEFAULT_NO_TARGET_SYSLOG: name: No syslog on target default: False - description: Toggle Ansible logging to syslog on the target when it executes tasks. + description: + - Toggle Ansible logging to syslog on the target when it executes tasks. On Windows hosts this will disable a newer + style PowerShell modules from writting to the event log. env: [{name: ANSIBLE_NO_TARGET_SYSLOG}] ini: - {key: no_target_syslog, section: defaults} + vars: + - name: ansible_no_target_syslog + version_added: '2.10' type: boolean yaml: {key: defaults.no_target_syslog} DEFAULT_NULL_REPRESENTATION: diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py index 967c5b027cb504..89b80fb78b1a8b 100644 --- a/lib/ansible/plugins/action/__init__.py +++ b/lib/ansible/plugins/action/__init__.py @@ -714,7 +714,8 @@ def _update_module_args(self, module_name, module_args, task_vars): module_args['_ansible_check_mode'] = False # set no log in the module arguments, if required - module_args['_ansible_no_log'] = self._play_context.no_log or C.DEFAULT_NO_TARGET_SYSLOG + no_target_syslog = C.config.get_config_value('DEFAULT_NO_TARGET_SYSLOG', variables=task_vars) + module_args['_ansible_no_log'] = self._play_context.no_log or no_target_syslog # set debug in the module arguments, if required module_args['_ansible_debug'] = C.DEFAULT_DEBUG