Update loki playbook
This commit is contained in:
parent
1c8bc92000
commit
2c3c38f106
8
ansible/etc/systemd/system/loki-backup.service.j2
Normal file
8
ansible/etc/systemd/system/loki-backup.service.j2
Normal file
@ -0,0 +1,8 @@
|
||||
[Unit]
|
||||
Description=Backup Loki server
|
||||
|
||||
[Service]
|
||||
WorkingDirectory={{ loki_dir }}
|
||||
Type=oneshot
|
||||
ExecStartPre={{ loki_dir }}/registry-cleaner.sh
|
||||
ExecStart={{ loki_dir }}/backup.sh -b
|
10
ansible/etc/systemd/system/loki-backup.timer.j2
Normal file
10
ansible/etc/systemd/system/loki-backup.timer.j2
Normal file
@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=Back up Loki once a week
|
||||
|
||||
[Timer]
|
||||
OnCalendar=weekly
|
||||
AccuracySec=1h
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
@ -3,7 +3,7 @@ Description=Dockerised web server
|
||||
After=docker.service
|
||||
|
||||
[Service]
|
||||
WorkingDirectory=/root/Loki
|
||||
WorkingDirectory={{ loki_dir }}
|
||||
Environment="COMPOSE_HTTP_TIMEOUT=300"
|
||||
ExecStart=/usr/bin/docker-compose up
|
||||
ExecStop=/usr/bin/docker-compose down
|
@ -6,7 +6,6 @@
|
||||
|
||||
vars:
|
||||
- debian_release: buster
|
||||
- loki_dir: /srv/loki
|
||||
|
||||
tasks:
|
||||
|
||||
@ -61,20 +60,6 @@
|
||||
dest: "{{ loki_dir }}"
|
||||
register: loki_git
|
||||
|
||||
- block:
|
||||
- name: Install Loki service
|
||||
command: cp "{{ loki_dir }}"/loki-server.service /lib/systemd/system/
|
||||
|
||||
- name: Update service file
|
||||
lineinfile:
|
||||
path: /lib/systemd/system/loki-server.service
|
||||
regexp: '^WorkingDirectory='
|
||||
line: 'WorkingDirectory={{ loki_dir }}'
|
||||
|
||||
- name: Reload systemd daemon
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
|
||||
- block:
|
||||
- name: Update
|
||||
command: ./update.sh
|
||||
@ -100,8 +85,46 @@
|
||||
dest: /etc/hosts
|
||||
mode: 0644
|
||||
|
||||
- name: Ensure service is started
|
||||
# -------------------------------------------------------------------------
|
||||
# Loki server service.
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
- name: Install Loki server
|
||||
template:
|
||||
src: ./etc/systemd/system/loki-server.service.j2
|
||||
dest: /etc/systemd/system/loki-server.service
|
||||
mode: 0644
|
||||
|
||||
- name: Enable and start Loki server
|
||||
service:
|
||||
name: loki-server
|
||||
state: started
|
||||
enabled: yes
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# Loki backup service.
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
- name: Create GitLab credentials file
|
||||
template:
|
||||
src: ./gitlab.cred.j2
|
||||
dest: "{{ loki_dir }}/gitlab.cred"
|
||||
mode: 0644
|
||||
|
||||
- name: Install Loki backup service
|
||||
template:
|
||||
src: ./etc/systemd/system/loki-backup.service.j2
|
||||
dest: /etc/systemd/system/loki-backup.service
|
||||
mode: 0644
|
||||
|
||||
- name: Install Loki backup timer
|
||||
template:
|
||||
src: ./etc/systemd/system/loki-backup.timer.j2
|
||||
dest: /etc/systemd/system/loki-backup.timer
|
||||
mode: 0644
|
||||
|
||||
- name: Enable and start Loki backup
|
||||
service:
|
||||
name: loki-backup.timer
|
||||
state: started
|
||||
enabled: yes
|
||||
|
Reference in New Issue
Block a user