Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Execute java version check in check mode #527

Merged

Conversation

katsukamaru
Copy link

This PR is related to this issue.
#525

This problem is happened in --check mode, because in check mode ignored test for java_full_path and does not register it.
So this PR changed to execute in check mode and register java_full_path.

@elasticmachine
Copy link
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@Crazybus
Copy link
Contributor

So this PR changed to execute in check mode and register java_full_path.

Does this change allow you to run check-mode successfully? Your comment sounds like you meant to set check_mode: yes but the changes have it set to no.

@Crazybus
Copy link
Contributor

jenkins test this please

@katsukamaru
Copy link
Author

katsukamaru commented Jan 15, 2019

@Crazybus thank you for your message and added the results in my local environment.

check_mode: yes means that ansible does not execute with --check.
My change check_mode: no means actually execute in --check.

And below are results in my environment.

elastic/master branch
ansible-playbook -i hosts playbook/es-c1.yml --check -v -l 172.20.0.54

TASK [elastic.elasticsearch : Get the installed java path] ************************************************************************************************************************************************
skipping: [172.20.0.54] => {"changed": false, "msg": "skipped, running in check mode"}

TASK [elastic.elasticsearch : correct java version selected] **********************************************************************************************************************************************
fatal: [172.20.0.54]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'stdout'\n\nThe error appears to have been in '/home/admin/.ansible/roles/elastic.elasticsearch/tasks/java.yml': line 24, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: correct java version selected\n  ^ here\n"}

...

katsukamaru:java-version-check-in-check-mode branch

ansible-playbook -i hosts playbook/es-c1.yml --check -v -l 172.20.0.54

TASK [elastic.elasticsearch : Get the installed java path] ************************************************************************************************************************************************
ok: [172.20.0.54] => {"changed": false, "cmd": "update-alternatives --display java | grep '^/' | awk '{print $1}' | grep 1.8.0 | head -1", "delta": "0:00:00.021355", "end": "2019-01-15 17:57:41.289218", "failed_when_result": false, "rc": 0, "start": "2019-01-15 17:57:41.267863", "stderr": "", "stderr_lines": [], "stdout": "/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-0.amzn2.x86_64/jre/bin/java", "stdout_lines": ["/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-0.amzn2.x86_64/jre/bin/java"]}

TASK [elastic.elasticsearch : correct java version selected] **********************************************************************************************************************************************
ok: [172.20.0.54] => {"changed": false}

...

In katsukamaru:java-version-check-in-check-mode branch actually executes the command and returns ok.
Please let me know if there are any problems.

@Crazybus
Copy link
Contributor

check_mode: yes means that ansible does not execute with --check.
My change check_mode: yes means actually execute in --check.

I think you meant check_mode: no here right?

I just had a look at the ansible check mode docs and it looks like I got it around backwards.

Force a task to run in check mode, even when the playbook is called without --check. This is called check_mode: yes.
Force a task to run in normal mode and make changes to the system, even when the playbook is called with --check. This is called check_mode: no.

Pretty confusing actually, but it means that your change does look good then! :)

Copy link
Contributor

@Crazybus Crazybus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Only thing still needed is to sign the CLA agreement and then this is ready to be merged.

@katsukamaru
Copy link
Author

katsukamaru commented Jan 15, 2019

@Crazybus

I think you meant check_mode: no here right?

You are right. I fixed my comment check_mode: yes to check_mode: no. Thank you for pointing it out.

I signed the CLA and seem to be passed all checks.

@Crazybus Crazybus merged commit 9823a3f into elastic:master Jan 15, 2019
@Crazybus
Copy link
Contributor

Thanks for your contribution @katsukamaru and teaching me how the check_mode actually works :D

@katsukamaru katsukamaru deleted the java-version-check-in-check-mode branch January 16, 2019 02:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants