Ansible operator logs

11/14/2019

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?

-- Al K
ansible
kubernetes

1 Answer

11/14/2019

Q: "I'd like to add some sort of ID to each entry generated by the output of Ansible module."

A: Try ansible-runner. For example running playbook example1.yml

$ cat test_01/project/example1.yml
- hosts: test_01
  tasks:
    - debug:
        var: inventory_hostname

$ ansible-runner -p example1.yml run test_01

will create an artifacts' tree with the complete log.

$ 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

Profiling might be useful as well.

-- Vladimir Botka
Source: StackOverflow