Inconsistent of the registered data structure

218 views
Skip to first unread message

Steve Kieu

unread,
Feb 9, 2016, 12:13:05 AM2/9/16
to Ansible Project
Hi team,

With ansible 2 in mind ...

The below playbook run fine 

- name: add
  hosts: docker-host
  tasks:
    - block:
        - name: test
          shell: "su - jumbo -c 'cd /tmp ; ls'"
          register: out
          failed_when: "out.rc != 0"
        - debug: "msg='out: {{out.rc}}'"


However I have another one

- name: test1-web-au
  hosts: test1-web-au
  tasks:
    - block:
        - name: make
          shell: "su - jumbo -c 'cd {{SITE_DIR}}/{{APP_DIR}} && make'"
          register: result
          failed_when: "result.rc != 0"
        - debug: "msg='DEBUG: {{result}}'"

The second one give error:

fatal: [test1-web-au]: FAILED! => {"failed": true, "msg": "The conditional check 'result.rc != 0' failed. The error was: error while evaluating conditional (result.rc != 0): 'dict object' has no attribute 'rc'"}

The only difference is that the make command ouput a lot of text. Somehow result.rc is not a value anymore, it is a dict. This is very inconsistent .

Trying to look into the debug message, clearly they have different keys 

The one that is normal 

    "msg": "DEBUG: {u'changed': True, u'end': u'2016-02-09 04:56:47.752599', u'stdout': u'behat_style.xml\\nbin\\nbugfree.json\\nbugfree-testing.json\\ncache\\ncomposer.json\\ncomposer.lock\\nconf\\nconfig.rb\\ndoc\\ngrunt\\nGruntfile.js\\njibs\\nkarma.conf.js\\nlib\\nlocale\\nMakefile\\nMakefile_help.mak\\nnode_modules\\nnpm-shrinkwrap.json\\npackage.json\\nphpunit.xml\\nscripts\\nscss\\nskel\\nsql\\nsrc\\nstyleguide\\ntesting\\ntmp\\nvendor\\nweb', u'cmd': u\"su - jumbo -c 'cd /www/sites/test1_web_au && ls'\", u'start': u'2016-02-09 04:56:47.701976', u'delta': u'0:00:00.050623', u'stderr': u'', u'rc': 0, 'stdout_lines': [u'behat_style.xml', u'bin', u'bugfree.json', u'bugfree-testing.json', u'cache', u'composer.json', u'composer.lock', u'conf', u'config.rb', u'doc', u'grunt', u'Gruntfile.js', u'jibs', u'karma.conf.js', u'lib', u'locale', u'Makefile', u'Makefile_help.mak', u'node_modules', u'npm-shrinkwrap.json', u'package.json', u'phpunit.xml', u'scripts', u'scss', u'skel', u'sql', u'src', u'styleguide', u'testing', u'tmp', u'vendor', u'web'], u'warnings': [u\"Consider using 'become', 'become_method', and 'become_user' rather than running su\"]}"
}


And the one with long output - the rc is in module_stdout  so to access this need result.module_stdout.rc 


    "msg": "DEBUG: {'module_stderr': u'', 'changed': False, 'module_stdout': u'{\"changed\": true, \"end\": \"2016-02-09 04:53:09.033206\", \"stdout\": \"Installing dependences as per composer.lock.\\\\n\\\\u001b[30;43mWarning: This development build of composer is over 30 days old. It is recommended to update it by running \\\\\"./bin/composer self-update\\\\\" to get the latest version.\\\\u001b[39;49m\\\\n\\\\u001b[32mLoading composer repositories with package information\\\\u001b[39m\\\\n\\\\u001b[32mInstalling dependencies (including require-dev) from lock file\\\\u001b[39m\\\\nNothing to install or update\\\\n\\\\u001b[32mGenerating optimized autoload files\\\\u001b[39m\\\\nInstalling dependences as per composer.lock.\\\\n\\\\u001b[30;43mWarning: This development build of composer is over 30 days old. It is recommended to update it by running \\\\\"./bin/composer self-update\\\\\" to get the latest version.\\\\u001b[39;49m\\\\n\\\\u001b[32mLoading composer repositories with package information\\\\u001b[39m\\\\n\\\\u001b[32mInstalling dependencies (including require-dev) from lock file\\\\u001b[39m\\\\nNothing to install or update\\\\n\\\\u001b[32mGenerating optimized autoload files\\\\u001b[39m\\\\n - Checking for config updates\\\\n - Rebuilding css from scss\\\\n\\\\u001b[4mRunning \\\\\"sass:dist\\\\\" (sass) task\\\\u001b[24m\\\\n\\\\n\\\\u001b[32mDone, without errors.\\\\u001b[39m\\\\n\\\\n\\\\nExecution Time (2016-02-09 04:51:58 UTC)\\\\nsass:dist   1.9s  \\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587\\\\u2587 100%\\\\nTotal 1.9s\\\\n\\\\n - Building meta based on current source.\\\\n\\\\r 1/8 [===>------------------------]  12% Elapsed:  1 sec\\\\r 2/8 [=======>--------------------]  25% Elapsed:  1 sec\\\\r 3/8 [==========>-----------------]  37% Elapsed:  1 sec\\\\r 4/8 [==============>-------------]  50% Elapsed:  1 sec\\\\r 5/8 [=================>----------]  62% Elapsed:  1 sec\\\\r 6/8 [=====================>------]  75% Elapsed:  1 sec\\\\r 7/8 [========================>---]  87% Elapsed:  1 sec\\\\r 8/8 [============================] 100% Elapsed:  1 sec\\\\n - Building one ugly javascript file per site variant\\\\n\\\\r 1/3 [=========>------------------]  33% Elapsed:  1 sec Building: pub.AU           \\\\r 2/3 [==================>---------]  66% Elapsed: 6 secs Building: admin.AU           \\\\r 3/3 [============================] 100% Elapsed: 14 secs                              \\\\n - Building one ugly css file per site variant\\\\n\\\\r 1/1 [============================] 100% Elapsed:  1 sec\\\\n - Building swagger based on current meta.\\\\n\\\\r 1/7 [====>-----------------------]  14% Elapsed:  1 sec\\\\r 2/7 [========>-------------------]  28% Elapsed:  1 sec\\\\r 3/7 [============>---------------]  42% Elapsed:  1 sec\\\\r 4/7 [================>-----------]  57% Elapsed:  1 sec\\\\r 5/7 [====================>-------]  71% Elapsed:  1 sec\\\\r 6/7 [========================>---]  85% Elapsed:  1 sec\\\\r 7/7 [============================] 100% Elapsed:  1 sec\\\\n - Config sanity check.\\\\n - building apache vhosts.\\\\n - Restarting apache:  - Building meta based on current source.\\\\n\\\\r 1/8 [===>------------------------]  12% Elapsed:  1 sec\\\\r 2/8 [=======>--------------------]  25% Elapsed:  1 sec\\\\r 3/8 [==========>-----------------]  37% Elapsed:  1 sec\\\\r 4/8 [==============>-------------]  50% Elapsed:  1 sec\\\\r 5/8 [=================>----------]  62% Elapsed:  1 sec\\\\r 6/8 [=====================>------]  75% Elapsed: 2 secs\\\\r 7/8 [========================>---]  87% Elapsed: 2 secs\\\\r 8/8 [============================] 100% Elapsed: 2 secs\\\\n-- node 1 --\\\\n No updates found\\\\n-- node 2 --\\\\n No updates found\\\\n-- node 3 --\\\\n No updates found\\\\n-- node 4 --\\\\n No updates found\\\\n-- node 128 --\\\\n No updates found\\\\n-- admin --\\\\n No updates found\\\\n-- cart --\\\\n No updates found\\\\n-- affiliate --\\\\n No updates found\\\\n-- metrics --\\\\n No updates found\\\\n - Creating sitemaps\\\\nInstalling dependences as per composer.lock.\\\\n\\\\u001b[30;43mWarning: This development build of composer is over 30 days old. It is recommended to update it by running \\\\\"./bin/composer self-update\\\\\" to get the latest version.\\\\u001b[39;49m\\\\n\\\\u001b[32mLoading composer repositories with package information\\\\u001b[39m\\\\n\\\\u001b[32mInstalling dependencies (including require-dev) from lock file\\\\u001b[39m\\\\nNothing to install or update\\\\n\\\\u001b[32mGenerating optimized autoload files\\\\u001b[39m\\\\n - Restarting all daemons\\\\n - customer-locator (disabled)\\\\n - event-hub (running 9344)\\\\n - restart customer-locator\\\\n - restart event-hub\\\\n - customer-locator (disabled)\\\\n - event-hub (running 10125)\\\\n - Flushing web nodes.\\\\n - Initialising perl database cache.\", \"cmd\": \"su - jumbo -c \\'cd /www/sites/test1_web_au && make\\'\", \"rc\": 0, \"start\": \"2016-02-09 04:51:15.791037\", \"stderr\": \"DEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecated-webkit-gradient.scss\\\\nDEPRECATION WARNING: Passing 100%, a non-string value, to unquote()\\\\nwill be an error in future versions of Sass.\\\\n        on line 27 of /www/sites/base_web/scss/bourbon/helpers/_deprecatedclose failed in file object destructor:\\r\\nError in sys.excepthook:\\r\\n\\r\\nOriginal exception was:\\r\\n', 'failed': True, 'msg': u'MODULE FAILURE', 'parsed': False}"
}


I think it is a bug. 

please let me know what I am doing wrong, or I will file a bug report.

Kind regards

Steve Kieu

unread,
Feb 9, 2016, 12:29:16 AM2/9/16
to Ansible Project
Apart from that problems ansible gives error after running the make command even though the make command exit status is 0 (Manually login and run make and check exit status is 0.

Ansibel says something like 

Error in sys.excepthook:\r\n\r\nOriginal exception was:\r\n"

I guess that ansible has a buffer limit size of the command output, and when output is truncated the object re-contructions is wrong and got error thus can explain there is no key rc in tehre and ansibel gives error.

Steve Kieu

unread,
Feb 9, 2016, 12:51:48 AM2/9/16
to Ansible Project
I confirmed that the too long output (or maybe some special characters in there ) caused the problems.

I just redirect the make command to /dev/null and things started to work properly.

Is it a known problems? Should I file bug report?

Thanks

Alex Leonhardt

unread,
Feb 9, 2016, 1:06:25 AM2/9/16
to ansible...@googlegroups.com
Hi, nice catch! Sounds like a bug to me, I've also seen similar behaviour but as my output wasn't consistently getting past whatever the buffer is, I wasn't able to reliably reproduce it.

That what's being returned changes is very irritating and should be fixed.

Alex
--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ca19fc38-85ee-43e9-8ca1-2f0ecdf2b301%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Steve Kieu

unread,
Feb 9, 2016, 1:20:01 AM2/9/16
to Ansible Project
Hi,

Not sure if the stdout or stderr are different but I saw one command with much larger output than the make command and it is fine.

However I can consistently fail it using my make command and something in stdout that mess it up.


Reply all
Reply to author
Forward
0 new messages