This commit is contained in:
Diogenes Pelisson 2020-05-04 18:48:42 -03:00
parent d4dbe48400
commit 38e4d7926f
7 changed files with 28 additions and 50 deletions

View File

@ -8,19 +8,16 @@ Requirements
- Ansible >= 2.9
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Example Playbook
----------------
------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
Install Loki and Promtail in local machine
```
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
- { role: diogenxs.loki, loki_bins: ['loki', 'promtail'] }
```
License
-------
@ -30,4 +27,4 @@ WTFPL see [LICENSE](license)
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
https://diogenxs.dev

View File

@ -48,7 +48,7 @@ loki_storage_config:
directory: "{{ loki_storage_dir }}/chunks"
loki_chunk_store_config:
max_look_back_period: 0
max_look_back_period: 0s
loki_schema_config:
configs:
@ -73,16 +73,6 @@ loki_limits_config:
loki_frontend_worker_config: []
loki_runtime_config: []
loki_table_manager_config:
chunk_tables_provisioning:
inactive_read_throughput: 0
inactive_write_throughput: 0
provisioned_read_throughput: 0
provisioned_write_throughput: 0
index_tables_provisioning:
inactive_read_throughput: 0
inactive_write_throughput: 0
provisioned_read_throughput: 0
provisioned_write_throughput: 0
retention_deletes_enabled: false
retention_period: 0
@ -100,7 +90,7 @@ promtail_scrape_config:
- job_name: journal
journal:
labels:
job: systemd-journal
job: node
host: "{{ ansible_hostname }}"
max_age: 12h
relabel_configs:

View File

@ -5,12 +5,14 @@
daemon_reload: true
name: loki
state: restarted
when: ('loki' in loki_bins)
- name: reload loki
become: true
systemd:
name: loki
state: reloaded
when: ('loki' in loki_bins)
- name: restart promtail
become: true
@ -18,9 +20,11 @@
daemon_reload: true
name: promtail
state: restarted
when: ('promtail' in loki_bins)
- name: reload promtail
become: true
systemd:
name: promtail
state: reloaded
when: ('promtail' in loki_bins)

View File

@ -49,6 +49,8 @@
retries: 5
delay: 2
loop: "{{ loki_bins }}"
delegate_to: localhost
check_mode: false
- name: unpack binaries
become: false
@ -57,6 +59,8 @@
dest: "/tmp"
creates: "/tmp/{{ item }}-{{ loki_version }}-linux-{{ go_arch }}"
loop: "{{ loki_bins }}"
delegate_to: localhost
check_mode: false
- name: propagate official binaries
copy:

View File

@ -1,8 +1,14 @@
---
- include: preflight.yml
tags:
- loki_pre_install
- include: install.yml
become: true
tags:
- loki_configure
- include: configure.yml
become: true
tags:
- loki_configure

View File

@ -11,20 +11,9 @@ User={{ loki_user }}
Group={{ loki_group }}
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/local/bin/loki \
-config.file {{ loki_config_dir }}/loki.yml \
-config.file {{ loki_config_dir }}/loki.yml
CapabilityBoundingSet=CAP_SET_UID
LimitNOFILE=65000
LockPersonality=true
NoNewPrivileges=true
MemoryDenyWriteExecute=true
PrivateDevices=true
PrivateTmp=true
ProtectHome=true
RemoveIPC=true
RestrictSUIDSGID=true
SyslogIdentifier=loki
Restart=always

View File

@ -1,30 +1,18 @@
{{ ansible_managed | comment }}
[Unit]
Description=Loki
Description=Promtail
After=network-online.target
[Service]
Type=simple
Environment="GOMAXPROCS={{ ansible_processor_vcpus|default(ansible_processor_count) }}"
User={{ loki_user }}
Group={{ loki_group }}
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/local/bin/promtail \
-config.file {{ loki_config_dir }}/promtail.yml \
-config.file {{ loki_config_dir }}/promtail.yml
CapabilityBoundingSet=CAP_SET_UID
LimitNOFILE=65000
LockPersonality=true
NoNewPrivileges=true
MemoryDenyWriteExecute=true
PrivateDevices=true
PrivateTmp=true
ProtectHome=true
RemoveIPC=true
RestrictSUIDSGID=true
SyslogIdentifier=loki
SyslogIdentifier=promtail
Restart=always
[Install]