mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 22:00:22 -07:00
Log device interaction and push labeled logs back to controller (#50028)
* Add session tracing support for network_cli, netconf and httapi connection * Add `persistent_log_messages` configuration option to log device inteaction in log file for network_cli, netconf and httapi connection type * Log jsonrpc request and response in log file is configuration option is enabled * Update docs to talk about warning shown when persistent_log_messages is on
This commit is contained in:
parent
c093ea5a28
commit
b2423e7602
6 changed files with 134 additions and 5 deletions
|
@ -99,6 +99,64 @@ Because the log files are verbose, you can use grep to look for specific informa
|
|||
|
||||
grep "p=28990" $ANSIBLE_LOG_PATH
|
||||
|
||||
|
||||
Enabling Networking device interaction logging
|
||||
----------------------------------------------
|
||||
|
||||
**Platforms:** Any
|
||||
|
||||
Ansible 2.8 features added logging of device interaction in log file to help diagnose and troubleshoot
|
||||
issues regarding Ansible Networking modules. The messages are logged in file pointed by ``log_path`` configuration
|
||||
option in Ansible configuration file or by set :envvar:`ANSIBLE_LOG_PATH` as mentioned in above section.
|
||||
|
||||
.. warning::
|
||||
The device interaction messages consist of command executed on target device and the returned response, as this
|
||||
log data can contain sensitive information including passwords in plain text it is disabled by default.
|
||||
Additionally, in order to prevent accidental leakage of data, a warning will be shown on every task with this
|
||||
setting eneabled specifying which host has it enabled and where the data is being logged.
|
||||
|
||||
Be sure to fully understand the security implications of enabling this option. The device interaction logging can be enabled either globally by setting in configuration file or by setting environment or enabled on per task basis by passing special variable to task.
|
||||
|
||||
Before running ``ansible-playbook`` run the following commands to enable logging::
|
||||
|
||||
# Specify the location for the log file
|
||||
export ANSIBLE_LOG_PATH=~/ansible.log
|
||||
|
||||
|
||||
Enable device interaction logging for a given task
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
- name: get version information
|
||||
ios_command:
|
||||
commands:
|
||||
- show version
|
||||
vars:
|
||||
ansible_persistent_log_messages: True
|
||||
|
||||
|
||||
To make this a global setting, add the following to your ``ansible.cfg`` file:
|
||||
|
||||
.. code-block:: ini
|
||||
|
||||
[persistent_connection]
|
||||
log_messages = True
|
||||
|
||||
or enable environment variable `ANSIBLE_PERSISTENT_LOG_MESSAGES`
|
||||
|
||||
# Enable device interaction logging
|
||||
export ANSIBLE_PERSISTENT_LOG_MESSAGES=True
|
||||
|
||||
If the task is failing at the time on connection initialization itself it is recommended to enable this option
|
||||
globally else if an individual task is failing intermittently this option can be enabled for that task itself to
|
||||
find the root cause.
|
||||
|
||||
After Ansible has finished running you can inspect the log file which has been created on the ansible-controller
|
||||
|
||||
.. note:: Be sure to fully understand the security implications of enabling this option as it can log sensitive
|
||||
information in log file thus creating security vulnerability.
|
||||
|
||||
|
||||
Isolating an error
|
||||
------------------
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue