From Ansible doc (https://docs.ansible.com/ansible/latest/modules/template_module.html#template-module) For those used to /usr/bin/chmod remember that modes are actually octal numbers. You must either add a leading zero so that Ansible's YAML parser knows it is an octal number (like 0644 or 01777) or quote it (like '644' or '1777') so Ansible receives a string and can do its own conversion from string into number. Giving Ansible a number without following one of these rules will end up with a decimal number which will have unexpected results.
31 lines
932 B
YAML
31 lines
932 B
YAML
---
|
||
|
||
- name: ensure templates dir is created
|
||
file:
|
||
path: "{{ es_conf_dir }}/templates"
|
||
state: directory
|
||
owner: root
|
||
group: "{{ es_group }}"
|
||
mode: "2750"
|
||
|
||
- name: Copy templates to elasticsearch
|
||
copy: src={{ item }} dest={{ es_conf_dir }}/templates owner=root group={{ es_group }} mode=0660
|
||
register: load_templates
|
||
with_fileglob:
|
||
- "{{ es_templates_fileglob | default('') }}"
|
||
|
||
- name: Install templates
|
||
uri:
|
||
url: "{{ es_api_uri }}/_template/{{item | filename}}"
|
||
method: PUT
|
||
status_code: 200
|
||
user: "{{es_api_basic_auth_username | default(omit)}}"
|
||
password: "{{es_api_basic_auth_password | default(omit)}}"
|
||
force_basic_auth: yes
|
||
body_format: json
|
||
body: "{{ lookup('file', item) }}"
|
||
validate_certs: "{{ es_validate_certs }}"
|
||
when: load_templates.changed and es_start_service
|
||
with_fileglob:
|
||
- "{{ es_templates_fileglob | default('') }}"
|
||
run_once: True
|