Fix ES API test task until statement. Fix block indentation

This commit is contained in:
zenidd 2020-11-09 19:08:33 +01:00
parent d23feddede
commit af948dff01

View File

@ -5,90 +5,91 @@
- generate_certs - generate_certs
- block: - block:
- import_tasks: RedHat.yml
when: ansible_os_family == 'RedHat'
- import_tasks: RedHat.yml - name: Install OpenDistro
when: ansible_os_family == 'RedHat' package:
name: opendistroforelasticsearch-{{ opendistro_version }}
state: present
register: install
tags: install
- name: Remove elasticsearch configuration file
file:
path: "{{ opendistro_conf_path }}/elasticsearch.yml"
state: absent
when: install.changed
tags: install
- name: Install OpenDistro - name: Copy Configuration File
package: blockinfile:
name: opendistroforelasticsearch-{{ opendistro_version }} block: "{{ lookup('template', 'elasticsearch.yml.j2') }}"
state: present dest: "{{ opendistro_conf_path }}/elasticsearch.yml"
register: install create: true
tags: install group: elasticsearch
mode: 0640
marker: "## {mark} Opendistro general settings ##"
when: install.changed
tags: install
- name: Remove elasticsearch configuration file - import_tasks: security_actions.yml
file:
path: "{{ opendistro_conf_path }}/elasticsearch.yml"
state: absent
when: install.changed
tags: install
- name: Copy Configuration File - name: Configure OpenDistro Elasticsearch JVM memmory.
blockinfile: template:
block: "{{ lookup('template', 'elasticsearch.yml.j2') }}" src: "templates/jvm.options.j2"
dest: "{{ opendistro_conf_path }}/elasticsearch.yml" dest: /etc/elasticsearch/jvm.options
create: true owner: root
group: elasticsearch group: elasticsearch
mode: 0640 mode: 0644
marker: "## {mark} Opendistro general settings ##" force: yes
when: install.changed notify: restart elasticsearch
tags: install tags: install
- import_tasks: security_actions.yml - name: Ensure Elasticsearch started and enabled
service:
name: elasticsearch
enabled: true
state: started
- name: Configure OpenDistro Elasticsearch JVM memmory. - name: Wait for Elasticsearch API
template: uri:
src: "templates/jvm.options.j2" url: "https://{{ inventory_hostname }}:{{ opendistro_http_port }}/_cluster/health/"
dest: /etc/elasticsearch/jvm.options user: "admin" # Default OpenDistro user is always "admin"
owner: root password: "{{ opendistro_admin_password }}"
group: elasticsearch validate_certs: no
mode: 0644 status_code: 200,401
force: yes return_content: yes
notify: restart elasticsearch timeout: 4
tags: install register: _result
until:
- _result.json is defined
- _result.json.status == "green" or ( _result.json.status == "yellow" and single_node )
retries: 24
delay: 5
tags: debug
when:
- hostvars[inventory_hostname]['private_ip'] is not defined or not hostvars[inventory_hostname]['private_ip']
- name: Ensure Elasticsearch started and enabled - name: Wait for Elasticsearch API (Private IP)
service: uri:
name: elasticsearch url: "https://{{ hostvars[inventory_hostname]['private_ip'] }}:{{ opendistro_http_port }}/_cluster/health/"
enabled: true user: "admin" # Default OpenDistro user is always "admin"
state: started password: "{{ opendistro_admin_password }}"
validate_certs: no
- name: Wait for Elasticsearch API status_code: 200,401
uri: return_content: yes
url: "https://{{ inventory_hostname }}:{{ opendistro_http_port }}/_cluster/health/" timeout: 4
user: "admin" # Default OpenDistro user is always "admin" register: _result
password: "{{ opendistro_admin_password }}" until:
validate_certs: no - _result.json is defined
status_code: 200,401 - _result.json.status == "green" or ( _result.json.status == "yellow" and single_node )
return_content: yes retries: 24
timeout: 4 delay: 5
register: _result tags: debug
until: ( _result.json is defined) and (_result.json.status == "green" or ( _result.json.status == "yellow" and single_node ) ) when:
retries: 24 - hostvars[inventory_hostname]['private_ip'] is defined and hostvars[inventory_hostname]['private_ip']
delay: 5
tags: debug
when:
- hostvars[inventory_hostname]['private_ip'] is not defined or not hostvars[inventory_hostname]['private_ip']
- name: Wait for Elasticsearch API (Private IP)
uri:
url: "https://{{ hostvars[inventory_hostname]['private_ip'] }}:{{ opendistro_http_port }}/_cluster/health/"
user: "admin" # Default OpenDistro user is always "admin"
password: "{{ opendistro_admin_password }}"
validate_certs: no
status_code: 200,401
return_content: yes
timeout: 4
register: _result
until: ( _result.json is defined) and (_result.json.status == "green" or ( _result.json.status == "yellow" and single_node ) )
retries: 24
delay: 5
tags: debug
when:
- hostvars[inventory_hostname]['private_ip'] is defined and hostvars[inventory_hostname]['private_ip']
- import_tasks: "RMRedHat.yml"
when: ansible_os_family == "RedHat"
- import_tasks: "RMRedHat.yml"
when: ansible_os_family == "RedHat"
when: perform_installation when: perform_installation