Skip to content

Commit f3a6ece

Browse files
authored
Merge pull request elastic#175 from jakommo/master
Use network.host and http.port for templates and scripts, if available
2 parents 5caf76b + d92f468 commit f3a6ece

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

handlers/elasticsearch-templates.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
service: name={{instance_init_script | basename}} state=started enabled=yes
55

66
- name: Wait for elasticsearch to startup
7-
wait_for: port={{es_api_port}} delay=10
7+
wait_for: host={% if es_config['network.host'] is defined %}{{es_config['network.host']}}{% else %}{{es_api_host}}{% endif %} port={% if es_config['http.port'] is defined %}{{es_config['http.port']}}{% else %}{{es_api_port}}{% endif %} delay=10
88

99
- name: Get template files
1010
find: paths="/etc/elasticsearch/templates" patterns="*.json"
1111
register: templates
1212

1313
- name: Install templates without auth
1414
uri:
15-
url: "http://{{es_api_host}}:{{es_api_port}}/_template/{{item.path | filename}}"
15+
url: "http://{% if es_config['network.host'] is defined %}{{es_config['network.host']}}{% else %}{{es_api_host}}{% endif %}:{% if es_config['http.port'] is defined %}{{es_config['http.port']}}{% else %}{{es_api_port}}{% endif %}/_template/{{item.path | filename}}"
1616
method: PUT
1717
status_code: 200
1818
body_format: json
@@ -22,7 +22,7 @@
2222

2323
- name: Install templates with auth
2424
uri:
25-
url: "http://{{es_api_host}}:{{es_api_port}}/_template/{{item.path | filename}}"
25+
url: "http://{% if es_config['network.host'] is defined %}{{es_config['network.host']}}{% else %}{{es_api_host}}{% endif %}:{% if es_config['http.port'] is defined %}{{es_config['http.port']}}{% else %}{{es_api_port}}{% endif %}/_template/{{item.path | filename}}"
2626
method: PUT
2727
status_code: 200
2828
user: "{{es_api_basic_auth_username}}"

handlers/shield/elasticsearch-shield-native.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
service: name={{instance_init_script | basename}} state=started enabled=yes
55

66
- name: Wait for elasticsearch to startup
7-
wait_for: port={{es_api_port}} delay=10
7+
wait_for: host={% if es_config['network.host'] is defined %}{{es_config['network.host']}}{% else %}{{es_api_host}}{% endif %} port={% if es_config['http.port'] is defined %}{{es_config['http.port']}}{% else %}{{es_api_port}}{% endif %} delay=10
88

99
- set_fact: manage_native_users=false
1010

@@ -21,7 +21,7 @@
2121
#List current users
2222
- name: List Native Users
2323
uri:
24-
url: http://{{es_api_host}}:{{es_api_port}}/_shield/user
24+
url: http://{% if es_config['network.host'] is defined %}{{es_config['network.host']}}{% else %}{{es_api_host}}{% endif %}:{% if es_config['http.port'] is defined %}{{es_config['http.port']}}{% else %}{{es_api_port}}{% endif %}/_shield/user
2525
method: GET
2626
user: "{{es_api_basic_auth_username}}"
2727
password: "{{es_api_basic_auth_password}}"
@@ -42,7 +42,7 @@
4242
#Delete all non required users
4343
- name: Delete Native Users
4444
uri:
45-
url: http://{{es_api_host}}:{{es_api_port}}/_shield/user/{{item}}
45+
url: http://{% if es_config['network.host'] is defined %}{{es_config['network.host']}}{% else %}{{es_api_host}}{% endif %}:{% if es_config['http.port'] is defined %}{{es_config['http.port']}}{% else %}{{es_api_port}}{% endif %}/_shield/user/{{item}}
4646
method: DELETE
4747
status_code: 200
4848
user: "{{es_api_basic_auth_username}}"
@@ -55,7 +55,7 @@
5555
#Overwrite all other users
5656
- name: Update Native Users
5757
uri:
58-
url: http://{{es_api_host}}:{{es_api_port}}/_shield/user/{{item.key}}
58+
url: http://{% if es_config['network.host'] is defined %}{{es_config['network.host']}}{% else %}{{es_api_host}}{% endif %}:{% if es_config['http.port'] is defined %}{{es_config['http.port']}}{% else %}{{es_api_port}}{% endif %}/_shield/user/{{item.key}}
5959
method: POST
6060
body_format: json
6161
body: "{{item.value | to_json}}"
@@ -70,7 +70,7 @@
7070

7171
- name: List Native Roles
7272
uri:
73-
url: http://{{es_api_host}}:{{es_api_port}}/_shield/role
73+
url: http://{% if es_config['network.host'] is defined %}{{es_config['network.host']}}{% else %}{{es_api_host}}{% endif %}:{% if es_config['http.port'] is defined %}{{es_config['http.port']}}{% else %}{{es_api_port}}{% endif %}/_shield/role
7474
method: GET
7575
body_format: json
7676
user: "{{es_api_basic_auth_username}}"
@@ -94,7 +94,7 @@
9494
#Delete all non required roles
9595
- name: Delete Native Roles
9696
uri:
97-
url: http://{{es_api_host}}:{{es_api_port}}/_shield/role/{{item}}
97+
url: http://{% if es_config['network.host'] is defined %}{{es_config['network.host']}}{% else %}{{es_api_host}}{% endif %}:{% if es_config['http.port'] is defined %}{{es_config['http.port']}}{% else %}{{es_api_port}}{% endif %}/_shield/role/{{item}}
9898
method: DELETE
9999
status_code: 200
100100
user: "{{es_api_basic_auth_username}}"
@@ -107,7 +107,7 @@
107107
#Update other roles
108108
- name: Update Native Roles
109109
uri:
110-
url: http://{{es_api_host}}:{{es_api_port}}/_shield/role/{{item.key}}
110+
url: http://{% if es_config['network.host'] is defined %}{{es_config['network.host']}}{% else %}{{es_api_host}}{% endif %}:{% if es_config['http.port'] is defined %}{{es_config['http.port']}}{% else %}{{es_api_port}}{% endif %}/_shield/role/{{item.key}}
111111
method: POST
112112
body_format: json
113113
body: "{{item.value | to_json}}"
@@ -117,6 +117,3 @@
117117
force_basic_auth: yes
118118
when: manage_native_roles and es_roles.native.keys() > 0
119119
with_dict: "{{es_roles.native}}"
120-
121-
122-

0 commit comments

Comments
 (0)