<p>We have implemented Ansible operator. We've got some bugs with it especially when we run in parallel. When they run in parallel it is difficult to track messages from ansible container to which object the message is related to. I'd like to add some sort of ID to each entry generated by output of ansible module. The straight forward approach would be modify each module execution to add ID, but this doesn't look nice. Is there any better solution?</p>

<blockquote>
  <p>Q: <em>"I'd like to add some sort of ID to each entry generated by the output of Ansible module."</em></p>
</blockquote>

<p>A: Try <a href="https://ansible-runner.readthedocs.io/en/latest/" rel="nofollow noreferrer">ansible-runner</a>. For example running playbook example1.yml</p>

<pre><code>$ cat test_01/project/example1.yml
- hosts: test_01
  tasks:
    - debug:
        var: inventory_hostname

$ ansible-runner -p example1.yml run test_01
</code></pre>

<p>will create an artifacts' tree with the complete log.</p>

<pre><code>$ tree test_01/artifacts/
test_01/artifacts/
└── 6ead1711-64a6-4cd1-9789-b32f407bc7f9
    ├── command
    ├── fact_cache
    ├── job_events
    │   ├── 1-93b14363-09bd-4817-8d7e-980afd2c9a88.json
    │   ├── 2-645d865d-16b9-7d1b-3747-000000000020.json
    │   ├── 3-645d865d-16b9-7d1b-3747-000000000022.json
    │   ├── 4-8f126531-b0e2-457d-9f8f-ec4220b9cbce.json
    │   ├── 5-0da7fe14-4314-440c-8aca-853a5828b9e8.json
    │   └── 6-57336e18-6510-4f30-a1db-94a684904a0d.json
    ├── rc
    ├── status
    └── stdout

3 directories, 10 files
</code></pre>

<p><a href="https://ansible-runner.readthedocs.io/en/latest/intro.html#runner-profiling-data-directory" rel="nofollow noreferrer">Profiling</a> might be useful as well.</p>
