mirror of
https://github.com/KevinMidboe/playbooks-retailor.git
synced 2026-02-16 22:39:15 +00:00
ansible playbooks for retailor.io infrastructure
This commit is contained in:
2
roles/promtail/defaults/main.yml
Normal file
2
roles/promtail/defaults/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
promtail_version: 3.4.2
|
||||
53
roles/promtail/tasks/main.yml
Normal file
53
roles/promtail/tasks/main.yml
Normal file
@@ -0,0 +1,53 @@
|
||||
---
|
||||
- name: Download the promtail archive
|
||||
get_url:
|
||||
url: "https://github.com/grafana/loki/releases/download/v{{ promtail_version }}/promtail-linux-amd64.zip"
|
||||
dest: "/tmp/promtail.zip"
|
||||
|
||||
- name: Extract promtail
|
||||
unarchive:
|
||||
src: "/tmp/promtail.zip"
|
||||
dest: "/tmp"
|
||||
remote_src: yes
|
||||
|
||||
- name: Move promtail binary
|
||||
copy:
|
||||
src: "/tmp/promtail-linux-amd64"
|
||||
dest: "/usr/local/bin/promtail"
|
||||
remote_src: yes
|
||||
mode: '0755'
|
||||
|
||||
- name: Create promtail service
|
||||
template:
|
||||
src: "promtail.service.j2"
|
||||
dest: "/etc/systemd/system/promtail.service"
|
||||
mode: '0644'
|
||||
tags:
|
||||
- create_promtail_service
|
||||
|
||||
- name: Reload systemd to pick up the promtail service
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
tags:
|
||||
- reload_systemd
|
||||
|
||||
- name: Enable and start the promtail service
|
||||
systemd:
|
||||
name: promtail
|
||||
state: started
|
||||
enabled: yes
|
||||
tags:
|
||||
- start_promtail
|
||||
|
||||
- name: Create promtail configuration file directory
|
||||
file:
|
||||
path: /etc/promtail
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Create promtail configuration file
|
||||
template:
|
||||
src: promtail.yml.j2
|
||||
dest: /etc/promtail/config.yml
|
||||
|
||||
|
||||
13
roles/promtail/templates/promtail.service.j2
Normal file
13
roles/promtail/templates/promtail.service.j2
Normal file
@@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=Promtail service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
ExecStart=/usr/local/bin/promtail -config.file /etc/promtail/config.yml --client.external-labels=hostname=%H
|
||||
Restart=on-failure
|
||||
RestartSec=20
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
32
roles/promtail/templates/promtail.yml.j2
Normal file
32
roles/promtail/templates/promtail.yml.j2
Normal file
@@ -0,0 +1,32 @@
|
||||
server:
|
||||
http_listen_port: 9080
|
||||
grpc_listen_port: 0
|
||||
|
||||
positions:
|
||||
filename: /tmp/positions.yaml
|
||||
|
||||
client:
|
||||
url: http://prometheus-grafana:3100/loki/api/v1/push
|
||||
scrape_configs:
|
||||
- job_name: nginx
|
||||
static_configs:
|
||||
- targets:
|
||||
- localhost
|
||||
labels:
|
||||
job: nginx
|
||||
__path__: /var/log/nginx/*.log
|
||||
|
||||
pipeline_stages:
|
||||
- regex:
|
||||
expression: '^(?P<remote_addr>\S+) - - \[(?P<timestamp>[^\]]+)\] "(?P<method>\S+) (?P<path>\S+) (?P<protocol>\S+)" (?P<status>\d+) (?P<bytes>\d+) "(?P<referrer>[^\"]*)" "(?P<user_agent>[^\"]*)"'
|
||||
- timestamp:
|
||||
source: "timestamp"
|
||||
format: "02/Jan/2006:15:04:05 -0700"
|
||||
- labels:
|
||||
remote_addr:
|
||||
method:
|
||||
path:
|
||||
protocol:
|
||||
status:
|
||||
referrer:
|
||||
user_agent:
|
||||
Reference in New Issue
Block a user