diff --git a/README.md b/README.md index d3d9b77..21ebf18 100644 --- a/README.md +++ b/README.md @@ -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 } +``` + - hosts: servers + roles: + - { 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 \ No newline at end of file diff --git a/defaults/main.yml b/defaults/main.yml index a969aa0..8d41f58 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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: diff --git a/handlers/main.yml b/handlers/main.yml index 45c4549..a3c4fcf 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -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) \ No newline at end of file diff --git a/tasks/install.yml b/tasks/install.yml index c4f8173..467c5c2 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -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: diff --git a/tasks/main.yml b/tasks/main.yml index 17fe52e..0a939fa 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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 diff --git a/templates/loki.service.j2 b/templates/loki.service.j2 index 5d6fa05..f219053 100644 --- a/templates/loki.service.j2 +++ b/templates/loki.service.j2 @@ -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 diff --git a/templates/promtail.service.j2 b/templates/promtail.service.j2 index 11407e5..58d2bce 100644 --- a/templates/promtail.service.j2 +++ b/templates/promtail.service.j2 @@ -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]