I want to access only stdout_lines or stdout output part (i.e, online) from below debug output log but I get whole log.
I just mentioned related code here:
code:
- debug: msg=" {{ item.stdout_lines }} "
with_items: " {{ result.results }} "
Output:
ok: [192.168.0.1] => (item={'changed': True, '_ansible_no_log': False, 'stdout': u'[online]\r\n', '_ansible_item_result': True, 'item': u'process1', 'stderr': u'Shared connection to 192.168.154.241 closed.\r\n', 'rc': 0, 'stdout_lines': [u'[online]'], '_ansible_ignore_errors': None, 'failed': False}) => {
"changed": false,
"item": {
"changed": true,
"failed": false,
"item": "process1",
"rc": 0,
"stderr": "Shared connection to 192.168.0.1 closed.\r\n",
"stdout": "[online]\r\n",
"stdout_lines": [
"[online]"
]
},
"msg": " [u'[online]'] "
Best Answer
Well it looks like you are running ansible-playbook with the
-v
option. So you are seeing more information because you are in verbose mode.Also, since you are using
with_items
in your debug task you will see the contents of the current item displayed as that item is processed. You can control what gets displayed for each item by using the loop_control