From 7f95e05fbf99cf5ffdb4c010dd8f4866803279ea Mon Sep 17 00:00:00 2001 From: SebClem Date: Tue, 23 May 2023 19:02:58 +0200 Subject: [PATCH] Fix loki install --- .vscode/settings.json | 3 ++- tasks/install.yml | 31 ++++++++++++++++--------------- tasks/preflight.yml | 19 ------------------- 3 files changed, 18 insertions(+), 35 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 2faa62e..4836ce9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,5 +5,6 @@ "*.yml": "ansible" }, "ansible.ansible.useFullyQualifiedCollectionNames": true, - "editor.formatOnSave": true + "editor.formatOnSave": true, + "ansible.python.interpreterPath": "/bin/python3" } diff --git a/tasks/install.yml b/tasks/install.yml index f614a0a..bed7bb8 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -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: diff --git a/tasks/preflight.yml b/tasks/preflight.yml index 6f63fb6..e7ba6ba 100644 --- a/tasks/preflight.yml +++ b/tasks/preflight.yml @@ -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