octplane / ansible_stdout_compact_logger

Ansible Stdout Compact Logger

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tasks using with_items show as green even if an item is changed

asmartin opened this issue · comments

Thanks for creating the compact logger callback for ansible - this is a great way to save space! I did notice what appears to be a bug - on tasks that use with_items, if a particular item is changed but others are not, it still reports the whole task as green when it should report it as orange. Moreover, it does not show the diff, even if --diff is provided.

Here's an example task:

 - name: template config files
   template: src={{ item.src }} dest={{ item.dest }} mode={{ item.mode|default(omit) }}
   with_items:
    - { src: "calm_file.tmpl.j2", dest: "/usr/share/websvn/templates/calm/file.tmpl" }
    - { src: "calm_index.tmpl.j2", dest: "/usr/share/websvn/templates/calm/index.tmpl" }
    - { src: "config.php.j2", dest: "/etc/websvn/config.php" }
    - { src: "index.html.j2", dest: "{{ www_root }}/index.html", mode: "0644" }
    - { src: "svn_deb_conf.inc.j2", dest: "/etc/websvn/svn_deb_conf.inc" }

And here's the normal output:

TASK [servers/vcs : template config files] *****************
ok: [vcs] => (item={u'dest': u'/usr/share/websvn/templates/calm/file.tmpl', u'src': u'calm_file.tmpl.j2'})
ok: [vcs] => (item={u'dest': u'/usr/share/websvn/templates/calm/index.tmpl', u'src': u'calm_index.tmpl.j2'})
--- before: /etc/websvn/config.php
+++ after: dynamically generated
@@ -1,5 +1,6 @@
 <?php
+// TEST LINE
 // WebSVN - Subversion repository viewing via the web using PHP
 // Copyright (C) 2004-2006 Tim Armes
 //

changed: [vcs] => (item={u'dest': u'/etc/websvn/config.php', u'src': u'config.php.j2'})
ok: [vcs] => (item={u'dest': u'/var/www/index.html', u'src': u'index.html.j2', u'mode': u'0644'})
ok: [vcs] => (item={u'dest': u'/etc/websvn/svn_deb_conf.inc', u'src': u'svn_deb_conf.inc.j2'})

In comparison, here's the output with ansible_stdout_compact_logger enabled:

[2017-01-09 08:34:05.356555] servers/myserver : template config files | myserver | SUCCESS | 7090ms

I've been testing this with ansible 2.2.0.0.

If have fixed the multiple item stuff (see test-issues-1.yml).

@asmartin please report if still unfixed. Sorry for the lag, but I didnt' receive any notification from GH when you opened the issue....

Thanks for the quick fix! This does appear to be resolved in my test case as well