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 - 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 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 - hosts: servers
roles: roles:
- { role: username.rolename, x: 42 } - { role: diogenxs.loki, loki_bins: ['loki', 'promtail'] }
```
License License
------- -------
@ -30,4 +27,4 @@ WTFPL see [LICENSE](license)
Author Information 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" directory: "{{ loki_storage_dir }}/chunks"
loki_chunk_store_config: loki_chunk_store_config:
max_look_back_period: 0 max_look_back_period: 0s
loki_schema_config: loki_schema_config:
configs: configs:
@ -73,16 +73,6 @@ loki_limits_config:
loki_frontend_worker_config: [] loki_frontend_worker_config: []
loki_runtime_config: [] loki_runtime_config: []
loki_table_manager_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_deletes_enabled: false
retention_period: 0 retention_period: 0
@ -100,7 +90,7 @@ promtail_scrape_config:
- job_name: journal - job_name: journal
journal: journal:
labels: labels:
job: systemd-journal job: node
host: "{{ ansible_hostname }}" host: "{{ ansible_hostname }}"
max_age: 12h max_age: 12h
relabel_configs: relabel_configs:

View File

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

View File

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

View File

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

View File

@ -11,20 +11,9 @@ User={{ loki_user }}
Group={{ loki_group }} Group={{ loki_group }}
ExecReload=/bin/kill -HUP $MAINPID ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/local/bin/loki \ 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 LimitNOFILE=65000
LockPersonality=true
NoNewPrivileges=true
MemoryDenyWriteExecute=true
PrivateDevices=true
PrivateTmp=true
ProtectHome=true
RemoveIPC=true
RestrictSUIDSGID=true
SyslogIdentifier=loki SyslogIdentifier=loki
Restart=always Restart=always

View File

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