Ansible Automation for an upgrade (5.611 to 6.5.4) of elasticsearch

Hi there,
quick question to the community. If you make an elasticsearch upgrade manually you are prompted if you want to keep the defaults. Does somenone has a solution for this step when using Ansible? So, how can I emulate 'yes, keep the existing configs (N ist the standard answer)' using ansible?

Do you know a way of solving this perhaps pimping this statement?
- name: doing elasticsearch upgrade
apt:
name: elasticsearch=6.5.4
only_upgrade: yes
environment:
RUNLEVEL: 1

Thank you very much!

1 Like

Hi Stefano!

This upgrade seems to work with our official playbook so it is possible. You can take a look at the install task to see what you might be missing.

My first guess would be that you need to set the ES_PATH_CONF to avoid the questions that apt asks.

  environment:
    ES_PATH_CONF: "/etc/elasticsearch"
1 Like

Thanks for the input.

I think mine is a more basic question. Meaning: If I upgrade manually via deb package I get 2 questions. For example one is:
Configuration file '/etc/elasticsearch/elasticsearch.yml'
==> Modified (by you or by a script) since installation.
==> Package distributor has shipped an updated version.
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** elasticsearch.yml (Y/I/N/O/D/Z) [default=N] ?

Now, how can I handle in ansible to give an answer using a playbook. Am I completely on a false track or how do you solve this?
Thank you very much for any input.
Cheers.

Usually apt install -y should solve that problem, it assumes yes on all questions.

....yep, correct ;-). BUt: is there a way to do this with ansible?

I'm not a ansible user myself, we use saltstack to do our config managment. but this thread on stackoverflow might push you in the right direction..

Now, how can I handle in ansible to give an answer using a playbook. Am I completely on a false track or how do you solve this?

Which version of Ansible are you using? It's weird that this works just fine for the official Ansible Elasticsearch playbook without needing any special configuration. The tests are being run with version 2.4.3.0 and includes testing of upgrades from 5.x to 6.x.

Version is really the only difference I can see here. Can you also post the output that you get from Ansible when it tries to upgrade?

Hello Michael,
I am working under ansible 2.6.3.
Would you mind to post the link for the official elastic upgrade playbook?
Thank you.

What I am doing right now is as simple as this at this point:
- name: doing elasticsearch upgrade
apt:
name: elasticsearch=6.5.4
install_recommends: yes
allow_unauthenticated: yes
environment:
RUNLEVEL: 1

But so, I have no choice to say if I wanto to accept the defaults. I am still learning ansible that is why I was interested to know if there is some way to script in the plays to accept or nor the given choices.

Thank you and kind regards
Stefano

I am still learning ansible that is why I was interested to know if there is some way to script in the plays to accept or nor the given choices.

Ansible is just going to run apt-get -y (with some other options too). It's not something that you need to specify yourself.

Would you mind to post the link for the official elastic upgrade playbook?

This is the task for the ansible-elasticsearch playbook. It's almost identical to yours which is why it is weird that you are running in to problems. As part of our automated testing we even check that upgrading from 5.x to 6.x is possible. If using the same settings doesn't work you could try it with ansible 2.4.3.0 to be sure that isn't something that has broken with ansible.

...so: using ansible I have no possibility to make a choice at this 2 points that came up during a manual install:

Configuration file '/etc/elasticsearch/elasticsearch.yml'
==> Modified (by you or by a script) since installation.
==> Package distributor has shipped an updated version.
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** elasticsearch.yml (Y/I/N/O/D/Z) [default=N] ?

Configuration file '/etc/default/elasticsearch'
==> Modified (by you or by a script) since installation.
==> Package distributor has shipped an updated version.
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** elasticsearch (Y/I/N/O/D/Z) [default=N] ?

MEANING: There is no way to tell ansible: hey, answer with e.g. Y in both cases to get the maintaner's version?

Thank you again for your input! I just want to learn it right. I think this is an important question. I could also decide: ok, the first answer is N and the second I would like a Y.

cheers
Stefano

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.