Compare commits
1 Commits
add-gitlab
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| bafa282482 |
@@ -7,11 +7,11 @@ Install Grafana Alloy from the release binary and configures it to scrape log fi
|
|||||||
## Variables
|
## Variables
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
grafana_alloy_version: "1.17.1"
|
alloy_version: "1.17.1"
|
||||||
grafana_alloy_config_dir: "/etc/alloy"
|
alloy_config_dir: "/etc/alloy"
|
||||||
grafana_alloy_data_dir: "/var/lib/alloy"
|
alloy_data_dir: "/var/lib/alloy"
|
||||||
grafana_alloy_loki_url: "http://localhost:3100/loki/api/v1/push"
|
alloy_loki_url: "http://localhost:3100/loki/api/v1/push"
|
||||||
grafana_alloy_log_paths:
|
alloy_log_paths:
|
||||||
- "/var/log/*.log"
|
- "/var/log/*.log"
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -23,8 +23,8 @@ grafana_alloy_log_paths:
|
|||||||
roles:
|
roles:
|
||||||
- role: grafana_alloy
|
- role: grafana_alloy
|
||||||
vars:
|
vars:
|
||||||
grafana_alloy_loki_url: "http://loki.example.com:3100/loki/api/v1/push"
|
alloy_loki_url: "http://loki.example.com:3100/loki/api/v1/push"
|
||||||
grafana_alloy_log_paths:
|
alloy_log_paths:
|
||||||
- "/var/log/*.log"
|
- "/var/log/*.log"
|
||||||
- "/var/log/myapp/*.log"
|
- "/var/log/myapp/*.log"
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
grafana_alloy_version: "1.17.1"
|
grafana_alloy_version: "1.17.1"
|
||||||
grafana_alloy_config_dir: "/etc/alloy"
|
grafana_alloy_config_dir: "/etc/alloy"
|
||||||
grafana_alloy_data_dir: "/var/lib/alloy"
|
grafana_alloy_data_dir: "/var/lib/alloy"
|
||||||
grafana_alloy_loki_port: 3100
|
grafana_alloy_loki_url: "http://localhost:3100/loki/api/v1/push"
|
||||||
grafana_alloy_loki_url: "http://localhost:{{ grafana_alloy_loki_port }}/loki/api/v1/push"
|
|
||||||
grafana_alloy_log_paths:
|
grafana_alloy_log_paths:
|
||||||
- "/var/log/*.log"
|
- "/var/log/*.log"
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
name: "alloy"
|
name: "alloy"
|
||||||
system: true
|
system: true
|
||||||
shell: "/sbin/nologin"
|
shell: "/sbin/nologin"
|
||||||
groups: "adm"
|
groups: "adm,systemd-journal"
|
||||||
|
append: true
|
||||||
create_home: false
|
create_home: false
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
@@ -23,16 +24,13 @@
|
|||||||
block:
|
block:
|
||||||
- name: "Install | Check Alloy version"
|
- name: "Install | Check Alloy version"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
failed_when: false
|
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
cmd: "alloy --version"
|
cmd: "alloy --version"
|
||||||
register: grafana_alloy_ver
|
register: grafana_alloy_ver
|
||||||
|
|
||||||
- name: "Install | Assert version correctness"
|
- name: "Install | Assert version correctness"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that: "grafana_alloy_version in grafana_alloy_ver.stdout"
|
||||||
- "grafana_alloy_ver.rc == 0"
|
|
||||||
- "grafana_alloy_version in grafana_alloy_ver.stdout"
|
|
||||||
success_msg: "alloy version {{ grafana_alloy_version }} is installed and working"
|
success_msg: "alloy version {{ grafana_alloy_version }} is installed and working"
|
||||||
fail_msg: "alloy version {{ grafana_alloy_version }} is not installed or not working correctly"
|
fail_msg: "alloy version {{ grafana_alloy_version }} is not installed or not working correctly"
|
||||||
|
|
||||||
@@ -42,26 +40,10 @@
|
|||||||
name: "unzip"
|
name: "unzip"
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: "Install | Download the distribution archive"
|
- name: "Install | Fetch and unpack the distribution"
|
||||||
ansible.builtin.get_url:
|
|
||||||
url: "https://github.com/grafana/alloy/releases/download/v{{ grafana_alloy_version }}/alloy-linux-amd64.zip"
|
|
||||||
dest: "/tmp/alloy-linux-amd64.zip"
|
|
||||||
group: "alloy"
|
|
||||||
owner: "alloy"
|
|
||||||
mode: "0644"
|
|
||||||
timeout: 30
|
|
||||||
force: true
|
|
||||||
register: grafana_alloy_download_status
|
|
||||||
until: grafana_alloy_download_status is success
|
|
||||||
retries: 3
|
|
||||||
delay: 5
|
|
||||||
|
|
||||||
- name: "Install | Unpack and delete the distribution"
|
|
||||||
ansible.builtin.unarchive:
|
ansible.builtin.unarchive:
|
||||||
src: "/tmp/alloy-linux-amd64.zip"
|
src: "https://github.com/grafana/alloy/releases/download/v{{ grafana_alloy_version }}/alloy-linux-amd64.zip"
|
||||||
dest: "/tmp"
|
dest: "/tmp"
|
||||||
group: "alloy"
|
|
||||||
owner: "alloy"
|
|
||||||
remote_src: true
|
remote_src: true
|
||||||
|
|
||||||
- name: "Install | Put the binary under the PATH"
|
- name: "Install | Put the binary under the PATH"
|
||||||
@@ -75,11 +57,8 @@
|
|||||||
mode: "0755"
|
mode: "0755"
|
||||||
|
|
||||||
- name: "Install | Clean up the downloads"
|
- name: "Install | Clean up the downloads"
|
||||||
loop:
|
|
||||||
- "/tmp/alloy-linux-amd64"
|
|
||||||
- "/tmp/alloy-linux-amd64.zip"
|
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ item }}"
|
path: "/tmp/alloy-linux-amd64"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: "Install | Create a systemd service unit"
|
- name: "Install | Create a systemd service unit"
|
||||||
@@ -87,6 +66,6 @@
|
|||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: alloy.service.j2
|
src: alloy.service.j2
|
||||||
dest: /etc/systemd/system/alloy.service
|
dest: /etc/systemd/system/alloy.service
|
||||||
owner: "root"
|
owner: "alloy"
|
||||||
group: "root"
|
group: "alloy"
|
||||||
mode: "0600"
|
mode: "0660"
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ ExecStart=/usr/bin/alloy run {{ grafana_alloy_config_dir }}/config.alloy \
|
|||||||
ExecReload=/bin/kill -HUP $MAINPID
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
|
|
||||||
# Security hardening
|
# Security hardening
|
||||||
ReadWritePaths={{ grafana_alloy_data_dir }} {{ grafana_alloy_config_dir }}
|
ReadWritePaths={{ grafana_alloy_data_dir }}
|
||||||
ProtectSystem=strict
|
ProtectSystem=strict
|
||||||
NoNewPrivileges=true
|
NoNewPrivileges=true
|
||||||
PrivateTmp=true
|
PrivateTmp=true
|
||||||
|
|||||||
Reference in New Issue
Block a user