Fix loki install

This commit is contained in:
SebClem 2023-05-23 19:02:58 +02:00
parent 8c0ed55dad
commit 7f95e05fbf
Signed by: sebclem
GPG Key ID: 5A4308F6A359EA50
3 changed files with 18 additions and 35 deletions

View File

@ -5,5 +5,6 @@
"*.yml": "ansible"
},
"ansible.ansible.useFullyQualifiedCollectionNames": true,
"editor.formatOnSave": true
"editor.formatOnSave": true,
"ansible.python.interpreterPath": "/bin/python3"
}

View File

@ -27,6 +27,14 @@
- "{{ loki_storage_dir }}/chunks"
when: ('loki' in loki_bins)
- name: Create Bin directories
ansible.builtin.file:
path: "/opt/loki"
state: directory
owner: root
group: root
mode: "0755"
- name: Create loki configuration directories
ansible.builtin.file:
path: "{{ item }}"
@ -37,35 +45,28 @@
with_items:
- "{{ loki_config_dir }}"
- name: Download bin
- name: Install bin
block:
- name: Unpack binaries
ansible.builtin.unarchive:
remote_src: true
src: "https://github.com/grafana/loki/releases/download/v{{ loki_version }}/{{ item }}-linux-{{ go_arch }}.zip"
dest: "/tmp"
loop: "{{ loki_bins }}"
check_mode: false
- name: Copy binaries
ansible.builtin.copy:
src: "/tmp/{{ item }}-linux-{{ go_arch }}"
dest: "/usr/local/bin/{{ item }}"
dest: "/opt/loki/"
mode: "0755"
owner: root
group: root
remote_src: true
loop: "{{ loki_bins }}"
notify:
- restart loki
when: _download_archive is changed
- name: Clean binaries
- name: Create bin symlink
ansible.builtin.file:
path: "/tmp/{{ item }}-linux-{{ go_arch }}"
state: absent
src: "/opt/loki/{{ item }}-linux-{{ go_arch }}"
dest: "/usr/local/bin/{{ item }}"
state: link
loop: "{{ loki_bins }}"
when: _download_archive is changed
notify:
- restart loki
- name: Create systemd service unit
ansible.builtin.template:

View File

@ -28,25 +28,6 @@
ansible.builtin.set_fact:
loki_version: "{{ _latest_release.json.tag_name[1:] }}"
- name: Get checksums
delegate_to: localhost
when:
- loki_binary_local_dir | length == 0
block:
- name: Get checksum list
ansible.builtin.set_fact:
__loki_checksums: "{{ lookup('url', 'https://github.com/grafana/loki/releases/download/v' + loki_version + '/SHA256SUMS', wantlist=True) | list }}"
run_once: true
- name: Get checksum for bins
ansible.builtin.set_fact:
__loki_bins_checksum: "{{ __loki_bins_checksum | default({}) | combine({item[1]: item[0].split()[0]}) }}"
loop: "{{ lookup('nested', __loki_checksums, loki_bins, wantlist=True) }}"
when:
- "(item[1] + '-linux-' + go_arch + '.zip') in item[0].split()[1]"
- name: Install unzip
ansible.builtin.apt:
name: unzip