Hey Brian,
I do not think that the pprint filter on a multi-item task make the output
any readable. Based on my previous example, if I do
- name: post-deployment tasks executed
local_action: shell {{ item }}
with_items: cf_post_deployment_tasks
when: cf_post_deployment_tasks is defined
register: post
tags:
- cf
- post-deploy
- debug: msg="{{ post | pprint }}"
when: post is defined
tags:
- cf
- post-deploy
and cf_post_deployment_tasks is a list of the following items:
cf_post_deployment_tasks:
- cd tasks; ls
- echo -e "blah blah blah\nsecond line"
I get:
TASK: [debug msg="Undefined"]
*************************************************
ok: [localhost] => {
"item": "",
"msg": "{'changed': True,\n 'msg': 'All items completed',\n 'results':
[{u'changed': True,\n u'cmd': u'cd tasks; ls ',\n
u'delta': u'0:00:00.004785',\n u'end': u'2014-02-21
15:17:40.739631',\n 'invocation': {'module_args': u'cd tasks;
ls',\n 'module_name': 'shell'},\n
'item': 'cd tasks; ls',\n u'rc': 0,\n u'start':
u'2014-02-21 15:17:40.734846',\n u'stderr': u'',\n
u'stdout':
u'cf_app_remap.yml\\ncf_app_route.yml\\ncf_deployment.yml\\nconcat_files.yml\\nnpm_install.yml'},\n
{u'changed': True,\n u'cmd': u'echo -e blah"
}
If I use the item-by-item approach to output, that is
- debug: msg="{{ item | pprint }}"
when: post is defined
with_items: post.results
tags:
- cf
- post-deploy
the output is lengthier and still a mess:
TASK: [debug msg="''"]
********************************************************
ok: [localhost] => (item={'item': 'cd tasks; ls', u'delta':
u'0:00:00.004356', u'cmd': u'cd tasks; ls ', u'end': u'2014-02-21
15:18:59.617802', u'stderr': u'', u'stdout':
u'cf_app_remap.yml\ncf_app_route.yml\ncf_deployment.yml\nconcat_files.yml\nnpm_install.yml',
'invocation': {'module_name': 'shell', 'module_args': u'cd tasks; ls'},
u'changed': True, u'rc': 0, u'start': u'2014-02-21 15:18:59.613446'}) => {
"item": {
"changed": true,
"cmd": "cd tasks; ls ",
"delta": "0:00:00.004356",
"end": "2014-02-21 15:18:59.617802",
"invocation": {
"module_args": "cd tasks; ls",
"module_name": "shell"
},
"item": "cd tasks; ls",
"rc": 0,
"start": "2014-02-21 15:18:59.613446",
"stderr": "",
"stdout":
"cf_app_remap.yml\ncf_app_route.yml\ncf_deployment.yml\nconcat_files.yml\nnpm_install.yml"
},
"msg": "{u'changed': True,\n u'cmd': u'cd tasks; ls ',\n u'delta':
u'0:00:00.004356',\n u'end': u'2014-02-21 15:18:59.617802',\n 'invocation':
{'module_args': u'cd tasks; ls', 'module_name': 'shell'},\n 'item': 'cd
tasks; ls',\n u'rc': 0,\n u'start': u'2014-02-21 15:18:59.613446',\n
u'stderr': u'',\n u'stdout':
u'cf_app_remap.yml\\ncf_app_route.yml\\ncf_deployment.yml\\nconcat_files.yml\\nnpm_install.yml'}"
}
ok: [localhost] => (item={'item': 'echo -e "blah blah blah\\nsecond line"',
u'delta': u'0:00:00.003149', u'cmd': u'echo -e "blah blah blah\\nsecond
line" ', u'end': u'2014-02-21 15:18:59.703624', u'stderr': u'', u'stdout':
u'-e blah blah blah\nsecond line', 'invocation': {'module_name': 'shell',
'module_args': u'echo -e "blah blah blah\\nsecond line"'}, u'changed':
True, u'rc': 0, u'start': u'2014-02-21 15:18:59.700475'}) => {
"item": {
"changed": true,
"cmd": "echo -e \"blah blah blah\\nsecond line\" ",
"delta": "0:00:00.003149",
"end": "2014-02-21 15:18:59.703624",
"invocation": {
"module_args": "echo -e \"blah blah blah\\nsecond line\"",
"module_name": "shell"
},
"item": "echo -e \"blah blah blah\\nsecond line\"",
"rc": 0,
"start": "2014-02-21 15:18:59.700475",
"stderr": "",
"stdout": "-e blah blah blah\nsecond line"
},
"msg": "{u'changed': True,\n u'cmd': u'echo -e blah"
}
On Fri, Feb 21, 2014 at 12:47 PM, Brian Coca <[email protected]> wrote:
> its very simple:
> - debug: msg={{post|pprint}}
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ansible-project/Ucg4FeGTCmw/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.