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

Commit

Permalink
Don't use nested blocks since the outer when statements don't apply
Browse files Browse the repository at this point in the history
  • Loading branch information
Crazybus committed Jun 18, 2018
1 parent d795e01 commit 0fb83fa
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions tasks/elasticsearch-Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,28 @@
- { repo: "{{ es_apt_url }}", state: "present" }
when: es_use_repository

- name: Stop elasticsearch and remove the package if we are upgrading to the oss version
when: es_package_name == 'elasticsearch-oss'
block:
- name: Check if the elasticsearch package is still installed
command: dpkg -l elasticsearch
register: elasticsearch_package
failed_when: False
changed_when: False
- name: Check if the elasticsearch package is installed
command: dpkg -l elasticsearch
register: elasticsearch_package
failed_when: False
changed_when: False

- name: Gracefully stop and remove elasticsearch if we are switching to the oss version
when: elasticsearch_package.rc == 0
block:
- name: stop elasticsearch
become: yes
service:
name: '{{ instance_init_script | basename }}'
state: stopped
- name: Gracefully stop and remove elasticsearch if we are switching to the oss version
when:
- es_package_name == 'elasticsearch-oss'
- elasticsearch_package.rc == 0
block:
- name: stop elasticsearch
become: yes
service:
name: '{{ instance_init_script | basename }}'
state: stopped

- name: Debian - Remove elasticsearch package if we are installing the oss package
become: yes
apt:
name: 'elasticsearch'
state: absent
- name: Debian - Remove elasticsearch package if we are installing the oss package
become: yes
apt:
name: 'elasticsearch'
state: absent

- name: Debian - Ensure elasticsearch is installed
become: yes
Expand Down

0 comments on commit 0fb83fa

Please # to comment.