From b02da06c973aa449ec522ed6808dcc8d9dfad990 Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Sun, 14 Apr 2024 17:13:06 -0500 Subject: [PATCH] Add roles for lego, logcli, mimir, process_exporter, smokeping_prober, and vector --- roles/lego/defaults/main.yaml | 130 ++++++++++++++++++ roles/lego/handlers/main.yaml | 5 + roles/lego/tasks/configure.yaml | 98 +++++++++++++ roles/lego/tasks/default.yaml | 0 roles/lego/tasks/install.yaml | 56 ++++++++ roles/lego/tasks/main.yaml | 28 ++++ roles/lego/templates/environ.conf.j2 | 8 ++ roles/lego/templates/lego@.service.j2 | 31 +++++ roles/lego/templates/lego@.timer.j2 | 11 ++ roles/lego/vars/default.yaml | 0 roles/logcli/defaults/main.yaml | 57 ++++++++ roles/logcli/tasks/configure.yaml | 11 ++ roles/logcli/tasks/default.yaml | 0 roles/logcli/tasks/install.yaml | 56 ++++++++ roles/logcli/tasks/main.yaml | 28 ++++ roles/logcli/vars/default.yaml | 0 roles/mimir/defaults/main.yaml | 68 +++++++++ roles/mimir/files/grafana.gpg | Bin 0 -> 1758 bytes roles/mimir/handlers/main.yaml | 6 + roles/mimir/tasks/Debian.yaml | 14 ++ roles/mimir/tasks/configure.yaml | 48 +++++++ roles/mimir/tasks/default.yaml | 0 roles/mimir/tasks/install.yaml | 5 + roles/mimir/tasks/main.yaml | 28 ++++ roles/mimir/templates/config.yml.j2 | 51 +++++++ roles/mimir/vars/default.yaml | 0 roles/process_exporter/defaults/main.yaml | 43 ++++++ roles/process_exporter/handlers/main.yaml | 6 + roles/process_exporter/tasks/configure.yaml | 47 +++++++ roles/process_exporter/tasks/default.yaml | 0 roles/process_exporter/tasks/install.yaml | 30 ++++ roles/process_exporter/tasks/main.yaml | 30 ++++ roles/process_exporter/tasks/pre.yaml | 54 ++++++++ .../templates/process-exporter.service.j2 | 17 +++ roles/process_exporter/vars/default.yaml | 0 roles/smokeping_prober/defaults/main.yaml | 100 ++++++++++++++ roles/smokeping_prober/handlers/main.yaml | 6 + roles/smokeping_prober/tasks/configure.yaml | 55 ++++++++ roles/smokeping_prober/tasks/default.yaml | 0 roles/smokeping_prober/tasks/install.yaml | 56 ++++++++ roles/smokeping_prober/tasks/main.yaml | 28 ++++ .../templates/smokeping_prober.service.j2 | 27 ++++ roles/smokeping_prober/vars/default.yaml | 0 roles/vector/defaults/main.yaml | 34 +++++ roles/vector/handlers/main.yaml | 6 + roles/vector/tasks/Debian.yaml | 22 +++ roles/vector/tasks/configure.yaml | 84 +++++++++++ roles/vector/tasks/default.yaml | 0 roles/vector/tasks/install.yaml | 5 + roles/vector/tasks/main.yaml | 28 ++++ roles/vector/vars/default.yaml | 0 51 files changed, 1417 insertions(+) create mode 100644 roles/lego/defaults/main.yaml create mode 100644 roles/lego/handlers/main.yaml create mode 100644 roles/lego/tasks/configure.yaml create mode 100644 roles/lego/tasks/default.yaml create mode 100644 roles/lego/tasks/install.yaml create mode 100644 roles/lego/tasks/main.yaml create mode 100644 roles/lego/templates/environ.conf.j2 create mode 100644 roles/lego/templates/lego@.service.j2 create mode 100644 roles/lego/templates/lego@.timer.j2 create mode 100644 roles/lego/vars/default.yaml create mode 100644 roles/logcli/defaults/main.yaml create mode 100644 roles/logcli/tasks/configure.yaml create mode 100644 roles/logcli/tasks/default.yaml create mode 100644 roles/logcli/tasks/install.yaml create mode 100644 roles/logcli/tasks/main.yaml create mode 100644 roles/logcli/vars/default.yaml create mode 100644 roles/mimir/defaults/main.yaml create mode 100644 roles/mimir/files/grafana.gpg create mode 100644 roles/mimir/handlers/main.yaml create mode 100644 roles/mimir/tasks/Debian.yaml create mode 100644 roles/mimir/tasks/configure.yaml create mode 100644 roles/mimir/tasks/default.yaml create mode 100644 roles/mimir/tasks/install.yaml create mode 100644 roles/mimir/tasks/main.yaml create mode 100644 roles/mimir/templates/config.yml.j2 create mode 100644 roles/mimir/vars/default.yaml create mode 100644 roles/process_exporter/defaults/main.yaml create mode 100644 roles/process_exporter/handlers/main.yaml create mode 100644 roles/process_exporter/tasks/configure.yaml create mode 100644 roles/process_exporter/tasks/default.yaml create mode 100644 roles/process_exporter/tasks/install.yaml create mode 100644 roles/process_exporter/tasks/main.yaml create mode 100644 roles/process_exporter/tasks/pre.yaml create mode 100644 roles/process_exporter/templates/process-exporter.service.j2 create mode 100644 roles/process_exporter/vars/default.yaml create mode 100644 roles/smokeping_prober/defaults/main.yaml create mode 100644 roles/smokeping_prober/handlers/main.yaml create mode 100644 roles/smokeping_prober/tasks/configure.yaml create mode 100644 roles/smokeping_prober/tasks/default.yaml create mode 100644 roles/smokeping_prober/tasks/install.yaml create mode 100644 roles/smokeping_prober/tasks/main.yaml create mode 100644 roles/smokeping_prober/templates/smokeping_prober.service.j2 create mode 100644 roles/smokeping_prober/vars/default.yaml create mode 100644 roles/vector/defaults/main.yaml create mode 100644 roles/vector/handlers/main.yaml create mode 100644 roles/vector/tasks/Debian.yaml create mode 100644 roles/vector/tasks/configure.yaml create mode 100644 roles/vector/tasks/default.yaml create mode 100644 roles/vector/tasks/install.yaml create mode 100644 roles/vector/tasks/main.yaml create mode 100644 roles/vector/vars/default.yaml diff --git a/roles/lego/defaults/main.yaml b/roles/lego/defaults/main.yaml new file mode 100644 index 0000000..c8cc153 --- /dev/null +++ b/roles/lego/defaults/main.yaml @@ -0,0 +1,130 @@ +--- +lego_go_arch_map: + i386: '386' + x86_64: 'amd64' + +lego_go_arch: "{{ lego_go_arch_map[ansible_architecture] | default('amd64') }}" + +lego_version: 4.16.1 +# curl -L -s https://github.com/go-acme/lego/releases/download/v4.14.2/lego_4.14.2_checksums.txt | awk '{ printf "%s: sha256:%s\n", $2, $1 }' | sort +lego_checksums: + lego_v4.16.1_darwin_amd64.tar.gz: sha256:2555ae9c3976bb6d3d783819c7012572fecbd309330a5010dd1f9882332fa349 + lego_v4.16.1_darwin_arm64.tar.gz: sha256:609789c72a9c8e7f4f5916aa08440a299f63c75fee14f42e61904cda01f0736f + lego_v4.16.1_freebsd_386.tar.gz: sha256:41408e99b9f1fb823e53d53feb15cd0cb929ad3cd093b9010c7af7ba71077e55 + lego_v4.16.1_freebsd_amd64.tar.gz: sha256:9353c009c4801d7646b3c99803a77aa0f2a041f802c8794d16ba4b31af4a8dfb + lego_v4.16.1_freebsd_arm64.tar.gz: sha256:c39a98c8401a0fe506ac206ae5ef5e167d1dcd9e7f6bb27def954089c0f99839 + lego_v4.16.1_freebsd_armv5.tar.gz: sha256:b96b88a84aa51e77da8d4b92f6920b1890ae47c53e59c477d7b3b556b1273446 + lego_v4.16.1_freebsd_armv6.tar.gz: sha256:ea41ff383adcf98ff70a65e6da49c7c82d16071f3057e44e1c41b2fe34543f19 + lego_v4.16.1_freebsd_armv7.tar.gz: sha256:6e883cb6c12a7bb703018e85623bf2c548eebfd01047bda75820264bb8ff85f2 + lego_v4.16.1_linux_386.tar.gz: sha256:3eb2e75cc474b0a0b9a990ddd9c70e7c9631a150487d8434e03a295cfd4b0caa + lego_v4.16.1_linux_amd64.tar.gz: sha256:e9826f955337c1fd825d21b073168692711985e25db013ff6b00e9a55a9644b4 + lego_v4.16.1_linux_arm64.tar.gz: sha256:0669037c2bcff11d0599765c63f186dfc98397b6a827f5cb2e48e9e69c12626c + lego_v4.16.1_linux_armv5.tar.gz: sha256:33ff82f3aff43825b0fca7f173825c6cc6b02d9e5607dec147ba172e62c883c9 + lego_v4.16.1_linux_armv6.tar.gz: sha256:3532a986667fe4ba42366fe09a5487c273c168779f803d878b4cc990d29c5c94 + lego_v4.16.1_linux_armv7.tar.gz: sha256:b9727c1282a320c22d9fbdbdb59e35810c8b7f94d1382bfa87d564429a89629e + lego_v4.16.1_linux_mips64_hardfloat.tar.gz: sha256:055914fab0e26432590fccb54e400e1c0b1ad8d9932f0d418ed9ee7857765eed + lego_v4.16.1_linux_mips64_softfloat.tar.gz: sha256:6d79cde9f3f7598276e9f82d2c0fe94b541b35112c0d03797cae4bd9de289d78 + lego_v4.16.1_linux_mips64le_hardfloat.tar.gz: sha256:5a2421aed70c009d746eff8ffb8a1429dbfdda9c60d08790b53b88d7d4e0b270 + lego_v4.16.1_linux_mips64le_softfloat.tar.gz: sha256:c1e8afedc29d18e7cb6da4d42c77d41b11041f58637e453be1ac70f65dfba0bc + lego_v4.16.1_linux_mips_hardfloat.tar.gz: sha256:07bcd8f03dda24e7db4ef0be065680a8db2d1ec7b217aea2c4ee7f6a6d731928 + lego_v4.16.1_linux_mips_softfloat.tar.gz: sha256:0367bd328a9355b0191ae0f1b77a20e6a7f6c84a0a65d0a7e4a5f240e7737ed4 + lego_v4.16.1_linux_mipsle_hardfloat.tar.gz: sha256:49c6117c24e351921e9fdfc0fa01dc7dd007001602b4743f2854b85dde7dd410 + lego_v4.16.1_linux_mipsle_softfloat.tar.gz: sha256:e5771a43504deab162291c957c1cf549e287c15f645712c08e56f08e5ed97d4c + lego_v4.16.1_openbsd_386.tar.gz: sha256:7aaa14b081b8c2d18717c463b6ecea434c963366c82ad9824bcf61750b130c73 + lego_v4.16.1_openbsd_amd64.tar.gz: sha256:4249afea73a1f8cdec964a0471e841103d6575f6d8549005ec2c06efa063d0fe + lego_v4.16.1_openbsd_arm64.tar.gz: sha256:4e94b6714bfed91c06e7365da1da36624126b323dc2c0fdabe7fd3fb155f7cb5 + lego_v4.16.1_solaris_amd64.tar.gz: sha256:e9d33547a2671636bf02148677bd790996fb94688b0a055393675c645de150ec + lego_v4.16.1_windows_386.zip: sha256:980e5d8e6afb700f28c9b9ab539141c45fbd556e12c5b3deb114d7db056d7f0f + lego_v4.16.1_windows_amd64.zip: sha256:2716e8cc14facd60d804f849c1aeff6bb31bfa09719905d8f65ec801ead628ca + lego_v4.16.1_windows_arm64.zip: sha256:28179af7c79f01e8347dcaab65fba5b70abd36dcd0a2bcc2d6803cb177f2b72c + lego_v4.16.1_windows_armv5.zip: sha256:4017c2f1cbd8c838377e6816daccabc96d063b44749407c68e985af7f04fff6c + lego_v4.16.1_windows_armv6.zip: sha256:099992c58012440f693206ab0ea23dd1794f4093fd2ad62b744d6a08e3749efd + lego_v4.16.1_windows_armv7.zip: sha256:4b9557137c5d24996c3b44c223edf9495f0ea7df7f9a2d5da5f3dbc8f8ec8b50 + +lego_github_rel_path: go-acme/lego +lego_github_project_url: "https://github.com/{{ lego_github_rel_path }}" +lego_release_file: "lego_v{{ lego_version }}_{{ ansible_system | lower }}_{{ lego_go_arch }}.tar.gz" +lego_release_url: "{{ lego_github_project_url }}/releases/download/v{{ lego_version }}/{{ lego_release_file }}" +lego_download_path: "/tmp/{{ lego_release_file }}" + +lego_opt_dir_path: "/opt/lego-{{ lego_version }}" + +lego_unarchive_dest_path: /tmp/ +lego_extracted_path: "/tmp" +lego_binaries: + - lego + +lego_user_name: lego +lego_user_shell: /usr/sbin/nologin +lego_user_home: "{{ lego_var_dir_path }}" +lego_group_name: lego + +lego_bin_dir_path: /usr/local/bin +lego_bin_path: "{{ lego_bin_dir_path }}/lego" + +lego_etc_dir_path: /etc/lego +lego_etc_dir_path_owner: "{{ lego_user_name }}" +lego_etc_dir_path_group: "{{ lego_group_name }}" +lego_etc_dir_path_mode: ugo=rx +lego_etc_dir_path_state: directory + +lego_var_dir_path: /var/lib/lego +lego_var_dir_path_owner: "{{ lego_user_name }}" +lego_var_dir_path_group: "{{ lego_group_name }}" +lego_var_dir_path_mode: u=rwx,go=rx +lego_var_dir_path_state: directory + +lego_bin_args: + - --accept-tos + - --domains %i + - --domains www.%i + +lego_environ: + LEGO_PATH: "{{ lego_var_dir_path }}" + +lego_bin_user_args: [] +lego_user_environ: {} +lego_credential_files: [] + +lego_service_name: lego@.service +lego_service_enabled: true +lego_service_state: started + +lego_timer_name: lego@.timer +lego_timer_enabled: true +lego_timer_state: started + +lego_service_template_src: "{{ lego_service_name }}.j2" +lego_service_template_dest: "/etc/systemd/system/{{ lego_service_name }}" +lego_service_template_owner: root +lego_service_template_group: root +lego_service_template_mode: ugo=r + +lego_timer_template_src: "{{ lego_timer_name }}.j2" +lego_timer_template_dest: "/etc/systemd/system/{{ lego_timer_name }}" +lego_timer_template_owner: root +lego_timer_template_group: root +lego_timer_template_mode: ugo=r + +lego_systemd_service_d_dir_path: /etc/systemd/system/lego@.service.d +lego_systemd_service_d_dir_path_owner: root +lego_systemd_service_d_dir_path_group: root +lego_systemd_service_d_dir_path_mode: ugo=rx +lego_systemd_service_d_dir_path_state: directory + +lego_systemd_service_d_template_src: "environ.conf.j2" +lego_systemd_service_d_template_dest: "{{ lego_systemd_service_d_dir_path }}/environ.conf" +lego_systemd_service_d_template_path_owner: root +lego_systemd_service_d_template_path_group: root +lego_systemd_service_d_template_path_mode: u=r,go= + +lego_credential_file_owner: "{{ lego_user_name }}" +lego_credential_file_group: "{{ lego_group_name }}" +lego_credential_file_mode: u=r,go= + +# lego_domains: +# - name: example.com +# # not required +# enabled: true +# # not required +# state: started diff --git a/roles/lego/handlers/main.yaml b/roles/lego/handlers/main.yaml new file mode 100644 index 0000000..18d1fb2 --- /dev/null +++ b/roles/lego/handlers/main.yaml @@ -0,0 +1,5 @@ +--- +- name: restart lego + systemd: + name: "{{ lego_service_name }}" + daemon_reload: true \ No newline at end of file diff --git a/roles/lego/tasks/configure.yaml b/roles/lego/tasks/configure.yaml new file mode 100644 index 0000000..e128592 --- /dev/null +++ b/roles/lego/tasks/configure.yaml @@ -0,0 +1,98 @@ +--- +- name: create group + ansible.builtin.group: + name: "{{ lego_group_name }}" + system: true + +- name: create user + ansible.builtin.user: + name: "{{ lego_user_name }}" + shell: "{{ lego_user_shell }}" + home: "{{ lego_user_home }}" + system: true + group: "{{ lego_group_name }}" + +- name: create var path + ansible.builtin.file: + path: "{{ lego_var_dir_path }}" + owner: "{{ lego_var_dir_path_owner }}" + group: "{{ lego_var_dir_path_group }}" + mode: "{{ lego_var_dir_path_mode }}" + state: "{{ lego_var_dir_path_state }}" + +- name: create etc path + ansible.builtin.file: + path: "{{ lego_etc_dir_path }}" + owner: "{{ lego_etc_dir_path_owner }}" + group: "{{ lego_etc_dir_path_group }}" + mode: "{{ lego_etc_dir_path_mode }}" + state: "{{ lego_etc_dir_path_state }}" + +- name: "create {{ lego_systemd_service_d_dir_path }}" + ansible.builtin.file: + path: "{{ lego_systemd_service_d_dir_path }}" + owner: "{{ lego_systemd_service_d_dir_path_owner }}" + group: "{{ lego_systemd_service_d_dir_path_group }}" + mode: "{{ lego_systemd_service_d_dir_path_mode }}" + state: "{{ lego_systemd_service_d_dir_path_state }}" + +- name: "create {{ lego_systemd_service_d_template_dest }}" + ansible.builtin.template: + src: "{{ lego_systemd_service_d_template_src }}" + dest: "{{ lego_systemd_service_d_template_dest }}" + owner: "{{ lego_systemd_service_d_template_path_owner }}" + group: "{{ lego_systemd_service_d_template_path_group }}" + mode: "{{ lego_systemd_service_d_template_path_mode }}" + notify: + - restart lego + +- name: create credential files + ansible.builtin.copy: + dest: "{{ lego_etc_dir_path }}/{{ item.name }}" + owner: "{{ item.owner | default(lego_credential_file_owner) }}" + group: "{{ item.group | default(lego_credential_file_group) }}" + mode: "{{ item.mode | default(lego_credential_file_mode) }}" + content: "{{ item.content }}" + loop: "{{ lego_credential_files | default([]) }}" + no_log: true + +#- name: configure +# ansible.builtin.template: +# src: "{{ lego_config_file_template_src }}" +# dest: "{{ lego_config_file_template_dest }}" +# owner: "{{ lego_config_file_template_owner }}" +# group: "{{ lego_config_file_template_group }}" +# mode: "{{ lego_config_file_template_mode }}" +# notify: +# - restart lego +# +- name: configure systemd unit + ansible.builtin.template: + src: "{{ lego_service_template_src }}" + dest: "{{ lego_service_template_dest }}" + owner: "{{ lego_service_template_owner }}" + group: "{{ lego_service_template_group }}" + mode: "{{ lego_service_template_mode }}" + notify: + - restart lego + +- name: configure timer + ansible.builtin.template: + src: "{{ lego_timer_template_src }}" + dest: "{{ lego_timer_template_dest }}" + owner: "{{ lego_timer_template_owner }}" + group: "{{ lego_timer_template_group }}" + mode: "{{ lego_timer_template_mode }}" +# +#- name: manage service +# ansible.builtin.service: +# name: "{{ lego_service_name }}" +# enabled: "{{ lego_service_enabled | default(true) }}" +# state: "{{ lego_service_state | default('started') }}" + +- name: manage timers + ansible.builtin.systemd: + name: "lego@{{ item.name }}.timer" + enabled: "{{ item.enabled | default(true) }}" + state: "{{ item.state | default('started') }}" + loop: "{{ lego_domains | default([]) }}" \ No newline at end of file diff --git a/roles/lego/tasks/default.yaml b/roles/lego/tasks/default.yaml new file mode 100644 index 0000000..e69de29 diff --git a/roles/lego/tasks/install.yaml b/roles/lego/tasks/install.yaml new file mode 100644 index 0000000..31add8c --- /dev/null +++ b/roles/lego/tasks/install.yaml @@ -0,0 +1,56 @@ +--- +- name: determine install status + ansible.builtin.stat: + path: "{{ lego_opt_dir_path }}/lego" + register: st + +- name: create opt path + ansible.builtin.file: + path: "{{ lego_opt_dir_path }}" + owner: root + group: root + mode: 0755 + state: directory + +- block: + - name: download + ansible.builtin.get_url: + url: "{{ lego_release_url }}" + dest: "{{ lego_download_path }}" + checksum: "{{ lego_checksums[lego_release_file] }}" + register: dl + until: dl is success + retries: 5 + delay: 10 + + - name: extract + ansible.builtin.unarchive: + src: "{{ lego_download_path }}" + dest: "{{ lego_unarchive_dest_path }}" + remote_src: true + + - name: install + ansible.builtin.copy: + src: "{{ lego_extracted_path }}/{{ item }}" + dest: "{{ lego_opt_dir_path }}/{{ item }}" + remote_src: true + loop: "{{ lego_binaries }}" + when: not st.stat.exists + +- name: permissions + ansible.builtin.file: + path: "{{ lego_opt_dir_path }}/{{ item }}" + owner: root + group: root + mode: 0755 + loop: "{{ lego_binaries }}" + +- name: symlink + ansible.builtin.file: + src: "{{ lego_opt_dir_path }}/{{ item }}" + dest: "/usr/local/bin/{{ item }}" + owner: root + group: root + mode: 0755 + state: link + loop: "{{ lego_binaries }}" \ No newline at end of file diff --git a/roles/lego/tasks/main.yaml b/roles/lego/tasks/main.yaml new file mode 100644 index 0000000..b13a010 --- /dev/null +++ b/roles/lego/tasks/main.yaml @@ -0,0 +1,28 @@ +--- +- name: gather os specific variables + ansible.builtin.include_vars: "{{ lookup('first_found', params) }}" + vars: + params: + files: + - "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml" + - "{{ ansible_distribution }}.yaml" + - "{{ ansible_os_family }}.yaml" + - "default.yaml" + paths: + - vars + +- name: include os specific tasks + ansible.builtin.include_tasks: "{{ lookup('first_found', params) }}" + vars: + params: + files: + - "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml" + - "{{ ansible_distribution }}.yaml" + - "{{ ansible_os_family }}.yaml" + - "default.yaml" + paths: + - tasks + +- ansible.builtin.include_tasks: install.yaml + +- ansible.builtin.include_tasks: configure.yaml \ No newline at end of file diff --git a/roles/lego/templates/environ.conf.j2 b/roles/lego/templates/environ.conf.j2 new file mode 100644 index 0000000..c73b975 --- /dev/null +++ b/roles/lego/templates/environ.conf.j2 @@ -0,0 +1,8 @@ +# {{ ansible_managed }} + +[Service] +{% if lego_user_environ is defined %} +{% for k, v in lego_user_environ.items() %} +Environment={{ k | upper }}={{ v }} +{% endfor %} +{% endif %} \ No newline at end of file diff --git a/roles/lego/templates/lego@.service.j2 b/roles/lego/templates/lego@.service.j2 new file mode 100644 index 0000000..df994f9 --- /dev/null +++ b/roles/lego/templates/lego@.service.j2 @@ -0,0 +1,31 @@ +# {{ ansible_managed }} + +[Unit] +Description=Let's Encrypt client and ACME library written in Go +After=network-online.target +Wants=network-online.target + +[Service] +{% if lego_environ is defined %} +{% for k, v in lego_environ.items() %} +Environment={{ k | upper }}={{ v }} +{% endfor %} +{% endif %} +Type=oneshot +User={{ lego_user_name }} +ExecStart={{ lego_bin_path }} \ +{% for arg in lego_bin_args | default([]) + lego_bin_user_args | default([]) %} + {{ arg }} \ +{% endfor %} + renew \ +{% for arg in lego_bin_renew_user_args | default([]) %} + {{ arg }} {% if not loop.last %}\{{ "\n"}}{% endif %} +{% if loop.last %} + +{% endif %} +{% endfor %} + +WorkingDirectory={{ lego_var_dir_path }} + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/roles/lego/templates/lego@.timer.j2 b/roles/lego/templates/lego@.timer.j2 new file mode 100644 index 0000000..324cd7d --- /dev/null +++ b/roles/lego/templates/lego@.timer.j2 @@ -0,0 +1,11 @@ +[Unit] +Description=Certbot renewal +Description=Let's Encrypt client and ACME library written in Go +Requires={{ lego_service_name }}%i + +[Timer] +OnCalendar=*-*-* 00,12:00:00 +# RandomizedDelaySec=1 + +[Install] +WantedBy=timers.target \ No newline at end of file diff --git a/roles/lego/vars/default.yaml b/roles/lego/vars/default.yaml new file mode 100644 index 0000000..e69de29 diff --git a/roles/logcli/defaults/main.yaml b/roles/logcli/defaults/main.yaml new file mode 100644 index 0000000..3df76e7 --- /dev/null +++ b/roles/logcli/defaults/main.yaml @@ -0,0 +1,57 @@ +--- +logcli_go_arch_map: + i386: '386' + x86_64: 'amd64' + +logcli_go_arch: "{{ logcli_go_arch_map[ansible_architecture] | default('amd64') }}" + +logcli_version: 2.9.5 +logcli_checksums: + logcli-darwin-amd64.zip: sha256:b224dc8872167be0c5f07b1c22471b21604419b625b4a6e69b2c7751bc409d98 + logcli-darwin-arm64.zip: sha256:ad93156ae1132038de7a6b42633bdc59aac1a04e816aeae2796bc6dddddff14a + logcli-freebsd-amd64.zip: sha256:952f48394a080b88a100001b9c454e8793071ba4cd8cc95811bd446b4215a9a3 + logcli-linux-amd64.zip: sha256:a22f7e29bb9ef8f6f70e31926bbffc646b9e36b3265458e199c497b305d21cc2 + logcli-linux-arm.zip: sha256:0ad5c86191916121acea30d44011d84d33e5ca27497691980de16f1508b209f5 + logcli-linux-arm64.zip: sha256:06b6a6b961f5004c51eb7922509dbbb189701b1f3925ba1bb2289894fef7861e + logcli-windows-amd64.exe.zip: sha256:d1a37c56fa2a1dfa97855d2a26826ba89569d50846a6022be03936423f04e19b + loki-canary-darwin-amd64.zip: sha256:9f73e81666397e195ae092c518df32200bab71f72ff778c839abba0283f8f4b3 + loki-canary-darwin-arm64.zip: sha256:fa3a96bec9b30ec06bf5271182646161ab8056c51b07e00da14ce21d53bbd871 + loki-canary-freebsd-amd64.zip: sha256:170c0ea9bf6349cce9b9fb5be6b27d0b8477fc57e5a0849ad7c828ba3de79f15 + loki-canary-linux-amd64.zip: sha256:e4ff7cfb302851b98d4df1dc7793b3fdc7fd9680d2e75fc0484abcd08412f198 + loki-canary-linux-arm.zip: sha256:02750db39ecba743da3036ca28a3b426c7d068efeee86b875f7870ba8798dca2 + loki-canary-linux-arm64.zip: sha256:e0c0c31c89cad8ddffbd11f9467778e9b30bdfbdce955fba67871365a07ab3a1 + loki-canary-windows-amd64.exe.zip: sha256:54564cbd123fbdd1b95fe9882bd916e2e9432b53826a97c04179c48ff0314912 + loki-darwin-amd64.zip: sha256:b5831c0da363b3b075ddbdaa6e6e1323858b17c0d6c0052908aebaa637bc522c + loki-darwin-arm64.zip: sha256:1b73e4867730c252ce0e3720dd42fea5bd7921dd3cda4aa5f3764e43e1495374 + loki-freebsd-amd64.zip: sha256:c3ac9b0aa16ca494a1537c28fe036440cd701d5273c5c8bbdb47426ecb5a041e + loki-linux-amd64.zip: sha256:9d919a55e7a2dbaeab46e777a0589d7e304c71fed011f989143883cbc887e348 + loki-linux-arm.zip: sha256:104efc28b322523bf5bced67bdcc3746e1f7f872057f6ef54f25ab00ce426b39 + loki-linux-arm64.zip: sha256:491833bf201c55388b82c3d1f583a9d4426c1b778ed3dc710cd67c8cbbbb67bb + loki-windows-amd64.exe.zip: sha256:1acee64bb69bd54ff6549edd2f670d0a3802727d9efced8705c7a712412d8ef7 + promtail-darwin-amd64.zip: sha256:54032f2781d3acfef7dd7ad12b7f38ec4f5d0eb8ba047ebecb9911a6dd4b6cc6 + promtail-darwin-arm64.zip: sha256:405ed21efcaa21ae5bbe4b7e16ca888ae8238716c46a176ea9c5e2a7b2b2a633 + promtail-freebsd-amd64.zip: sha256:5a68f6fa6c7ae96919f13b4fffb188f72f9b16e38f40cf3962b97989c9739a99 + promtail-linux-amd64.zip: sha256:e444bcff2d6677d284350819d3d1b7b473a1699357689230254fbc602b28dac7 + promtail-linux-arm.zip: sha256:d0cc7552b8ce69534893040e6518288a6899c4f3acf9d4e7d32335f5f2f6145d + promtail-linux-arm64.zip: sha256:b23bd750dc5f6a76d808826ebc9d3c8b3540adb329578b650571a10d2be348b8 + promtail-windows-386.exe.zip: sha256:a121de0b043db194c65422f863211efe566da3bec338a92f0623dff6f3c435d1 + promtail-windows-amd64.exe.zip: sha256:d9c4b5bb58d3ece2e4ff78cd7fef65f5fadd7d9fe73ceb2dfa4a2990f944466f + +logcli_github_rel_path: grafana/loki +logcli_github_project_url: "https://github.com/{{ logcli_github_rel_path }}" +logcli_release_file: "logcli-{{ ansible_system | lower }}-{{ logcli_go_arch }}.zip" +logcli_release_url: "{{ logcli_github_project_url }}/releases/download/v{{ logcli_version }}/{{ logcli_release_file }}" +logcli_download_path: "/tmp/logcli-{{ logcli_version }}-{{ ansible_system | lower }}-{{ logcli_go_arch }}.zip" + +logcli_opt_path: "/opt/logcli-{{ logcli_version }}" + +logcli_unarchive_dest_path: /tmp/ +logcli_extracted_path: "/tmp/logcli-{{ ansible_system | lower }}-{{ logcli_go_arch }}" +logcli_binaries: + - logcli + +logcli_loki_addr: http://localhost:3100 + +logcli_profile_d_path: /etc/profile.d/logcli.sh +logcli_profile_d_env: + LOKI_ADDR: "{{ logcli_loki_addr }}" diff --git a/roles/logcli/tasks/configure.yaml b/roles/logcli/tasks/configure.yaml new file mode 100644 index 0000000..a623f93 --- /dev/null +++ b/roles/logcli/tasks/configure.yaml @@ -0,0 +1,11 @@ +--- +- name: set logcli environment variables + ansible.builtin.copy: + dest: "{{ logcli_profile_d_path }}" + owner: root + group: root + mode: 0755 + content: | + {% for k, v in logcli_profile_d_env.items() %} + export {{ k }}="{{ v }}" + {% endfor %} \ No newline at end of file diff --git a/roles/logcli/tasks/default.yaml b/roles/logcli/tasks/default.yaml new file mode 100644 index 0000000..e69de29 diff --git a/roles/logcli/tasks/install.yaml b/roles/logcli/tasks/install.yaml new file mode 100644 index 0000000..8c8bc62 --- /dev/null +++ b/roles/logcli/tasks/install.yaml @@ -0,0 +1,56 @@ +--- +- name: determine install status + ansible.builtin.stat: + path: "{{ logcli_opt_path }}/logcli" + register: st + +- name: create opt path + ansible.builtin.file: + path: "{{ logcli_opt_path }}" + owner: root + group: root + mode: 0755 + state: directory + +- block: + - name: download + ansible.builtin.get_url: + url: "{{ logcli_release_url }}" + dest: "{{ logcli_download_path }}" + checksum: "{{ logcli_checksums[logcli_release_file] }}" + register: dl + until: dl is success + retries: 5 + delay: 10 + + - name: extract + ansible.builtin.unarchive: + src: "{{ logcli_download_path }}" + dest: "{{ logcli_unarchive_dest_path }}" + remote_src: true + + - name: install + ansible.builtin.copy: + src: "{{ logcli_extracted_path }}" + dest: "{{ logcli_opt_path }}/{{ item }}" + remote_src: true + loop: "{{ logcli_binaries }}" + when: not st.stat.exists + +- name: permissions + ansible.builtin.file: + path: "{{ logcli_opt_path }}/{{ item }}" + owner: root + group: root + mode: 0755 + loop: "{{ logcli_binaries }}" + +- name: symlink + ansible.builtin.file: + src: "{{ logcli_opt_path }}/{{ item }}" + dest: "/usr/local/bin/{{ item }}" + owner: root + group: root + mode: 0755 + state: link + loop: "{{ logcli_binaries }}" \ No newline at end of file diff --git a/roles/logcli/tasks/main.yaml b/roles/logcli/tasks/main.yaml new file mode 100644 index 0000000..b13a010 --- /dev/null +++ b/roles/logcli/tasks/main.yaml @@ -0,0 +1,28 @@ +--- +- name: gather os specific variables + ansible.builtin.include_vars: "{{ lookup('first_found', params) }}" + vars: + params: + files: + - "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml" + - "{{ ansible_distribution }}.yaml" + - "{{ ansible_os_family }}.yaml" + - "default.yaml" + paths: + - vars + +- name: include os specific tasks + ansible.builtin.include_tasks: "{{ lookup('first_found', params) }}" + vars: + params: + files: + - "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml" + - "{{ ansible_distribution }}.yaml" + - "{{ ansible_os_family }}.yaml" + - "default.yaml" + paths: + - tasks + +- ansible.builtin.include_tasks: install.yaml + +- ansible.builtin.include_tasks: configure.yaml \ No newline at end of file diff --git a/roles/logcli/vars/default.yaml b/roles/logcli/vars/default.yaml new file mode 100644 index 0000000..e69de29 diff --git a/roles/mimir/defaults/main.yaml b/roles/mimir/defaults/main.yaml new file mode 100644 index 0000000..ba74984 --- /dev/null +++ b/roles/mimir/defaults/main.yaml @@ -0,0 +1,68 @@ +--- +mimir_package_name: mimir +mimir_package_state: present + +mimir_service_name: mimir.service +mimir_service_enabled: true +mimir_service_state: started + +mimir_apt_repository_repo: deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main +mimir_apt_repository_state: present + +mimir_version_regex: ^mimir, version ([\d.]+) + +mimir_user_name: mimir +mimir_user_comment: mimir user +mimir_user_state: present +mimir_user_shell: /usr/sbin/nologin +mimir_user_system: true +mimir_user_createhome: false + +mimir_group_name: mimir +mimir_group_state: "{{ mimir_user_state | default('present') }}" +mimir_group_system: true + +mimir_var_dir_path: /var/lib/mimir +mimir_var_dir_owner: "{{ mimir_user_name }}" +mimir_var_dir_group: "{{ mimir_group_name }}" +mimir_var_dir_mode: "0700" + +mimir_etc_dir_path: /etc/mimir +mimir_etc_dir_owner: "{{ mimir_user_name }}" +mimir_etc_dir_group: "{{ mimir_group_name }}" +mimir_etc_dir_mode: "0755" + +mimir_config_file_path: "{{ mimir_etc_dir_path }}/config.yml" +mimir_config_file_path_owner: "{{ mimir_user_name }}" +mimir_config_file_path_group: "{{ mimir_group_name }}" +mimir_config_file_path_mode: "0755" + +m# imir_common: + # {} + +mimir_server: + http_listen_port: 9009 + +mimir_alertmanager: + sharding_ring: + replication_factor: 1 + +# mimir_compactor: +# {} + +# mimir_distributor: +# {} + +mimir_ingester: + ring: + replication_factor: 1 + +mimir_store_gateway: + sharding_ring: + replication_factor: 1 + +# mimir_blocks_storage: +# {} + +# mimir_ruler_storage: +# {} \ No newline at end of file diff --git a/roles/mimir/files/grafana.gpg b/roles/mimir/files/grafana.gpg new file mode 100644 index 0000000000000000000000000000000000000000..d199581a98242764d0d6ddccf191b8655db7c2b5 GIT binary patch literal 1758 zcmajeX*d*$0><%KY{P^xmcbk`F(Szp#h4h&Ws)s&2^kto7}=$(Q`{NLP*X&9rY4ET z*!OfOkz);!Au*b48B6x%oO{o6pL@UE&+qg9^gh3AU>e_bE+qg61q{PE)oGGpDMRSd zE=s4;9LkmZ{b_^9y+Vn(I~evt=RU${IWW7OfjFzzB#fa;EjEDTSE^Xy$qG(BPU{1n z3cF)LiOc=_l@ifR?3-Mp$d^(rZ`|`G|a9aWALie4@VHG{z z$>x2Ym?yG4=ux9{!*EmAU}=$~XSxG{v0kVkVjYbQX_nNG7B0MV zJ!)`E1xv!!h)$ftuw&fXaE}JNT3br(;yIt=&5ixpLK%WD(+7xA+%V_C45oRYnKR?r zFNlf?6-_~Tm_?e}8Ji+mZ>VVcu?_l;;S{}-hNf5^*n*ki$C)MJzCs?Y{3uu*Q+3TFh2y`?g!u(fd~nL1f+x^LLwkO zX%H9)QUHQv?gE4%;{Qpk?m_`M)TOYxgJ&_O)^2Be^X#=3cjfaU+}&pkI!fOk>FnPf zGV+@82_1%yjh<1v0uPBEm7CQ_jV!t`Wm$IfG`czkAm_SJ@k=C+`+($& zoSIvAG5YEwhfij(yjRVVo{=_qb}8<})pz zacW3e^}NhK8)^3UgLx)i(sNN5EoC=kRK=L#-Y7wL&7~0%lhOEJj@4FD_?eqHt=cD9 zKQdT89;la3#@cC5aU(>~Dz7RNd#tgN+A>vR-KNKaHXFL}%S&x}IthabK+~;4 z-PV=TBVz6c>{xvXad_M`^qYWkK(Vt}L6wgj#m7=|ZZDQE_vMVl%Ll%SSZ}*a>52q9+v>@MLM~=gn z2&x4Baz53a<=@nL6<+-aurJg*xrId?;$tq_Dx3%1jnmK4a`AKXOi3+=L2aHJFZ zy%^C6wE~hTj%TuAaI{bk75^4T^+0u&V!4miOdO;04>i@DGIZ-cctpC3?fz2Md(LOA zp(k1cZW~8%)bZb{l-QK;c6j?a(b^TEZ|3YtxzT5JM*Mm2D#LctCbDCN5)eRHBs07% zG(!&U%c=k7m<(*;L;T4M{ePH2|6=yPoQ?&H>_b(LQ$urI_vSaV#s+YtB1adEF(kER zuZp;^{4$}$pF|K#ZF21gtNNI$Tp8aHL=8r%_c8WD_Uj+74|2=pCDY$w9)7WhiGP&2 z!Q9uZpw|{MS)2s@CCE+dWZj~?n2#dWRPw_(ibaw;1;4g*0LsLzI-I*V8+(#E{Zg@+ zXaL)z_1aE<(wH~R){fppDYaIInF)7FVNDuMbVae|YvVaHG6hWIg*o&Vd2pacA_ zE6Z=rnHT%h)H6KU<%GR@C^e#*IZkF@B4$={XtaoM0soFq?df8#(Fv5Sx0boxSdD_( zd1_$>qGnqy^zpafX-0JRz*pAB%Ek+j