Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Sohan Yadav committed Dec 12, 2019
0 parents commit 73fe7de
Show file tree
Hide file tree
Showing 19 changed files with 603 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ignored files
.idea
*.iml
*.zip
molecule
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks.git
rev: v2.2.3
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
- id: check-byte-order-marker
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: debug-statements
- id: check-yaml
- id: check-added-large-files
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Cloud Drove

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export GENIE_PATH ?= $(shell 'pwd')/../../../genie

include $(GENIE_PATH)/Makefile
147 changes: 147 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
<!-- This file was automatically generated by the `geine`. Make all changes to `README.yaml` and run `make readme` to rebuild this file. -->


<p align="center"> <img src="https://user-images.githubusercontent.com/50652676/62451340-ba925480-b78b-11e9-99f0-13a8a9cc0afa.png" width="100" height="100"></p>

<h1 align="center">
Ansible Role Docker Elasticsearch
</h1>

<p align="center" style="font-size: 1.2rem;">
This ansible role is used to install Elasticsearch Server with docker on linux.
</p>

<p align="center">

<a href="https://www.ansible.com">
<img src="https://img.shields.io/badge/Ansible-2.8-green?style=flat&logo=ansible" alt="Ansible">
</a>
<a href="LICENSE.md">
<img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="Licence">
</a>
<a href="https://ubuntu.com/">
<img src="https://img.shields.io/badge/ubuntu-16.x-orange?style=flat&logo=ubuntu" alt="Distribution">
</a>
<a href="https://ubuntu.com/">
<img src="https://img.shields.io/badge/ubuntu-18.x-orange?style=flat&logo=ubuntu" alt="Distribution">
</a>
<a href="https://www.centos.org/">
<img src="https://img.shields.io/badge/centos-7.x-orange" alt="Distribution">
</a>


</p>
<p align="center">

<a href='https://facebook.com/sharer/sharer.php?u=https://github.com/clouddrove/ansible-role-docker-elasticsearch'>
<img title="Share on Facebook" src="https://user-images.githubusercontent.com/50652676/62817743-4f64cb80-bb59-11e9-90c7-b057252ded50.png" />
</a>
<a href='https://www.linkedin.com/shareArticle?mini=true&title=Ansible+Role+Docker+Elasticsearch&url=https://github.com/clouddrove/ansible-role-docker-elasticsearch'>
<img title="Share on LinkedIn" src="https://user-images.githubusercontent.com/50652676/62817742-4e339e80-bb59-11e9-87b9-a1f68cae1049.png" />
</a>
<a href='https://twitter.com/intent/tweet/?text=Ansible+Role+Docker+Elasticsearch&url=https://github.com/clouddrove/ansible-role-docker-elasticsearch'>
<img title="Share on Twitter" src="https://user-images.githubusercontent.com/50652676/62817740-4c69db00-bb59-11e9-8a79-3580fbbf6d5c.png" />
</a>

</p>
<hr>



We eat, drink, sleep and most importantly love **DevOps**. DevOps always promotes automation and standardisation. While setting up various environments like local, dev, testing, production, etc. it is critical to maintain the same environment across. This can easily be achieved using automating the environment setup & installation with the help of ansible-playbooks.

Smaller roles are created for each environment elements; which also include tasks & tests. These roles can then be grouped together in [ansible-playbook](https://docs.ansible.com/ansible/latest/user_guide/playbooks_intro.html) to achieve the desired yet consistent results.



## Prerequisites

This module has a few dependencies:

- [Ansible2.8](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html)
- [Python](https://www.python.org/downloads)
- [Docker](https://docs.docker.com/install/linux/docker-ce/ubuntu)




## What Includes

Followiing things includes in this role:
- Elasticsearch







## Example Playbook

**IMPORTANT:** Since the `master` branch used in `source` varies based on new modifications, we suggest that you use the release versions [here](https://github.com/clouddrove/ansible-role-docker-elasticsearch/releases).


```yaml
- hosts: localhost
remote_user: root
roles:
- clouddrove.ansible_role_docker_elasticsearch
```
## Example hosts.ini
```ini
[elasticsearch]
elasticsearch = ansible_host=34.228.21.221 Env=dev EcType=elasticsearch EcName=dev-elasticsearch Az=a Nr=0 PrivateIp=10.0.109.170
```

## Variables

```yaml
es_version: "6.7.2"
es_xmx: "{{ ( ansible_memtotal_mb * 0.20 ) | round(0, 'ceil') | int }}"
es_user: elastic
es_group: elastic
mount_path: /data
es_opt_dir: "/opt/elasticsearch"
es_config_dir: "{{ es_opt_dir }}/config"
es_tmp_dir: "{{ mount_path }}/tmp/elasticsearch"
es_data_dir: "{{ mount_path }}/elasticsearch"
es_log_dir: "/var/log/elasticsearch"
es_port: 9200
es_publish_port: 9300
es_host: "0.0.0.0"
es_publish_host: "{{ es_host }}"
es_bind_host: "{{ es_host }}"
es_node_name: "{{ hostvars[inventory_hostname].EcName | safe | trim }}"
```


## Installation

```console
$ ansible-galaxy install clouddrove.ansible_role_docker_elasticsearch
```






## Feedback
If you come accross a bug or have any feedback, please log it in our [issue tracker](https://github.com/clouddrove/ansible-role-docker-elasticsearch/issues), or feel free to drop us an email at [hello@clouddrove.com](mailto:hello@clouddrove.com).

If you have found it worth your time, go ahead and give us a ★ on [our GitHub](https://github.com/clouddrove/ansible-role-docker-elasticsearch)!

## About us

At [CloudDrove][website], we offer expert guidance, implementation support and services to help organisations accelerate their journey to the cloud. Our services include docker and container orchestration, cloud migration and adoption, infrastructure automation, application modernisation and remediation, and performance engineering.

<p align="center">We are <b> The Cloud Experts!</b></p>
<hr />
<p align="center">We ❤️ <a href="https://github.com/clouddrove">Open Source</a> and you can check out <a href="https://github.com/clouddrove">our other modules</a> to get help with your new Cloud ideas.</p>

[website]: https://clouddrove.com
[github]: https://github.com/clouddrove
[linkedin]: https://cpco.io/linkedin
[twitter]: https://twitter.com/clouddrove/
[email]: https://clouddrove.com/contact-us.html
[terraform_modules]: https://github.com/clouddrove?utf8=%E2%9C%93&q=terraform-&type=&language=
83 changes: 83 additions & 0 deletions README.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
#
# This is the canonical configuration for the `README.md`
# Run `make readme` to rebuild the `README.md`
#

# Name of this project
name: Ansible Role Docker Elasticsearch

# License of this project
license: "MIT"

# Canonical GitHub repo
github_repo: clouddrove/ansible-role-docker-elasticsearch

# Badges to display
badges:
- name: "Ansible"
image: "https://img.shields.io/badge/Ansible-2.8-green?style=flat&logo=ansible"
url: "https://www.ansible.com"
- name: "Licence"
image: "https://img.shields.io/badge/License-MIT-blue.svg"
url: "LICENSE.md"
- name: "Distribution"
image: "https://img.shields.io/badge/ubuntu-16.x-orange?style=flat&logo=ubuntu"
url: "https://ubuntu.com/"
- name: "Distribution"
image: "https://img.shields.io/badge/ubuntu-18.x-orange?style=flat&logo=ubuntu"
url: "https://ubuntu.com/"
- name: "Distribution"
image: "https://img.shields.io/badge/centos-7.x-orange"
url: "https://www.centos.org/"
# Prerequesties to display
# yamllint disable
prerequesties:
- name: "Ansible2.8"
url: "https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html"
- name: "Python"
url: "https://www.python.org/downloads"
- name: "Docker"
url: "https://docs.docker.com/install/linux/docker-ce/ubuntu"
# yamllint enable
# What Includes to display
what_includes:
- name: "Elasticsearch"

# description of this project
description: |-
This ansible role is used to install Elasticsearch Server with docker on linux.
# How to use this project
usage: |-
```yaml
- hosts: localhost
remote_user: root
roles:
- clouddrove.ansible_role_docker_elasticsearch
```
# Variables use in the project
variables: |-
```yaml
es_version: "6.7.2"
es_xmx: "{{ ( ansible_memtotal_mb * 0.20 ) | round(0, 'ceil') | int }}"
es_user: elastic
es_group: elastic
mount_path: /data
es_opt_dir: "/opt/elasticsearch"
es_config_dir: "{{ es_opt_dir }}/config"
es_tmp_dir: "{{ mount_path }}/tmp/elasticsearch"
es_data_dir: "{{ mount_path }}/elasticsearch"
es_log_dir: "/var/log/elasticsearch"
es_port: 9200
es_publish_port: 9300
es_host: "0.0.0.0"
es_publish_host: "{{ es_host }}"
es_bind_host: "{{ es_host }}"
es_node_name: "{{ hostvars[inventory_hostname].EcName | safe | trim }}"
```
# How to install project
installation: |-
```console
$ ansible-galaxy install clouddrove.ansible_role_docker_elasticsearch
```
29 changes: 29 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
# version
es_version: "6.7.2"

# memory settings
es_xmx: "{{ ( ansible_memtotal_mb * 0.30 ) | round(0, 'ceil') | int }}"

# user settings
es_user: elastic
es_group: elastic
# data mounting
mount_path: /data

# elasticearch settings
es_opt_dir: "/opt/elasticsearch"
es_config_dir: "{{ es_opt_dir }}/config"
es_tmp_dir: "{{ mount_path }}/tmp/elasticsearch"
es_data_dir: "{{ mount_path }}/elasticsearch"
es_log_dir: "/var/log/elasticsearch"

# elasticsearch network settings
es_port: 9200
es_publish_port: 9300
es_host: "0.0.0.0"
es_publish_host: "{{ es_host }}"
es_bind_host: "{{ es_host }}"

# elasticsearch node settings
es_node_name: "{{ hostvars[inventory_hostname].EcName | safe | trim }}"
16 changes: 16 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- name: restart elasticsearch
service:
name: elasticsearch
state: restarted
enabled: true

- name: reload elasticsearch
systemd:
name: elasticsearch
state: reloaded

- name: start elasticsearch
systemd:
name: elasticsearch
state: started
31 changes: 31 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
dependencies: []

galaxy_info:
author: clouddrove
description: This ansible role is used to install Elasticsearch Server with docker on linux.
company: "CloudDrove, LLC"
license: "license (BSD, MIT)"
min_ansible_version: 2.4
platforms:
- name: Debian
versions:
- jessie
- stretch
- name: Ubuntu
versions:
- trusty
- xenial
- bionic
- name: EL
versions:
- 7
galaxy_tags:
- system
- server
- elasticsearch
- ubuntu
- debian
- centos
- search
- docker
36 changes: 36 additions & 0 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
- name: create elasticsearch dirs
file:
path: "{{ item|safe|trim }}"
state: directory
owner: "{{ es_user }}"
group: "{{ es_group }}"
mode: 0777
recurse: true
changed_when: false
with_items:
- "{{ es_opt_dir }}"
- "{{ es_config_dir }}"
- "{{ es_tmp_dir }}"
- "{{ es_data_dir }}"

- name: create elasticsearch configuration file
template:
dest: "{{ es_config_dir }}/{{ item | basename }}"
owner: "{{ es_user }}"
group: "{{ es_group }}"
mode: 0644
force: true
src: "{{ item }}"
with_items:
- elasticsearch.yml
- log4j2.properties
- analysis/stopword.txt
- analysis/synonym.txt

- name: set vm.max_map_count to 262144 in sysctl
sysctl:
name: "{{ item.key }}"
value: "{{ item.value }}"
with_items:
- { key: "vm.max_map_count", value: "262144" }
Loading

0 comments on commit 73fe7de

Please sign in to comment.