Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 0e57631

Browse files
authored
Merge pull request #3 from weakcamel/update_github_actions_and_fix_lint
fix Github actions
2 parents cbb4427 + 98d3ceb commit 0e57631

7 files changed

Lines changed: 48 additions & 42 deletions

File tree

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v2
1414
- name: Lint Ansible Playbook
15-
uses: ansible/ansible-lint-action@master
15+
uses: ansible/ansible-lint-action@main

defaults/main.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,18 @@ loki_chunk_store_config:
5252

5353
loki_schema_config:
5454
configs:
55-
- from: 2020-01-01
56-
store: boltdb
57-
object_store: filesystem
58-
schema: v11
59-
index:
60-
prefix: index_
61-
period: 168h
62-
63-
chunks:
64-
prefix: index_
65-
period: 168h
66-
row_shards: 16
55+
- from: 2020-01-01
56+
store: boltdb
57+
object_store: filesystem
58+
schema: v11
59+
index:
60+
prefix: index_
61+
period: 168h
62+
63+
chunks:
64+
prefix: index_
65+
period: 168h
66+
row_shards: 16
6767

6868
loki_limits_config:
6969
enforce_metric_name: false
@@ -94,9 +94,9 @@ promtail_scrape_config:
9494
host: "{{ ansible_hostname }}"
9595
max_age: 12h
9696
relabel_configs:
97-
- source_labels:
98-
- __journal__systemd_unit
99-
target_label: unit
97+
- source_labels:
98+
- __journal__systemd_unit
99+
target_label: unit
100100

101101
promtail_target_config: []
102102
promtail_positions_config:

handlers/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
---
22
- name: restart loki
33
become: true
4-
systemd:
4+
ansible.builtin.systemd:
55
daemon_reload: true
66
name: loki
77
state: restarted
88
when: ('loki' in loki_bins)
99

1010
- name: reload loki
1111
become: true
12-
systemd:
12+
ansible.builtin.systemd:
1313
name: loki
1414
state: reloaded
1515
when: ('loki' in loki_bins)
1616

1717
- name: restart promtail
1818
become: true
19-
systemd:
19+
ansible.builtin.systemd:
2020
daemon_reload: true
2121
name: promtail
2222
state: restarted
2323
when: ('promtail' in loki_bins)
2424

2525
- name: reload promtail
2626
become: true
27-
systemd:
27+
ansible.builtin.systemd:
2828
name: promtail
2929
state: reloaded
30-
when: ('promtail' in loki_bins)
30+
when: ('promtail' in loki_bins)

meta/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ galaxy_info:
55
description: Deploy and configure Loki and Promtail.
66
issue_tracker_url: https://github.com/weakcamel/ansible-role-loki/issues
77
license: WTFPL
8-
min_ansible_version: 2.9
8+
min_ansible_version: "2.9"
99
platforms:
1010
- name: Ubuntu
1111
versions:

tasks/configure.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
- name: configure loki
3-
template:
3+
ansible.builtin.template:
44
src: "loki.yml.j2"
55
dest: "{{ loki_config_dir }}/loki.yml"
66
force: true
@@ -12,7 +12,7 @@
1212
when: ('loki' in loki_bins)
1313

1414
- name: configure promtail
15-
template:
15+
ansible.builtin.template:
1616
src: "promtail.yml.j2"
1717
dest: "{{ loki_config_dir }}/promtail.yml"
1818
force: true
@@ -21,4 +21,4 @@
2121
mode: 0640
2222
notify:
2323
- reload promtail
24-
when: ('promtail' in loki_bins)
24+
when: ('promtail' in loki_bins)

tasks/install.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
- name: create {{ loki_group }} system group
3-
group:
3+
ansible.builtin.group:
44
name: "{{ loki_group }}"
55
system: true
66
state: present
77

88
- name: create {{ loki_user }} system user
9-
user:
9+
ansible.builtin.user:
1010
name: "{{ loki_user }}"
1111
system: true
1212
shell: "/usr/sbin/nologin"
@@ -15,7 +15,7 @@
1515
home: "{{ loki_storage_dir }}"
1616

1717
- name: create loki data directory
18-
file:
18+
ansible.builtin.file:
1919
path: "{{ item }}"
2020
state: directory
2121
owner: loki
@@ -28,7 +28,7 @@
2828
when: ('loki' in loki_bins)
2929

3030
- name: create loki configuration directories
31-
file:
31+
ansible.builtin.file:
3232
path: "{{ item }}"
3333
state: directory
3434
owner: root
@@ -37,13 +37,15 @@
3737
with_items:
3838
- "{{ loki_config_dir }}"
3939

40-
- block:
40+
- name: retrieve Loki binaries
41+
block:
4142
- name: download binaries to a temporary folder
4243
become: false
43-
get_url:
44+
ansible.builtin.get_url:
4445
url: "https://github.com/grafana/loki/releases/download/v{{ loki_version }}/{{ item }}-linux-{{ go_arch }}.zip"
4546
dest: "/tmp/{{ item }}-{{ loki_version }}-linux-{{ go_arch }}.zip"
4647
checksum: "sha256:{{ __loki_bins_checksum[item] }}"
48+
mode: 0644
4749
register: _download_archive
4850
until: _download_archive is succeeded
4951
retries: 5
@@ -53,7 +55,7 @@
5355

5456
- name: unpack binaries
5557
become: false
56-
unarchive:
58+
ansible.builtin.unarchive:
5759
src: "/tmp/{{ item }}-{{ loki_version }}-linux-{{ go_arch }}.zip"
5860
dest: "/tmp"
5961
creates: "/tmp/{{ item }}-{{ loki_version }}-linux-{{ go_arch }}"
@@ -62,7 +64,7 @@
6264
check_mode: false
6365

6466
- name: propagate official binaries
65-
copy:
67+
ansible.builtin.copy:
6668
src: "/tmp/{{ item }}-linux-{{ go_arch }}"
6769
dest: "/usr/local/bin/{{ item }}"
6870
mode: 0755
@@ -74,7 +76,7 @@
7476
- restart loki
7577

7678
- name: create systemd service unit
77-
template:
79+
ansible.builtin.template:
7880
src: "{{ item }}.service.j2"
7981
dest: "/etc/systemd/system/{{ item }}.service"
8082
owner: root

tasks/preflight.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
---
22
- name: Assert usage of systemd as an init system
3-
assert:
3+
ansible.builtin.assert:
44
that: ansible_service_mgr == 'systemd'
55
msg: "This module only works with systemd"
66

7-
- block:
7+
- name: Get loki latest release
8+
block:
89
- name: Get latest release
9-
uri:
10+
ansible.builtin.uri:
1011
url: "https://api.github.com/repos/grafana/loki/releases/latest"
1112
method: GET
1213
return_content: true
@@ -21,20 +22,23 @@
2122
retries: 5
2223

2324
- name: Set loki version to {{ _latest_release.json.tag_name[1:] }}
24-
set_fact:
25+
ansible.builtin.set_fact:
2526
loki_version: "{{ _latest_release.json.tag_name[1:] }}"
2627
when:
2728
- loki_version == "latest"
2829
- loki_binary_local_dir | length == 0
2930

30-
- block:
31+
- name: Load loki checksums
32+
block:
3133
- name: Get checksum list
32-
set_fact:
33-
__loki_checksums: "{{ lookup('url', 'https://github.com/grafana/loki/releases/download/v' + loki_version + '/SHA256SUMS', wantlist=True) | list }}"
34+
ansible.builtin.set_fact:
35+
__loki_checksums: >-
36+
{{ lookup('url', 'https://github.com/grafana/loki/releases/download/v'
37+
+ loki_version + '/SHA256SUMS', wantlist=True) | list }}
3438
run_once: true
3539

3640
- name: Get checksum for bins
37-
set_fact:
41+
ansible.builtin.set_fact:
3842
__loki_bins_checksum: "{{ __loki_bins_checksum | default({}) | combine({item[1]: item[0].split()[0]}) }}"
3943
loop: "{{ lookup('nested', __loki_checksums, loki_bins, wantlist=True) }}"
4044
when:

0 commit comments

Comments
 (0)