--- #Test if feature is installed - shell: "{{es_home}}/bin/plugin list | sed -n '1!p' | grep {{item}}" register: feature_installed changed_when: False ignore_errors: yes environment: CONF_DIR: "{{ conf_dir }}" ES_INCLUDE: "{{ instance_default_file }}" #Remove Plugin if installed and its not been requested or the ES version has changed - name: Remove {{item}} plugin command: > {{es_home}}/bin/plugin remove shield register: xpack_state failed_when: "'ERROR' in xpack_state.stdout" changed_when: xpack_state.rc == 0 when: feature_installed.rc == 0 and (not es_enable_xpack or not '"{{item}}" in es_xpack_features' or es_version_changed) notify: restart elasticsearch environment: CONF_DIR: "{{ conf_dir }}" ES_INCLUDE: "{{ instance_default_file }}" #Install plugin if not installed, or the es version has changed (so removed above), and its been requested - name: Install {{item}} plugin command: > {{es_home}}/bin/plugin install {{item}} register: xpack_state failed_when: "'ERROR' in xpack_state.stdout" changed_when: xpack_state.rc == 0 when: (feature_installed.rc == 1 or es_version_changed) and es_enable_xpack and "{{item}}" in es_xpack_features notify: restart elasticsearch environment: CONF_DIR: "{{ conf_dir }}" ES_INCLUDE: "{{ instance_default_file }}"