Created
September 25, 2013 08:24
-
-
Save vincentvdk/6696654 to your computer and use it in GitHub Desktop.
ansible register variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
running from Ansible works : | |
→ ansible 192.168.13.42 -m shell -a "update-alternatives --display java | grep currently | awk '{print \$5}'" -u root -k [master] | |
SSH password: | |
192.168.13.42 | success | rc=0 >> | |
/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java | |
running from playbook | |
TASK: [return java_alternatives [DEBUG]] ************************************** | |
ok: [192.168.13.42] => {"item": "", "msg": "jdk = ,,,,,,,,,,"} | |
TASK: [update-alternatives OpenJDK] ******************************************* | |
fatal: [192.168.13.42] => error while evaluating conditional: {% if {u'changed': True, u'end': u'2013-09-25 04:23:54.952150', u'stdout': u'/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java', 'item': '', u'cmd': u"update-alternatives --display java | grep currently | awk {'print $5'} ", u'rc': 0, u'start': u'2013-09-25 04:23:54.930993', u'stderr': u'', u'delta': u'0:00:00.021157', 'invocation': {'module_name': 'shell', 'module_args': u"update-alternatives --display java | grep currently | awk {'print $5'}"}, 'stdout_lines': [u'/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java']} != "/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java" %} True {% else %} False {% endif %} | |
FATAL: all hosts have already failed -- aborting | |
this is a part of the playbook | |
- name: detect and register current java | |
24 action: shell update-alternatives --display java | grep currently | awk '{print \$5}' | |
25 register: java_alternatives | |
26 | |
27 - name: update-alternatives Oracle JDK | |
28 action: command update-alternatives --set java /usr/java/jdk1.6.0_43/bin/java | |
29 when: java == "oraclejdk" | |
30 changed_when: $java_alternatives != "/usr/java/jdk1.6.0_43/bin/java" | |
31 | |
32 - name: return java_alternatives [DEBUG] | |
33 action: debug msg="jdk = $ENV(java_alternatives)" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment