Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ansible/host_vars/ldap01/alloy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
alloy_extra_files:
- name: dirsrv_access
path: "/var/log/dirsrv/slapd-*/access"
- name: dirsrv_error
path: "/var/log/dirsrv/slapd-*/errors"

alloy_extra_groups:
- dirsrv
2 changes: 1 addition & 1 deletion ansible/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
- common
- pydis-mtls
- wireguard
- alloy
- munin-node

- name: Deploy services to Netcup nodes
hosts: netcup
roles:
- certbot
- ci-user
- alloy
- lke-nftables-update
- nftables
- prometheus-node-exporter
Expand Down
8 changes: 6 additions & 2 deletions ansible/roles/alloy/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
---
alloy_grafana_signing_key: "https://apt.grafana.com/gpg.key"
alloy_grafana_repository: "https://apt.grafana.com"
alloy_debian_grafana_signing_key: "https://apt.grafana.com/gpg.key"
alloy_debian_grafana_repository: "https://apt.grafana.com"

alloy_rocky_grafana_signing_key: "https://rpm.grafana.com/gpg.key"
alloy_rocky_grafana_repository: "https://rpm.grafana.com"

alloy_extra_files: []
alloy_extra_groups: []
54 changes: 51 additions & 3 deletions ansible/roles/alloy/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
---

- name: Add Grafana apt repository with key
- name: Add Grafana apt repository (Rocky)
yum_repository:
name: grafana
description: Grafana Repository
baseurl: "{{ alloy_rocky_grafana_repository }}"
gpgcheck: true
gpgkey: "{{ alloy_rocky_grafana_signing_key }}"
when: ansible_facts["distribution"] == "Rocky"
Comment thread
jchristgit marked this conversation as resolved.
tags:
- role::alloy

- name: Add Grafana apt repository with key (Debian)
deb822_repository:
name: grafana
types: deb
uris: "{{ alloy_grafana_repository }}"
uris: "{{ alloy_debian_grafana_repository }}"
state: present
suites: [stable]
components: [main]
signed_by: "{{ alloy_grafana_signing_key }}"
signed_by: "{{ alloy_debian_grafana_signing_key }}"
when: ansible_facts["distribution"] == "Debian"
tags:
- role::alloy

Expand Down Expand Up @@ -61,3 +73,39 @@
enabled: true
tags:
- role::alloy

- name: Add user to extra groups for Alloy
user:
name: "alloy"
groups: "{{ alloy_extra_groups }}"
append: true
when: alloy_extra_groups | length > 0
tags:
- role::alloy
notify:
- Restart the alloy service

# We need to add cap_dac_read_search=+ep to the Alloy binary.

- name: Get Alloy binary path
command: "which alloy"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if ansible sanitizes PATH (or does not preserve it from the user it's escalating from)? If not, something malicious modifying PATH on the profile of whoever deploys could cause this to set cap_dac_read_search on the binary.

register: alloy_binary_path
changed_when: false
tags:
- role::alloy

- name: Get the current capabilities of the Alloy binary
command: "getcap {{ alloy_binary_path.stdout }}"
register: alloy_getcap_output
changed_when: false
tags:
- role::alloy

- name: Set capabilities on the Alloy binary
command: "setcap cap_dac_read_search=ep {{ alloy_binary_path.stdout }}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this be done via systemd?

man systemd.exec, see AmbientCapabilities. That way we can remove this whole dance and just set it in the service, no?

changed_when: true
when: "'cap_dac_read_search=ep' not in alloy_getcap_output.stdout"
tags:
- role::alloy
notify:
- Restart the alloy service
26 changes: 26 additions & 0 deletions ansible/roles/alloy/templates/config.alloy.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,35 @@ logging {
level = "info"
}

livedebugging {
enabled = true
}

Comment on lines +7 to +10
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this not expose sensitive information in some way that I'm missing? Judging by the Grafana docs, this relates to the Alloy UI. I haven't followed the deployment - do we expose that somewhere?

loki.source.journal "system_journal" {
format_as_json = true
forward_to = [loki.process.journal_labels.receiver]
}

loki.process "journal_labels" {
forward_to = [loki.write.pydis_gateway.receiver]

stage.json {
expressions = {
unit = "_SYSTEMD_UNIT",
}
}

stage.labels {
values = {
unit = "unit",
}
}

stage.static_labels {
values = {
job = "system_journal",
}
}
}

{% for extra in alloy_extra_files %}
Expand Down