Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
elasticsearch
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Ansible
Roles
elasticsearch
Commits
b6d8a606
Commit
b6d8a606
authored
Mar 02, 2019
by
Jürgen Haas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve some scripts
parent
c7b05c6b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
1 deletion
+40
-1
files/elasticsearch-remove-readonly
files/elasticsearch-remove-readonly
+16
-0
files/purge.py
files/purge.py
+5
-1
tasks/main.yml
tasks/main.yml
+1
-0
tasks/readonly.yml
tasks/readonly.yml
+18
-0
No files found.
files/elasticsearch-remove-readonly
0 → 100644
View file @
b6d8a606
#!/bin/bash
if
[[
"x
$1
"
=
"x"
]]
;
then
DATE
=
`
date
+%Y.%m.%d
`
elasticsearch-remove-readonly .kibana_2
elasticsearch-remove-readonly .kibana_1
elasticsearch-remove-readonly ansible
elasticsearch-remove-readonly
uptime
elasticsearch-remove-readonly logstash-
$DATE
elasticsearch-remove-readonly heartbeat-6.6.1-
$DATE
exit
0
fi
echo
""
echo
"Unlock
$1
"
curl
-X
PUT http://127.0.0.1:9200/
$1
/_settings
-H
'Content-Type: application/json'
-d
'{"index.blocks.read_only_allow_delete":null}'
files/purge.py
View file @
b6d8a606
...
...
@@ -29,6 +29,7 @@ def getIndex():
buffer
=
StringIO
()
c
=
pycurl
.
Curl
()
c
.
setopt
(
c
.
URL
,
'localhost:9200/_cat/indices?v&pretty&s=index&format=json'
)
c
.
setopt
(
c
.
HTTPHEADER
,
[
'Content-Type: application/json'
])
c
.
setopt
(
c
.
WRITEDATA
,
buffer
)
c
.
perform
()
c
.
close
()
...
...
@@ -38,12 +39,13 @@ def getIndex():
def
purgeSingle
(
cat
,
day
):
for
index
in
cat
:
if
index
[
'index'
]
==
args
.
index
:
post_data
=
{
"query"
:{
"bool"
:{
"filter"
:{
"range"
:{
"
syslog_time"
:{
"lte"
:
day
.
strftime
(
'%d/%b/%Y:00:00:00 +0000
'
)}}}}}}
post_data
=
{
"query"
:{
"bool"
:{
"filter"
:{
"range"
:{
"
@timestamp"
:{
"lte"
:
day
.
strftime
(
'%Y-%m-%d
'
)}}}}}}
postfields
=
json
.
dumps
(
post_data
)
print
(
' Postfields: '
+
postfields
)
buffer
=
StringIO
()
c
=
pycurl
.
Curl
()
c
.
setopt
(
c
.
URL
,
'localhost:9200/'
+
args
.
index
+
'/_delete_by_query'
)
c
.
setopt
(
c
.
HTTPHEADER
,
[
'Content-Type: application/json'
])
c
.
setopt
(
c
.
WRITEDATA
,
buffer
)
c
.
setopt
(
c
.
POSTFIELDS
,
postfields
)
c
.
perform
()
...
...
@@ -53,6 +55,7 @@ def purgeSingle(cat, day):
buffer
=
StringIO
()
c
=
pycurl
.
Curl
()
c
.
setopt
(
c
.
URL
,
'localhost:9200/'
+
args
.
index
+
'/_forcemerge?only_expunge_deletes=true'
)
c
.
setopt
(
c
.
HTTPHEADER
,
[
'Content-Type: application/json'
])
c
.
setopt
(
c
.
WRITEDATA
,
buffer
)
c
.
setopt
(
c
.
POSTFIELDS
,
''
)
c
.
perform
()
...
...
@@ -72,6 +75,7 @@ def purgeDaily(cat, day):
buffer
=
StringIO
()
c
=
pycurl
.
Curl
()
c
.
setopt
(
c
.
URL
,
'localhost:9200/'
+
index
[
'index'
])
c
.
setopt
(
c
.
HTTPHEADER
,
[
'Content-Type: application/json'
])
c
.
setopt
(
c
.
WRITEDATA
,
buffer
)
c
.
setopt
(
c
.
CUSTOMREQUEST
,
'DELETE'
)
c
.
perform
()
...
...
tasks/main.yml
View file @
b6d8a606
...
...
@@ -18,5 +18,6 @@
loop_var
:
index
-
import_tasks
:
purge.yml
-
import_tasks
:
readonly.yml
when
:
'
"elasticsearch"
not
in
excluded_roles'
tasks/readonly.yml
0 → 100644
View file @
b6d8a606
---
# file: roles/elasticsearch/tasks/readonly.yml
-
name
:
"
Copy
script"
copy
:
src
:
'
elasticsearch-remove-readonly'
dest
:
'
/usr/local/bin/elasticsearch-remove-readonly'
mode
:
'
0755'
tags
:
'
cron'
-
name
:
"
Set
Remove
Readonly
Crons"
cron
:
name
:
'
Elasticsearch
Remove
Readonly'
hour
:
'
5'
minute
:
'
55'
job
:
'
/usr/local/bin/elasticsearch-remove-readonly
>>/var/log/elasticsearch/readonly.log
2>&1'
disabled
:
'
{{
item.disabled|default(false)
}}'
tags
:
'
cron'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment