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
--
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/12dd620e-e9c1-4c58-a594-7e0f49acdaaf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.