Hey Jonathan - thanks for the suggestion, but -v doesn't help. If I
include no_log: True, including -v just outputs the same:
TASK [Confirming ownership of filesystems]
*************************************
ok: [localhost] => (item=(censored due to no_log)) => {"censored": "the
output has been hidden due to the fact that 'no_log: true' was specified
for this result"}
ok: [localhost] => (item=(censored due to no_log)) => {"censored": "the
output has been hidden due to the fact that 'no_log: true' was specified
for this result"}
Rob
On Monday, January 28, 2019 at 12:31:43 PM UTC-5, Jonathan Lozada De La
Matta wrote:
>
> using -v should be enough to show changes but, not the whole output.
>
> On Mon, Jan 28, 2019 at 10:54 AM <[email protected] <javascript:>>
> wrote:
>
>> Hey all-
>>
>> I'm using stat and with_items to check proper ownership of various
>> files. Is there any way to reduce the volume of output (i.e., eliminate
>> everything in red, below)?
>>
>> rowagn@localhost:~/data-platform/oracle/ansible/db12r2$ cat test.yml
>> ---
>> - hosts: localhost
>> tasks:
>> - name: Stat filesystems
>> stat: path="{{ item }}"
>> with_items:
>> - /dev
>> - /home
>> register: filesystems_stat
>>
>> - name: Confirming ownership of filesystems
>> assert:
>> that: "{{ item.stat.pw_name == 'root' }}"
>> with_items: "{{ filesystems_stat.results }}"
>> loop_control:
>> label: "{{ item.item }}"
>>
>> - name: Stat filesystem no with_items
>> stat: path="/dev"
>> register: dev_stat
>>
>> - name: Confirming ownership of dev
>> assert:
>> that: "{{ dev_stat.stat.pw_name == 'root' }}"
>>
>> rowagn@localhost:~/data-platform/oracle/ansible/db12r2$ ansible-playbook
>> -i "localhost," -c local test.yml
>>
>> PLAY [localhost]
>> ***************************************************************
>>
>> TASK [setup]
>> *******************************************************************
>> ok: [localhost]
>>
>> TASK [Stat filesystems]
>> ********************************************************
>> ok: [localhost] => (item=/dev)
>> ok: [localhost] => (item=/home)
>>
>> TASK [Confirming ownership of filesystems]
>> *************************************
>> ok: [localhost] => (item=/dev) => {
>> "changed": false,
>> "item": {
>> "changed": false,
>> "invocation": {
>> "module_args": {
>> "checksum_algorithm": "sha1",
>> "follow": false,
>> "get_checksum": true,
>> "get_md5": true,
>> "mime": false,
>> "path": "/dev"
>> },
>> "module_name": "stat"
>> },
>> "item": "/dev",
>> "stat": {
>> "atime": 1548686732.628008,
>> "ctime": 1548686731.6280031,
>> "dev": 6,
>> "executable": true,
>> "exists": true,
>> "gid": 0,
>> "gr_name": "root",
>> "inode": 2,
>> "isblk": false,
>> "ischr": false,
>> "isdir": true,
>> "isfifo": false,
>> "isgid": false,
>> "islnk": false,
>> "isreg": false,
>> "issock": false,
>> "isuid": false,
>> "mode": "0755",
>> "mtime": 1548686731.6280031,
>> "nlink": 21,
>> "path": "/dev",
>> "pw_name": "root",
>> "readable": true,
>> "rgrp": true,
>> "roth": true,
>> "rusr": true,
>> "size": 4340,
>> "uid": 0,
>> "wgrp": false,
>> "woth": false,
>> "writeable": false,
>> "wusr": true,
>> "xgrp": true,
>> "xoth": true,
>> "xusr": true
>> }
>> },
>> "msg": "All assertions passed"
>> }
>> ok: [localhost] => (item=/home) => {
>> "changed": false,
>> "item": {
>> "changed": false,
>> "invocation": {
>> "module_args": {
>> "checksum_algorithm": "sha1",
>> "follow": false,
>> "get_checksum": true,
>> "get_md5": true,
>> "mime": false,
>> "path": "/home"
>> },
>> "module_name": "stat"
>> },
>> "item": "/home",
>> "stat": {
>> "atime": 1548687317.493867,
>> "ctime": 1519054783.2176335,
>> "dev": 64512,
>> "executable": true,
>> "exists": true,
>> "gid": 0,
>> "gr_name": "root",
>> "inode": 13631489,
>> "isblk": false,
>> "ischr": false,
>> "isdir": true,
>> "isfifo": false,
>> "isgid": false,
>> "islnk": false,
>> "isreg": false,
>> "issock": false,
>> "isuid": false,
>> "mode": "0755",
>> "mtime": 1519054783.2176335,
>> "nlink": 5,
>> "path": "/home",
>> "pw_name": "root",
>> "readable": true,
>> "rgrp": true,
>> "roth": true,
>> "rusr": true,
>> "size": 4096,
>> "uid": 0,
>> "wgrp": false,
>> "woth": false,
>> "writeable": false,
>> "wusr": true,
>> "xgrp": true,
>> "xoth": true,
>> "xusr": true
>> }
>> },
>> "msg": "All assertions passed"
>> }
>>
>> TASK [Stat filesystem no with_items]
>> *******************************************
>> ok: [localhost]
>>
>> TASK [Confirming ownership of dev]
>> *********************************************
>> ok: [localhost] => {
>> "changed": false,
>> "msg": "All assertions passed"
>> }
>>
>> PLAY RECAP
>> *********************************************************************
>> localhost : ok=5 changed=0 unreachable=0
>> failed=0
>>
>> Is there any way to avoid printing the entire stat dictionary for each
>> item? I have tried no_log: True, but that eliminates everything (i.e., so
>> the output doesn't even include the path being tested):
>>
>> TASK [Confirming ownership of filesystems]
>> *************************************
>> ok: [localhost] => (item=(censored due to no_log)) => {"censored": "the
>> output has been hidden due to the fact that 'no_log: true' was specified
>> for this result"}
>> ok: [localhost] => (item=(censored due to no_log)) => {"censored": "the
>> output has been hidden due to the fact that 'no_log: true' was specified
>> for this result"}
>>
>> Ideally, the output would be similar to that when not using with_items.
>> i.e.:
>>
>> TASK [Confirming ownership of filesystems]
>> *************************************
>> ok: [localhost] => (item=/dev) => {
>> "changed": false,
>> "msg": "All assertions passed"
>> }
>> ok: [localhost] => (item=/home) => {
>> "changed": false,
>> "msg": "All assertions passed"
>> }
>>
>> Thanks for any advice.
>>
>> Rob
>>
>> --
>> 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] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/7facb073-ba90-4af3-ab4b-b4cc830f47bd%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/ansible-project/7facb073-ba90-4af3-ab4b-b4cc830f47bd%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
>
> Jonathan lozada de la matta
>
> AUTOMATION PRACTICE
>
>
>
>
>
>
--
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/28498c53-7202-4c7e-86ae-4f6cfe6b511e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.