-
Notifications
You must be signed in to change notification settings - Fork 855
Conversation
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? |
jenkins test this please |
@toadjaune Thank you so much for the great writeup with all of the detail. I really appreciate a well written PR. I'm going to let the tests run but I believe this is going to fail on the
This code you removed makes sure that the symbolic link is only created once for the first machine. It is needed to allow uninstalls of the elasticsearch package to work properly (it needs to do a Lets see what the tests say first, however I think this might need to be solved in a more ugly way :( |
Yup as I suspected. All of the systemd multi tests are failing. If you want to test this locally we have some documentation on how to run these tests yourself. https://github.com/elastic/ansible-elasticsearch#testing To reproduce this locall you would want to run.
|
jenkins test this please |
As you should have seen, this is a simpler fix, just making sure that we don't try to access I've been trying to run the tests locally for the last hour, then gave up. I'll be waiting for Jenkins again ! :) |
@toadjaune Thanks so much for the fix here! Once again I really really appreciate the great detailed pull request description :) |
Issue
Elasticsearch version:
6.3.0
Role version:
6.3.0
JVM version (
java -version
):OS version (
uname -a
if on a Unix-like system):Ansible version :
Description of the problem including expected versus actual behaviour:
When deploying with systemd (
use_system_d
is set to true by the playbook, default behaviour on Debian 8 and above), if the elasticsearch systemd unit file does not exist, the playbook fails instead of creating it as a symlink.Playbook:
The playbook we actually played is quite complicated, and was run number of times to overcome the numerous issues we met during an upgrade from ElasticSearch 5.6.2 to 6.3.0.
The following playbook however reproduces the issue we met :
Provide logs from Ansible:
The above playbook gives the exact same error than the real one (except for the file paths), which is :
Proposed fix
According to the stat module documentation, most values in the return dict, including
islnk
are only defined if the target file exists. When it doesn't, the current code checks a non-existing dict entry, and ansible fails.I can't explain with certitude why we ended up with no systemd unit file in the first place, but it is definitely possible (happened at some point of the upgrade on every single node we had), and ansible should not fail on something so easily fixable.
First version
Here is the fix I first came up with :
sysd_stat_result.stat.exists
, to ensure not to test a non-existing dict keySecond version
The second version is the current PR, and is in my opinion way more elegant : we just get rid of all the test and the manual file suppression, and use the
force
option of the file module instead.The only functional difference with the first solution is that ansible will silently create the symlink even if the file it points to does not exist (instead of failing), which is not supposed to be possible (because this file is created earlier in the same task file), so it should be safe.