web-logs: Use logsync user for syncing logs
This commit is contained in:
parent
663038ced2
commit
283a16a97b
2 changed files with 27 additions and 7 deletions
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -u
|
set -u
|
||||||
umask 022
|
umask 027
|
||||||
|
|
||||||
TARGET="/var/cache/sync-http-logs"
|
TARGET="/var/cache/sync-http-logs"
|
||||||
CONFIG="/etc/rclone/rclone.conf"
|
CONFIG="/etc/rclone/rclone.conf"
|
||||||
|
@ -10,6 +10,11 @@ RCLONE="/usr/local/bin/rclone"
|
||||||
|
|
||||||
timestamp="$(date +%Y%m%d%H%M%S)"
|
timestamp="$(date +%Y%m%d%H%M%S)"
|
||||||
|
|
||||||
|
if [ "$(whoami)" != "logsync" ]; then
|
||||||
|
echo "ERR: Script needs to be run as logsync user" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -d "$TARGET" ]; then
|
if [ ! -d "$TARGET" ]; then
|
||||||
echo "ERR: Destination directory '${TARGET}' does not exist" 1>&2
|
echo "ERR: Destination directory '${TARGET}' does not exist" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
@ -6,6 +6,21 @@
|
||||||
with_items:
|
with_items:
|
||||||
- rclone
|
- rclone
|
||||||
|
|
||||||
|
- name: create logsync group
|
||||||
|
group:
|
||||||
|
name: logsync
|
||||||
|
system: true
|
||||||
|
|
||||||
|
- name: create logsync user
|
||||||
|
user:
|
||||||
|
name: logsync
|
||||||
|
comment: Service logsync
|
||||||
|
createhome: false
|
||||||
|
group: logsync
|
||||||
|
home: /var/empty
|
||||||
|
shell: /sbin/nologin
|
||||||
|
system: true
|
||||||
|
|
||||||
- name: create ssh known_hosts
|
- name: create ssh known_hosts
|
||||||
template:
|
template:
|
||||||
dest: /etc/ssh/ssh_known_hosts
|
dest: /etc/ssh/ssh_known_hosts
|
||||||
|
@ -18,9 +33,9 @@
|
||||||
file:
|
file:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
state: directory
|
state: directory
|
||||||
mode: 0755
|
mode: 0750
|
||||||
owner: root
|
owner: logsync
|
||||||
group: "{{ ansible_wheel }}"
|
group: logsync
|
||||||
with_items:
|
with_items:
|
||||||
- /var/cache/sync-http-logs
|
- /var/cache/sync-http-logs
|
||||||
|
|
||||||
|
@ -28,8 +43,8 @@
|
||||||
file:
|
file:
|
||||||
path: /var/log/rclone
|
path: /var/log/rclone
|
||||||
state: directory
|
state: directory
|
||||||
mode: 0755
|
mode: 0750
|
||||||
owner: root
|
owner: logsync
|
||||||
group: "{{ ansible_wheel }}"
|
group: "{{ ansible_wheel }}"
|
||||||
|
|
||||||
- name: copy logsync script
|
- name: copy logsync script
|
||||||
|
@ -59,7 +74,7 @@
|
||||||
- name: add log sync cron job
|
- name: add log sync cron job
|
||||||
cron:
|
cron:
|
||||||
name: sync-http-logs
|
name: sync-http-logs
|
||||||
user: root
|
user: logsync
|
||||||
hour: "3"
|
hour: "3"
|
||||||
minute: "0"
|
minute: "0"
|
||||||
job: /usr/local/bin/sync-http-logs
|
job: /usr/local/bin/sync-http-logs
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue