From a306c467e7457e7d24401425c79f1e0e89f0c081 Mon Sep 17 00:00:00 2001 From: Alexander Gabriel Date: Tue, 29 Nov 2022 18:58:41 +0100 Subject: [PATCH] first commit --- files/.gitignore | 1 + handlers/main.yml | 7 +++++ tasks/main.yml | 46 +++++++++++++++++++++++++++++ templates/loki-local-config.yaml.j2 | 30 +++++++++++++++++++ templates/loki.service.j2 | 12 ++++++++ 5 files changed, 96 insertions(+) create mode 100644 files/.gitignore create mode 100644 handlers/main.yml create mode 100644 tasks/main.yml create mode 100644 templates/loki-local-config.yaml.j2 create mode 100644 templates/loki.service.j2 diff --git a/files/.gitignore b/files/.gitignore new file mode 100644 index 0000000..8bebc6c --- /dev/null +++ b/files/.gitignore @@ -0,0 +1 @@ +loki-linux-amd64 \ No newline at end of file diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..69f4c5d --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,7 @@ +--- +- name: restart loki + service: + daemon_reload: yes + name: loki + state: restarted + diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..ca6d454 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,46 @@ +--- +- name: Create user loki + user: + name: loki + system: yes + group: root + +- name: copy loki binaries + copy: + src: loki-linux-amd64 + dest: /usr/local/bin/loki + owner: root + group: root + mode: '0755' + backup: no + +- name: generate /etc/systemd/system/loki.service + template: + src: loki.service.j2 + dest: /etc/systemd/system/loki.service + owner: root + group: root + mode: "0644" + notify: + - restart loki + +- name: enable loki + systemd: + name: loki + enabled: yes + masked: no + notify: + - restart loki + +- name: generate /etc/loki-local-config.yaml + template: + src: loki-local-config.yaml.j2 + dest: /etc/loki.yaml + owner: root + group: root + mode: "0644" + notify: + - restart loki + +- name: Flush handlers + meta: flush_handlers diff --git a/templates/loki-local-config.yaml.j2 b/templates/loki-local-config.yaml.j2 new file mode 100644 index 0000000..d37ee60 --- /dev/null +++ b/templates/loki-local-config.yaml.j2 @@ -0,0 +1,30 @@ +auth_enabled: false + +server: + http_listen_port: 3100 + grpc_listen_port: 9096 + +common: + path_prefix: /tmp/loki + storage: + filesystem: + chunks_directory: /tmp/loki/chunks + rules_directory: /tmp/loki/rules + replication_factor: 1 + ring: + instance_addr: 127.0.0.1 + kvstore: + store: inmemory + +schema_config: + configs: + - from: 2020-10-24 + store: boltdb-shipper + object_store: filesystem + schema: v11 + index: + prefix: index_ + period: 24h + +ruler: + alertmanager_url: http://localhost:9093 diff --git a/templates/loki.service.j2 b/templates/loki.service.j2 new file mode 100644 index 0000000..660f49f --- /dev/null +++ b/templates/loki.service.j2 @@ -0,0 +1,12 @@ + +[Unit] +Description=Loki service +After=network.target + +[Service] +Type=simple +User=loki +ExecStart=/usr/local/bin/loki -config.file /etc/loki.yaml + +[Install] +WantedBy=multi-user.target \ No newline at end of file