Skip to content

Commit a232ae2

Browse files
authored
Add SUSE support to Alloy role (#423)
1 parent bd1319b commit a232ae2

File tree

7 files changed

+36
-11
lines changed

7 files changed

+36
-11
lines changed

.github/workflows/alloy-molecule.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
- rockylinux9
2424
- ubuntu2204
2525
- debian12
26+
- opensuseleap15
2627

2728
steps:
2829
- name: Check out the codebase.

roles/alloy/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![License](https://img.shields.io/github/license/grafana/grafana-ansible-collection)](LICENSE)
44

55
This Ansible role to install and configure [Alloy](https://grafana.com/docs/alloy/latest/), which can be used to collect traces, metrics, and logs.
6-
This role is tailored for operating systems such as **RedHat**, **Rocky Linux**, **AlmaLinux**, **Ubuntu**, **Debian**, and **macOS**.
6+
This role is tailored for operating systems such as **RedHat**, **Rocky Linux**, **AlmaLinux**, **Ubuntu**, **Debian**, **macOS**, and **openSUSE**.
77

88
## Table of Content
99

roles/alloy/meta/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ galaxy_info:
2222
- name: macOS
2323
versions:
2424
- all
25+
- name: opensuse
26+
versions:
27+
- all
2528
galaxy_tags:
2629
- alloy
2730
- grafana

roles/alloy/tasks/deploy.yml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
alloy_version: "{{ __github_latest_version.json.tag_name | regex_replace('^v?(\\d+\\.\\d+\\.\\d+)$', '\\1') }}"
1919

2020
- name: Verify current deployed version
21-
when: ansible_facts['os_family'] in ['RedHat', 'Debian']
21+
when: ansible_facts['os_family'] in ['RedHat', 'Debian', 'Suse']
2222
block:
2323
- name: Check if Alloy binary is present
2424
ansible.builtin.stat:
@@ -62,10 +62,15 @@
6262
file: setup-Darwin.yml
6363
when: ansible_facts['os_family'] == 'Darwin'
6464

65+
- name: Include SUSE setup
66+
ansible.builtin.include_tasks:
67+
file: setup-Suse.yml
68+
when: ansible_facts['os_family'] == 'Suse'
69+
6570
- name: Alloy systemd override
6671
when:
6772
- alloy_systemd_override | length > 0
68-
- ansible_facts['os_family'] in ['RedHat', 'Debian']
73+
- ansible_facts['os_family'] in ['RedHat', 'Debian', 'Suse']
6974
block:
7075
- name: Ensure that Alloy systemd override path exist
7176
ansible.builtin.file:
@@ -93,7 +98,7 @@
9398
group: "root"
9499
mode: "0644"
95100
notify: restart alloy
96-
when: ansible_facts['os_family'] in ['RedHat', 'Debian']
101+
when: ansible_facts['os_family'] in ['RedHat', 'Debian', 'Suse']
97102

98103
- name: Template Alloy config - /etc/alloy/config.alloy
99104
ansible.builtin.template:
@@ -105,7 +110,7 @@
105110
when:
106111
- alloy_config | length > 0
107112
- alloy_env_file_vars.CONFIG_FILE is not defined
108-
- ansible_facts['os_family'] in ['RedHat', 'Debian']
113+
- ansible_facts['os_family'] in ['RedHat', 'Debian', 'Suse']
109114
notify: restart alloy
110115

111116
- name: Ensure that /etc/alloy/alloy.config is absent when a custom configuration file/dir is specified in alloy_env_file_vars.CONFIG_FILE
@@ -114,7 +119,7 @@
114119
state: absent
115120
when:
116121
- alloy_config | length < 1 or alloy_env_file_vars.CONFIG_FILE is defined
117-
- ansible_facts['os_family'] in ['RedHat', 'Debian']
122+
- ansible_facts['os_family'] in ['RedHat', 'Debian', 'Suse']
118123

119124
- name: Add the Alloy system user to additional group
120125
ansible.builtin.user:
@@ -127,13 +132,13 @@
127132
loop: "{{ alloy_user_groups }}"
128133
when:
129134
- alloy_user_groups | length > 0
130-
- ansible_facts['os_family'] in ['RedHat', 'Debian']
135+
- ansible_facts['os_family'] in ['RedHat', 'Debian', 'Suse']
131136

132137
- name: Get firewalld state
133138
ansible.builtin.systemd:
134139
name: "firewalld"
135140
register: __firewalld_service_state
136-
when: ansible_facts['os_family'] in ['RedHat', 'Debian']
141+
when: ansible_facts['os_family'] in ['RedHat', 'Debian', 'Suse']
137142

138143
- name: Enable firewalld rule to expose Alloy tcp port {{ __alloy_server_http_listen_port }}
139144
ansible.posix.firewalld:
@@ -142,7 +147,7 @@
142147
port: "{{ __alloy_server_http_listen_port }}/tcp"
143148
state: enabled
144149
when:
145-
- ansible_facts['os_family'] in ['RedHat', 'Debian']
150+
- ansible_facts['os_family'] in ['RedHat', 'Debian', 'Suse']
146151
- __firewalld_service_state.status.ActiveState == "active"
147152
- alloy_expose_port | bool
148153

@@ -155,7 +160,7 @@
155160
state: started
156161
when:
157162
- not ansible_check_mode
158-
- ansible_facts['os_family'] in ['RedHat', 'Debian']
163+
- ansible_facts['os_family'] in ['RedHat', 'Debian', 'Suse']
159164

160165
- name: Verify that Alloy URL is responding
161166
ansible.builtin.uri:
@@ -168,4 +173,4 @@
168173
until: __alloy_verify_url_status_code.status == 200
169174
when:
170175
- not ansible_check_mode
171-
- ansible_facts['os_family'] in ['RedHat', 'Debian']
176+
- ansible_facts['os_family'] in ['RedHat', 'Debian', 'Suse']

roles/alloy/tasks/setup-Suse.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
- name: Zypper - Install Alloy from remote URL
3+
community.general.zypper:
4+
name: "{{ alloy_download_url_rpm }}"
5+
state: present
6+
disable_gpg_check: true
7+
notify: restart alloy
8+
when: __current_deployed_version.stdout is not defined or alloy_version not in __current_deployed_version.stdout

roles/alloy/tasks/uninstall.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
state: absent
3131
when: ansible_facts['os_family'] == 'Darwin'
3232

33+
- name: Uninstall Alloy rpm package (SUSE)
34+
community.general.zypper:
35+
name: "alloy"
36+
state: absent
37+
when: ansible_facts['os_family'] == 'Suse'
38+
3339
- name: Ensure that Alloy firewalld rule is not present - tcp port {{ __alloy_server_http_listen_port }}
3440
ansible.posix.firewalld: # noqa ignore-errors
3541
immediate: true

roles/alloy/vars/Suse.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
__alloy_env_file: "/etc/sysconfig/alloy"

0 commit comments

Comments
 (0)