Skip to content

Commit 7d94121

Browse files
author
gingerwizard
committed
Merge pull request elastic#75 from LaneCommunityCollege/optional_user
For elastic#36 - Add support for creating optional elasticsearch user and group
2 parents 6a4eb97 + 8393b86 commit 7d94121

File tree

5 files changed

+35
-1
lines changed

5 files changed

+35
-1
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ If installing Marvel or Watcher, ensure the license plugin is also specified. S
221221

222222
* ```es_user``` - defaults to elasticsearch.
223223
* ```es_group``` - defaults to elasticsearch.
224+
* ```es_user_id``` - default is undefined.
225+
* ```es_group_id``` - default is undefined.
226+
227+
Both ```es_user_id``` and ```es_group_id``` must be set for the user and group ids to be set.
224228

225229
By default, each node on a host will be installed to use unique pid, plugin, work, data and log directories. These directories are created, using the instance and host name, beneath default locations ]
226230
controlled by the following parameters:

tasks/elasticsearch-optional-user.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
#Add the elasticsearch user before installing from packages.
3+
- name: Ensure optional elasticsearch group is created with the correct id.
4+
group:
5+
state: present
6+
name: "{{ es_group }}"
7+
system: yes
8+
gid: "{{ es_group_id }}"
9+
10+
- name: Ensure optional elasticsearch user is created with the correct id.
11+
user:
12+
state: present
13+
name: "{{ es_user }}"
14+
comment: elasticsearch system user
15+
system: yes
16+
createhome: no
17+
uid: "{{ es_user_id }}"
18+
group: "{{ es_group }}"

tasks/elasticsearch.yml

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
- debug: msg="Node configuration {{ es_config }} "
1010

11+
- name: Include optional user and group creation.
12+
when: (es_user_id is defined) and (es_group_id is defined)
13+
include: elasticsearch-optional-user.yml
14+
1115
#- name: Include specific Elasticsearch
1216
# include: "elasticsearch-{{ansible_os_family}}.yml"
1317

test/integration/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
hosts: localhost
55
roles:
66
#expand to all available parameters
7-
- { role: elasticsearch, es_instance_name: "node1", es_data_dirs: ["/opt/elasticsearch/data-1","/opt/elasticsearch/data-2"], es_log_dir: "/opt/elasticsearch/logs", es_work_dir: "/opt/elasticsearch/temp", es_config: {node.name: "node1", cluster.name: "custom-cluster", discovery.zen.ping.unicast.hosts: "localhost:9301", http.port: 9201, transport.tcp.port: 9301, node.data: false, node.master: true, bootstrap.mlockall: true, discovery.zen.ping.multicast.enabled: false } }
7+
- { role: elasticsearch, es_instance_name: "node1", es_data_dirs: ["/opt/elasticsearch/data-1","/opt/elasticsearch/data-2"], es_log_dir: "/opt/elasticsearch/logs", es_work_dir: "/opt/elasticsearch/temp", es_user_id: 333, es_group_id: 333, es_config: {node.name: "node1", cluster.name: "custom-cluster", discovery.zen.ping.unicast.hosts: "localhost:9301", http.port: 9201, transport.tcp.port: 9301, node.data: false, node.master: true, bootstrap.mlockall: true, discovery.zen.ping.multicast.enabled: false } }
88
vars:
99
es_scripts: false
1010
es_templates: false

test/integration/helpers/serverspec/config_spec.rb

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
describe user('elasticsearch') do
66
it { should exist }
77
end
8+
9+
describe group('elasticsearch') do
10+
it { should have_gid 333 }
11+
end
12+
13+
describe user('elasticsearch') do
14+
it { should have_uid 333 }
15+
end
816

917
describe service('node1_elasticsearch') do
1018
it { should be_running }

0 commit comments

Comments
 (0)