Skip to content

Commit 20c7bcf

Browse files
author
Philipp Wiesner
committed
add possibility to add files to keystore
1 parent 94c7524 commit 20c7bcf

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,16 @@ In addition to es_config, the following parameters allow the customization of th
450450
* ```es_use_repository``` Setting this to `false` will stop Ansible from using the official Elastic package from any repository configured on the system.
451451
* ```es_add_repository``` Setting this to `false` will stop Ansible to add the official Elastic package repositories (if es_use_repository is true) if you want to use a repo already present.
452452
* ```es_custom_package_url``` the URL to the rpm or deb package for Ansible to install. When using this you will also need to set `es_use_repository: false` and make sure that the `es_version` matches the version being installed from your custom URL. E.g. `es_custom_package_url: https://downloads.example.com/elasticsearch.rpm`
453+
* ```es_additional_files``` additional files to upload
454+
455+
```yaml
456+
es_additional_files:
457+
- src: sourceFile
458+
dest: destFile
459+
user: user | default(es_user)
460+
group: group | default(es_group)
461+
mode: fileMode | default('660')
462+
```
453463

454464
Earlier examples illustrate the installation of plugins using `es_plugins`. For officially supported plugins no version or source delimiter is required. The plugin script will determine the appropriate plugin version based on the target Elasticsearch version. For community based plugins include the full url. This approach should NOT be used for the X-Pack plugin. See X-Pack below for details here.
455465

@@ -495,6 +505,10 @@ es_keystore_entries:
495505
496506
- key: someKeyToDelete
497507
state: absent
508+
509+
- key: someFileKey
510+
value: filePath
511+
file: true
498512
```
499513

500514

tasks/elasticsearch-config.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,17 @@
103103
force: yes
104104
notify: restart elasticsearch
105105
when: es_config_log4j2 != ''
106+
107+
- name: Copy additional files
108+
become: yes
109+
copy:
110+
src: "{{ item.src }}"
111+
dest: "{{ item.dest }}"
112+
owner: "{{ item.owner | default(es_user) }}"
113+
group: "{{ item.group | default(es_group) }}"
114+
mode: "{{ item.mode | default('660') }}"
115+
loop: "{{ es_additional_files }}"
116+
when:
117+
- es_additional_files is defined
118+
- es_additional_files | length > 0
119+

tasks/xpack/security/elasticsearch-security.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,30 @@
5757
ES_PATH_CONF: "{{ es_conf_dir }}"
5858
check_mode: no
5959

60-
- name: Add keystore entries
60+
- name: Add keystore string entries
6161
become: yes
6262
shell: echo {{ item.value | quote }} | {{ es_home }}/bin/elasticsearch-keystore add -x -f {{ item.key }}
6363
with_items: "{{ es_keystore_entries }}"
6464
when:
6565
- es_keystore_entries is defined and es_keystore_entries | length > 0
6666
- item.state is undefined or item.state == 'present'
67+
- item.file is undefined or not item.file
6768
- item.force|default(False) or ( not item.force|default(False) and item.key not in list_keystore.stdout_lines )
6869
- ('bootstrap.password' not in item.key)
6970
no_log: true
7071

72+
- name: Add keystore file entries
73+
become: yes
74+
command: >
75+
{{ es_home }}/bin/elasticsearch-keystore add-file -f {{ item.key }} {{ item.value }}
76+
with_items: "{{ es_keystore_entries }}"
77+
when:
78+
- es_keystore_entries is defined and es_keystore_entries | length > 0
79+
- item.state is undefined or item.state == 'present'
80+
- item.file is defined and item.file
81+
- item.force|default(False) or ( not item.force|default(False) and item.key not in list_keystore.stdout_lines )
82+
- ('bootstrap.password' not in item.key)
83+
no_log: true
7184

7285
### END BLOCK elasticsearch keystore ###
7386

0 commit comments

Comments
 (0)