Logging AAP information on a target system
Magnus Glantz
Principal Specialist Solution Architect at Red Hat | author | spokesperson | linux | k8s | ansible | security
A customer of mine recently requested a new feature, which was added about a month ago. It adds a new configuration item called TARGET_LOG_INFO to Ansible Core 2.17.1.
This allows you to append any arbitrary information to the target system log. Most interestingly, is that you can use this, to add things like awx_job_id or awx_user_id to the target systems log, meaning the audit trail from a target system can more easily get connected to a specific Ansible Automation Platform job_id or user_id, or any other thing you have in mind.
Here's how you get that to work:
---
- name: Check if a server is alive
hosts: all
tasks:
- name: Set TARGET_LOG_INFO
ansible.builtin.set_fact:
ansible_target_log_info: "aap_job_id = {{ awx_job_id }} aap_user_id = {{ awx_user_id }} runs:"
- name: Log into the server and check that the ping modules returns output
ansible.builtin.ping:
data: pong from Ansible
That was all! Enjoy :)