Skip to content

Commit

Permalink
Merge pull request #5 from weakcamel/fix_linter_errors
Browse files Browse the repository at this point in the history
address all ansible-lint findings
  • Loading branch information
weakcamel authored Nov 10, 2022
2 parents 4ed7f95 + 77d9ae7 commit 58a308e
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ jobs:
linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Lint Ansible Playbook
uses: ansible/ansible-lint-action@main
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: galaxy
uses: robertdebock/[email protected].0
uses: robertdebock/[email protected].1
with:
galaxy_api_key: ${{ secrets.galaxy_api_key }}
8 changes: 4 additions & 4 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
---
- name: restart loki
- name: Restart loki
become: true
ansible.builtin.systemd:
daemon_reload: true
name: loki
state: restarted
when: ('loki' in loki_bins)

- name: reload loki
- name: Reload loki
become: true
ansible.builtin.systemd:
name: loki
state: reloaded
when: ('loki' in loki_bins)

- name: restart promtail
- name: Restart promtail
become: true
ansible.builtin.systemd:
daemon_reload: true
name: promtail
state: restarted
when: ('promtail' in loki_bins)

- name: reload promtail
- name: Reload promtail
become: true
ansible.builtin.systemd:
name: promtail
Expand Down
8 changes: 4 additions & 4 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: configure loki
- name: Configure loki
ansible.builtin.template:
src: "loki.yml.j2"
dest: "{{ loki_config_dir }}/loki.yml"
Expand All @@ -8,10 +8,10 @@
group: "{{ loki_user }}"
mode: 0640
notify:
- reload loki
- Reload loki
when: ('loki' in loki_bins)

- name: configure promtail
- name: Configure promtail
ansible.builtin.template:
src: "promtail.yml.j2"
dest: "{{ loki_config_dir }}/promtail.yml"
Expand All @@ -20,5 +20,5 @@
group: "{{ loki_user }}"
mode: 0640
notify:
- reload promtail
- Reload promtail
when: ('promtail' in loki_bins)
22 changes: 11 additions & 11 deletions tasks/install.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
- name: create {{ loki_group }} system group
- name: Create system group {{ loki_group }}
ansible.builtin.group:
name: "{{ loki_group }}"
system: true
state: present

- name: create {{ loki_user }} system user
- name: Create system user {{ loki_user }}
ansible.builtin.user:
name: "{{ loki_user }}"
system: true
Expand All @@ -14,7 +14,7 @@
createhome: false
home: "{{ loki_storage_dir }}"

- name: create loki data directory
- name: Create loki data directory
ansible.builtin.file:
path: "{{ item }}"
state: directory
Expand All @@ -27,7 +27,7 @@
- "{{ loki_storage_dir }}/chunks"
when: ('loki' in loki_bins)

- name: create loki configuration directories
- name: Create loki configuration directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
Expand All @@ -37,9 +37,9 @@
with_items:
- "{{ loki_config_dir }}"

- name: retrieve Loki binaries
- name: Retrieve Loki binaries
block:
- name: download binaries to a temporary folder
- name: Download binaries to a temporary folder
become: false
ansible.builtin.get_url:
url: "https://github.com/grafana/loki/releases/download/v{{ loki_version }}/{{ item }}-linux-{{ go_arch }}.zip"
Expand All @@ -53,7 +53,7 @@
loop: "{{ loki_bins }}"
check_mode: false

- name: unpack binaries
- name: Unpack binaries
become: false
ansible.builtin.unarchive:
src: "/tmp/{{ item }}-{{ loki_version }}-linux-{{ go_arch }}.zip"
Expand All @@ -63,7 +63,7 @@
loop: "{{ loki_bins }}"
check_mode: false

- name: propagate official binaries
- name: Propagate official binaries
ansible.builtin.copy:
src: "/tmp/{{ item }}-linux-{{ go_arch }}"
dest: "/usr/local/bin/{{ item }}"
Expand All @@ -73,15 +73,15 @@
remote_src: true
loop: "{{ loki_bins }}"
notify:
- restart loki
- Restart loki

- name: create systemd service unit
- name: Create systemd service unit
ansible.builtin.template:
src: "{{ item }}.service.j2"
dest: "/etc/systemd/system/{{ item }}.service"
owner: root
group: root
mode: 0644
notify: "restart {{ item }}"
notify: "Restart {{ item }}"
loop: "{{ loki_bins }}"
when: item == 'loki' or item == 'promtail'
6 changes: 3 additions & 3 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
- name: Pre-flight tasks
import_tasks: preflight.yml
ansible.builtin.import_tasks: preflight.yml
tags:
- loki_pre_install

- name: Installation tasks
import_tasks: install.yml
ansible.builtin.import_tasks: install.yml
become: true
tags:
- loki_configure

- name: Configuration tasks
import_tasks: configure.yml
ansible.builtin.import_tasks: configure.yml
become: true
tags:
- loki_configure
12 changes: 6 additions & 6 deletions tasks/preflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
msg: "This module only works with systemd"

- name: Get loki latest release
when:
- loki_version == "latest"
- loki_binary_local_dir | length == 0
block:
- name: Get latest release
ansible.builtin.uri:
Expand All @@ -24,11 +27,11 @@
- name: Set loki version to {{ _latest_release.json.tag_name[1:] }}
ansible.builtin.set_fact:
loki_version: "{{ _latest_release.json.tag_name[1:] }}"
when:
- loki_version == "latest"
- loki_binary_local_dir | length == 0

- name: Load loki checksums
when:
- loki_binary_local_dir | length == 0
delegate_to: localhost
block:
- name: Get checksum list
ansible.builtin.set_fact:
Expand All @@ -43,6 +46,3 @@
loop: "{{ lookup('nested', __loki_checksums, loki_bins, wantlist=True) }}"
when:
- "(item[1] + '-linux-' + go_arch + '.zip') in item[0].split()[1]"
delegate_to: localhost
when:
- loki_binary_local_dir | length == 0

0 comments on commit 58a308e

Please sign in to comment.