Skip to content

Commit

Permalink
Moving the vars definitions to ops\defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
romsok24 authored and rafzei committed Mar 28, 2022
1 parent b8b4132 commit 0b646ac
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 43 deletions.
7 changes: 7 additions & 0 deletions ansible/playbooks/roles/opensearch/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
---
# This file is meant to be also used by upgrade role
file_name_version:
opensearch:
x86_64: opensearch-1.2.4-linux-x64.tar.gz
aarch64: opensearch-1.2.4-linux-arm64.tar.gz
opensearch_perftop:
x86_64: opensearch-perf-top-1.2.0.0-linux-x64.zip
# Perftop is not supported on ARM (https://github.com/opensearch-project/perftop/issues/26)
certificates:
dirs:
certs: /usr/share/opensearch/config
Expand Down
11 changes: 4 additions & 7 deletions ansible/playbooks/roles/opensearch/tasks/install-opensearch.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
---
- name: Define the filenames for the download task
include_tasks: roles/opensearch/tasks/set_facts.yml

- name: Download Opensearch
include_role:
name: download
tasks_from: download_file
vars:
file_name: "opensearch-{{ opensearch_ver }}"
file_name: "{{ file_name_version.opensearch[ansible_architecture] }}"

- name: Download PerfTop
include_role:
name: download
tasks_from: download_file
vars:
file_name: "opensearch-perf-top-{{ opensearch_perftop_ver }}"
file_name: "{{ file_name_version.opensearch_perftop[ansible_architecture] }}"
when: ansible_architecture == "x86_64" # Perftop is not yet supported on ARM (https://github.com/opensearch-project/perftop/issues/26)

- name: Ensure Opensearch service user exists
Expand Down Expand Up @@ -42,7 +39,7 @@

- name: Extract OpenSearch tar file
unarchive:
src: "/tmp/opensearch-{{ opensearch_ver }}"
src: "/tmp/{{ file_name_version.opensearch[ansible_architecture] }}"
dest: "{{ specification.paths.opensearch_home }}"
owner: "{{ specification.opensearch_user }}"
remote_src: yes
Expand All @@ -51,7 +48,7 @@

- name: Extract OpenSearch PerfTop tar file
unarchive:
src: "/tmp/opensearch-perf-top-{{ opensearch_perftop_ver }}"
src: "/tmp/{{ file_name_version.opensearch_perftop[ansible_architecture] }}"
dest: "{{ specification.paths.opensearch_perftop_home }}"
owner: "{{ specification.opensearch_user }}"
remote_src: yes
Expand Down
12 changes: 0 additions & 12 deletions ansible/playbooks/roles/opensearch/tasks/set_facts.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
file_name_version:
opensearch_dashboards:
x86_64: opensearch-dashboards-1.2.0-linux-x64.tar.gz
aarch64: opensearch-dashboards-1.2.0-linux-arm64.tar.gz
opensearch_api_port: 9200
opensearch_nodes_dashboards: |-
{% for item in groups['opensearch_dashboards'] -%}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
---
- name: Define the filename for the download task
include_tasks: set_facts.yml

- name: Download Opensearch dashbaords
include_role:
name: download
tasks_from: download_file
vars:
file_name: "opensearch-dashboards-{{ opensearchdash_version }}"
file_name: "{{ file_name_version.opensearch_dashboards[ansible_architecture] }}"

- name: Create OpenSearch Dashboards user
user:
Expand All @@ -24,7 +21,7 @@

- name: Extract OpenSearch Dashboards tar file
unarchive:
src: "/tmp/opensearch-dashboards-{{ opensearchdash_version }}"
src: "/tmp/{{ file_name_version.opensearch_dashboards[ansible_architecture] }}"
dest: "{{ specification.paths.opensearchdash_home }}"
owner: "{{ specification.dashboards_user }}"
remote_src: yes
Expand Down
10 changes: 0 additions & 10 deletions ansible/playbooks/roles/opensearch_dashboards/tasks/set_facts.yml

This file was deleted.

5 changes: 1 addition & 4 deletions ansible/playbooks/roles/upgrade/tasks/opensearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
file: roles/opensearch/vars/main.yml
name: opensearch_vars

- name: OpenSearch | Set the versions of OpenSearch
include_tasks: roles/opensearch/tasks/set_facts.yml

- name: OpenSearch | Ensure Opensearch service user exists
user:
name: "{{ opensearch_vars.specification.opensearch_user }}"
Expand All @@ -47,7 +44,7 @@
debug:
msg:
- "Installed version: {{ ansible_facts.packages['elasticsearch-oss'][0].version }}"
- "Target version: {{ opensearch_ver.split('-')[0] }}"
- "Target version: {{ opensearch_defaults.file_name_version.opensearch[ansible_architecture].split('-')[1] }}"

# If state file exists it means the previous run failed
- name: OpenSearch | Check if upgrade state file exists
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@
enabled: no
state: stopped

- name: Kibana migr | Define the filename for the download task
include_tasks: roles/opensearch_dashboards/tasks/set_facts.yml

- name: Kibana migr | Download Opensearch Dashboards binary
include_role:
name: download
tasks_from: download_file
vars:
file_name: "opensearch-dashboards-{{ opensearchdash_version }}"
file_name: "{{ file_name_version.opensearch_dashboards[ansible_architecture] }}"

- name: Kibana migr | Create opensearch-dashboards user
user:
Expand All @@ -43,7 +40,7 @@

- name: Kibana migr | Extract the tar file
unarchive:
src: "/tmp/opensearch-dashboards-{{ opensearchdash_version }}"
src: "/tmp/{{ file_name_version.opensearch_dashboards[ansible_architecture] }}"
dest: "{{ specification.paths.opensearchdash_home }}"
owner: "{{ specification.dashboards_user }}"
remote_src: yes
Expand Down

0 comments on commit 0b646ac

Please sign in to comment.