Skip to content

Shield #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
c1f13cc
Added additional CORS settings
mewwts Aug 12, 2015
c719d0e
Added shield specific variables
mewwts Aug 12, 2015
be540fe
Added esusers task
mewwts Aug 12, 2015
2b47e92
renamed variables
mewwts Aug 12, 2015
7da9075
added full path
Aug 12, 2015
ffe8f5f
Wrong command name
mewwts Aug 12, 2015
f553f6c
CAn't have - in template
mewwts Aug 12, 2015
0d7efb5
esusers
Aug 12, 2015
3846588
support for several users
Aug 13, 2015
60b07c6
added option to disable shield
Aug 14, 2015
642ddcf
syntx erro
Aug 14, 2015
b666ada
added config for shield files
Aug 19, 2015
192529f
Very nice
mewwts Aug 20, 2015
90c9019
added default timezone UTC
Aug 21, 2015
9cd4856
not shield.enabled false
Aug 21, 2015
20e6f85
setting for keystore_key_passwd
Aug 24, 2015
c67250f
Update README.md
babadofar Sep 17, 2015
371f8e8
added some documentation
Sep 23, 2015
f0990d4
ready for ansible 2.0 plugin module
Sep 23, 2015
c15003b
Language configuration files
Oct 30, 2015
9fc1c13
Started configuring for elasticsearch version 2.0
Oct 30, 2015
08c7739
removed marvel plugin config, removed max open files setting from init
Oct 30, 2015
fa27d3f
added modules for handling snapshot restore and index
Nov 6, 2015
03ea72b
Merge branch 'master' of https://github.com/comperiosearch/ansible-el…
Nov 6, 2015
70d6b35
battle tested module for snapshot/restore
Nov 6, 2015
731aa67
split out shield tasks in one file
Nov 13, 2015
ac1e596
shield config
Nov 16, 2015
3cdac81
check elasticsearch package installed
Nov 20, 2015
8c8cd38
added check and create es backup directory
Nov 20, 2015
e06bd43
merged
Nov 20, 2015
87cfb08
change vagrant file, some default settings changed
Nov 23, 2015
9d7df95
Merge branch 'master' of https://github.com/Traackr/ansible-elasticse…
Nov 23, 2015
a3c4ed7
changed vagrantfile into something usable on windows
Nov 23, 2015
f41d59d
Merge branch 'master' into master_c
Nov 23, 2015
0ba7217
Added snapshot/restore and reindexing samples to readme.md
Nov 23, 2015
11e730b
Delete AEREADME.md
babadofar Nov 23, 2015
2b1eb20
readme fix
Nov 24, 2015
9db9ad6
cleaned up with only Shield changes
Nov 24, 2015
7d1a890
fixed up for pull request
Nov 24, 2015
82f1b57
Update README.md
babadofar Nov 24, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This is an [Ansible](http://www.ansibleworks.com/) playbook for [Elasticsearch](
- Support for installing custom JARs in the Elasticsearch classpath (e.g. custom Lucene Similarity JAR)
- Support for installing the [Sematext SPM](http://www.sematext.com/spm/) monitor
- Support for installing the [Marvel](http://www.elasticsearch.org/guide/en/marvel/current/) plugin
- Support for installing the [Shield](http://www.elasticsearch.org/guide/en/marvel/current/) plugin

## Installing

Expand Down Expand Up @@ -65,7 +66,7 @@ spm_client_token=<your SPM token here>
```

### Edit your vars/my-vars.yml
See `vars/sample.yml` and `vars/vagrant.yml` for example variable files. These are the files where you specify Elasticsearch settings and apply certain features such as plugins, custom JARs or monitoring. The best way to enable configurations is to look at `templates/elasticsearch.yml.j2` and see which variables you want to defile in your `vars/my-vars.yml`. See below for configurations regarding EC2, plugins and custom JARs.
See `vars/sample.yml` and `vars/vagrant.yml` for example variable files. These are the files where you specify Elasticsearch settings and apply certain features such as plugins, custom JARs or monitoring. The best way to enable configurations is to look at `templates/elasticsearch.yml.j2` and see which variables you want to define in your `vars/my-vars.yml`. See below for configurations regarding EC2, plugins and custom JARs.

### Edit your my-playbook-main.yml
Example `my-playbook-main.yml`:
Expand Down Expand Up @@ -186,6 +187,37 @@ The following variables provide configuration for the plugin. More options may b
- elasticsearch_plugin_marvel_agent_interval
- elasticsearch_plugin_marvel_agent_exporter_es_index_timeformat


### Configuring Shield
The following variables need to be defined in your playbook or inventory:

- elasticsearch_plugin_shield_enabled

The following variables provide configuration for the plugin. More options may be available in the future (see [https://www.elastic.co/guide/en/shield/current/reference.html](https://www.elastic.co/guide/en/shield/current/reference.html)):
- elasticsearch_plugin_shield_ssl_keystore_path
- elasticsearch_plugin_shield_ssl_keystore_password
- elasticsearch_plugin_shield_ssl_keystore_key_password
- elasticsearch_plugin_shield_ssl_hostname_verification
- elasticsearch_plugin_shield_transport_ssl
- elasticsearch_plugin_shield_http_ssl
- elasticsearch_plugin_shield_audit_enabled
- elasticsearch_plugin_shield_realms
- elasticsearch_plugin_shield_realms_esusers
+ order: 0
+ enabled: "false"

- elasticsearch_plugin_shield_realms_active_directory
+ order: 1
+ domain_name: example.com
+ unmapped_groups_as_roles: "true"
+ url: ldap://ad.microsoft.com
+ enabled: "true"

- elasticsearch_esusers
+ - {username:demouser, password: mypass, role: myrole}

- elasticsearch_shield_files: path to folder with Shield configuration files which will be copied into /etc/elasticsearch/shield

## Disable Java installation

If you prefer to skip the built-in installation of the Oracle JRE, use the `elasticsearch_install_java` flag:
Expand Down Expand Up @@ -247,3 +279,5 @@ MIT
# Author Information

George Stathis - gstathis [at] traackr.com
Mats Olsen molsen [at] comperiosearch.com
Christoffer Vig cvig [at] comperiosearch.com
26 changes: 16 additions & 10 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

$script = <<SCRIPT
cd /vagrant
ansible-playbook -i vagrant-inventory.ini vagrant-main.yml -vv
SCRIPT
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "ubuntu/trusty64"
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
config.vm.provider "virtualbox" do |v|
v.memory = 2048
v.cpus = 2
Expand All @@ -22,13 +26,15 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
config.vm.synced_folder '.', '/vagrant'
config.vm.synced_folder '.', '/vagrant', mount_options: ["dmode=777,fmode=666"]

config.vm.provision :ansible do |ansible|
ansible.inventory_path = "vagrant-inventory.ini"
ansible.playbook = "vagrant-main.yml"
ansible.extra_vars = { user: "vagrant" }
ansible.limit = 'all'
# ansible.verbose = 'vvvv'
end
end
config.vm.provision :shell,
:keep_color => true,
:path => "setup.sh"


config.vm.provision :shell,
:keep_color => true,
:inline => $script

end
5 changes: 4 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ elasticsearch_download_url: https://download.elasticsearch.org/elasticsearch/ela
elasticsearch_version: 1.7.3
elasticsearch_apt_repos:
- 'ppa:webupd8team/java'
elasticsearch_apt_java_package: oracle-java7-installer
elasticsearch_apt_java_package: oracle-java8-installer
elasticsearch_apt_dependencies:
- htop
- ntp
Expand All @@ -29,3 +29,6 @@ elasticsearch_service_state: started
# Non-Elasticsearch Defaults
apt_cache_valid_time: 300 # seconds between "apt-get update" calls.
elasticsearch_install_java: "true"
#uncomment to enable shield
#elasticsearch_plugin_shield_enabled: "true"

18 changes: 18 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
export PYTHONUNBUFFERED=1
export ANSIBLE_FORCE_COLOR=1

if [ $(dpkg-query -W -f='${Status}' ansible 2>/dev/null | grep -c "ok installed") -eq 0 ];
then
echo "Add APT repositories"
export DEBIAN_FRONTEND=noninteractive
apt-get install -qq software-properties-common &> /dev/null || exit 1
apt-add-repository ppa:ansible/ansible &> /dev/null || exit 1

apt-get update -qq

echo "Installing Ansible"
apt-get install -qq ansible &> /dev/null || exit 1
echo "Ansible installed"
fi

12 changes: 12 additions & 0 deletions tasks/esusers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- name: Delete user from esuser realm if it exists
action: >
shell bin/shield/esusers userdel {{ item.username }}
chdir={{ elasticsearch_home_dir }}
ignore_errors: yes
with_items: elasticsearch_esusers
- name: Add user to esuser realm
action: >
shell bin/shield/esusers useradd "{{ item.username }}" -p "{{ item.password }}" -r "{{ item.role }}"
chdir={{ elasticsearch_home_dir }}
ignore_errors: no
with_items: elasticsearch_esusers
4 changes: 4 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,9 @@
- include: marvel.yml
when: (elasticsearch_plugin_marvel_version is defined)

# Setup Shield
- include: shield.yml
when: (elasticsearch_shield_enabled is defined and elasticsearch_shield_enabled == "true")

# Always run post-run tasks
- include: post-run.yml
9 changes: 9 additions & 0 deletions tasks/shield.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- name: shield | esusers
include: esusers.yml
when: (elasticsearch_esusers is defined)

- name: shield | config files
copy: src={{elasticsearch_shield_files}} dest=/etc/elasticsearch/shield/
tags: shield_config_files
when: (elasticsearch_shield_files is defined)
notify: Restart Elasticsearch
70 changes: 69 additions & 1 deletion templates/elasticsearch.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ path.logs: {{ elasticsearch_log_dir }}
path.plugins: {{ elasticsearch_plugin_dir }}
{% endif %}


#################################### Plugin ###################################

# If a plugin listed here is not installed for current node, the node will not start.
Expand Down Expand Up @@ -664,7 +665,11 @@ http.cors.enabled: {{ elasticsearch_http_cors_enabled }}
{% endif %}

{% if elasticsearch_http_cors_allow_origin is defined %}
http.cors.allow-origin: {{ elasticsearch_http_cors_allow_origin}}
http.cors.allow-origin: {{ elasticsearch_http_cors_allow_origin }}
{% endif %}

{% if elasticsearch_http_cors_allow_credentials is defined%}
http.cors.allow-credentials: {{ elasticsearch_http_cors_allow_credentials }}
{% endif %}

{% if elasticsearch_script_groovy_sandbox_enabled is defined %}
Expand All @@ -678,3 +683,66 @@ script.groovy.sandbox.enabled: {{ elasticsearch_script_groovy_sandbox_enabled }}
cluster.routing.allocation.awareness.attributes: zone
node.zone: {{ facter_ec2_placement_availability_zone }}
{% endif %}



{% if elasticsearch_plugin_shield_enabled is defined %}
{% if elasticsearch_plugin_shield_enabled == "false" %}

shield.enabled: false

{% else %}
################################### Shield Settings #####################################

{% if elasticsearch_plugin_shield_ssl_keystore_path is defined %}
shield.ssl.keystore.path: {{ elasticsearch_plugin_shield_ssl_keystore_path }}
{% endif %}

{% if elasticsearch_plugin_shield_ssl_keystore_password is defined %}
shield.ssl.keystore.password: {{ elasticsearch_plugin_shield_ssl_keystore_password }}
{% endif %}

{% if elasticsearch_plugin_shield_ssl_keystore_key_password is defined %}
shield.ssl.keystore.key_password: {{ elasticsearch_plugin_shield_ssl_keystore_key_password }}
{% endif %}

{% if elasticsearch_plugin_shield_ssl_hostname_verification is defined %}
shield.ssl.hostname_verification: {{ elasticsearch_plugin_shield_ssl_hostname_verification }}
{% endif %}

{% if elasticsearch_plugin_shield_transport_ssl is defined %}
shield.transport.ssl: {{ elasticsearch_plugin_shield_transport_ssl }}
{% endif %}

{% if elasticsearch_plugin_shield_http_ssl is defined %}
shield.http.ssl: {{ elasticsearch_plugin_shield_http_ssl }}
{% endif %}

{% if elasticsearch_plugin_shield_audit_enabled is defined %}
shield.audit.enabled: {{elasticsearch_plugin_shield_audit_enabled}}
{% endif %}

{% if elasticsearch_plugin_shield_realms is defined %}
shield.authc.realms:
{% if elasticsearch_plugin_shield_realms_esusers is defined %}
esusers:
type: esusers
order: {{ elasticsearch_plugin_shield_realms_esusers.order }}
enabled: {{ elasticsearch_plugin_shield_realms_esusers.enabled }}
{% endif %}

{% if elasticsearch_plugin_shield_realms_active_directory is defined %}
active_directory:
type: active_directory
order: {{ elasticsearch_plugin_shield_realms_active_directory.order }}
enabled: {{ elasticsearch_plugin_shield_realms_active_directory.enabled }}
domain_name: {{ elasticsearch_plugin_shield_realms_active_directory.domain_name }}
unmapped_groups_as_roles: {{ elasticsearch_plugin_shield_realms_active_directory.unmapped_groups_as_roles }}
url: {{ elasticsearch_plugin_shield_realms_active_directory.url }}
#cache.ttl: 1m
{% endif %}
{% endif %}
{% endif %}


{% endif %}
2 changes: 1 addition & 1 deletion vagrant-inventory.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Local Environment #
#####################
[vagrant]
192.168.111.10 ansible_ssh_user=vagrant ansible_ssh_pass=vagrant
192.168.111.10 ansible_ssh_user=vagrant ansible_ssh_pass=vagrant ansible_connection=local

[vagrant:vars]
# spm_client_token=<enter your token>
5 changes: 3 additions & 2 deletions vars/vagrant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ elasticsearch_apt_java_package: oracle-java8-installer
elasticsearch_java_home: /usr/lib/jvm/java-8-oracle
elasticsearch_heap_size: 1g
elasticsearch_max_open_files: 65535
elasticsearch_timezone: "America/New_York"
elasticsearch_timezone: "America/New_York"
elasticsearch_node_max_local_storage_nodes: 1
elasticsearch_index_mapper_dynamic: "true"
elasticsearch_memory_bootstrap_mlockall: "true"
Expand All @@ -16,8 +16,9 @@ elasticsearch_plugins:
- { name: 'com.github.richardwilly98.elasticsearch/elasticsearch-river-mongodb/2.0.9', reinstall: false }
- { name: 'facet-script', url: 'http://dl.bintray.com/content/imotov/elasticsearch-plugins/elasticsearch-facet-script-1.1.2.zip', reinstall: false }
- { name: 'http-basic', url: 'https://github.com/Asquera/elasticsearch-http-basic/releases/download/v1.5.1/elasticsearch-http-basic-1.5.1.jar', download_only: true, reinstall: false }

elasticsearch_thread_pools:
- "threadpool.bulk.type: fixed"
- "threadpool.bulk.size: 50"
- "threadpool.bulk.queue_size: 1000"
elasticsearch_service_startonboot: yes
elasticsearch_service_startonboot: yes