Skip to content

Commit

Permalink
OPSEXP-1635 add elasticsearch role (#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
gionn authored Sep 22, 2022
1 parent c06ec38 commit 4fd9459
Show file tree
Hide file tree
Showing 11 changed files with 134 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/community.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
role:
- name: activemq
- name: common
- name: elasticsearch
- name: java
- name: nginx
- name: postgres
Expand Down
5 changes: 5 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ collections:
# molecule roles tests
- name: community.docker
version: 2.1.1
roles:
- name: buluma.elastic_repo
version: v0.1.2
- name: buluma.elasticsearch
version: 1.0.2
4 changes: 4 additions & 0 deletions roles/elasticsearch/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
# defaults file for elasticsearch
elasticsearch_tmp_path: /usr/share/elasticsearch/tmp
elasticsearch_systemd_service_path: /etc/systemd/system/elasticsearch.service.d/
2 changes: 2 additions & 0 deletions roles/elasticsearch/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# handlers file for elasticsearch
26 changes: 26 additions & 0 deletions roles/elasticsearch/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
galaxy_info:
author: alfresco
namespace: alfresco
description: Install elasticsearch required by Search Enteprise
company: Hyland Software

license: Apache-2.0

min_ansible_version: "2.12"

platforms:
- name: Ubuntu
versions:
- focal
- bionic
- name: EL
versions:
- "7"
- "8"

galaxy_tags: []

dependencies:
- role: common
- role: buluma.elastic_repo
become: true
7 changes: 7 additions & 0 deletions roles/elasticsearch/molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Converge
hosts: all
tasks:
- name: "Include elasticsearch"
include_role:
name: "elasticsearch"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ansible_user: ansible
27 changes: 27 additions & 0 deletions roles/elasticsearch/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: elasticsearch-instance
image: ${MOLECULE_ROLE_IMAGE:-ubuntu:18.04}
dockerfile: ../../../../tests/molecule/Dockerfile-noprivs.j2
command: "/lib/systemd/systemd"
privileged: true
tmpfs:
- /run
- /run/lock
- /tmp
volume_mounts:
- "/sys/fs/cgroup:/sys/fs/cgroup:ro"
groups:
- elasticsearch
provisioner:
name: ansible
inventory:
links:
host_vars: host_vars
group_vars: ../../../../group_vars
verifier:
name: ansible
34 changes: 34 additions & 0 deletions roles/elasticsearch/molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
- name: Verify
hosts: all
gather_facts: false
tasks:

- name: Stat the tmp folder for elasticsearch
stat:
path: "/usr/share/elasticsearch/tmp"
register: tmp_path_stat

- name: Assert that tmp folder is setup correctly
ansible.builtin.assert:
that:
- tmp_path_stat.stat.exists
- tmp_path_stat.stat.isdir
- tmp_path_stat.stat.mode == '0777'
- tmp_path_stat.stat.uid == 0
- tmp_path_stat.stat.gid == 0

- name: Check if port 9200/tcp is listening
wait_for:
port: 9200
timeout: 30
connect_timeout: 1
msg: "Timeout waiting for 9200/tcp to respond"

- name: Populate service facts
ansible.builtin.service_facts:

- name: Elasticsearch service is up and running
ansible.builtin.assert:
that:
- ansible_facts.services['elasticsearch.service'] is defined
- ansible_facts.services['elasticsearch.service'].state == 'running'
25 changes: 25 additions & 0 deletions roles/elasticsearch/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
# tasks file for elasticsearch
- name: Install elasticsearch
become: true
block:
# https://github.com/buluma/ansible-role-elasticsearch/issues/25
- name: Create alternative tmp directory for elasticsearch
ansible.builtin.file:
path: "{{ elasticsearch_tmp_path }}"
state: directory
mode: "0777"
- name: Create override directory for elasticsearch.service
ansible.builtin.file:
path: "{{ elasticsearch_systemd_service_path }}"
state: directory
mode: "0755"
- name: Set tmpdir override for elasticsearch.service
ansible.builtin.copy:
content: |
[Service]
Environment="ES_TMPDIR={{ elasticsearch_tmp_path }}"
dest: "{{ elasticsearch_systemd_service_path }}/tmpdir.conf"
- name: Install elasticsearch
ansible.builtin.include_role:
name: buluma.elasticsearch
2 changes: 2 additions & 0 deletions roles/elasticsearch/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# vars file for elasticsearch

0 comments on commit 4fd9459

Please sign in to comment.