105 lines
2.8 KiB
YAML
105 lines
2.8 KiB
YAML
---
|
|
- name: Ensure unzip package is available
|
|
package:
|
|
name: unzip
|
|
state: present
|
|
update_cache: "{{ promtail_apt_update_cache }}"
|
|
|
|
- name: Create promtail group
|
|
group:
|
|
name: "{{ promtail_system_group }}"
|
|
state: present
|
|
system: True
|
|
when: promtail_system_group != "root"
|
|
|
|
- name: Create the promtail user
|
|
user:
|
|
name: "{{ promtail_system_user }}"
|
|
group: "{{ promtail_system_group }}"
|
|
groups: "{{ promtail_user_additional_groups }}"
|
|
append: True
|
|
shell: /usr/sbin/nologin
|
|
system: True
|
|
createhome: False
|
|
home: /
|
|
when: promtail_system_user != "root"
|
|
|
|
- name: Ensure /usr/local/bin exists
|
|
file:
|
|
path: /usr/local/bin
|
|
state: directory
|
|
mode: 0755
|
|
|
|
- name: Create config directories
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
owner: root
|
|
group: "{{ promtail_system_group }}"
|
|
mode: 0770
|
|
loop:
|
|
- "{{ promtail_config_dir }}"
|
|
- "{{ promtail_config_file_sd_dir }}"
|
|
- "{{ promtail_positions_directory }}"
|
|
|
|
- name: Create application dirs
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
owner: "{{ promtail_system_user }}"
|
|
group: "{{ promtail_system_group }}"
|
|
mode: 0755
|
|
with_items:
|
|
- "{{ promtail_install_dir }}"
|
|
- "{{ promtail_install_dir }}/{{ promtail_version }}"
|
|
|
|
- name: Check promtail binary
|
|
stat:
|
|
path: "{{ promtail_install_dir }}/{{ promtail_version }}/promtail-linux-{{ go_arch }}"
|
|
register: promtail_binary
|
|
|
|
- name: Download promtail binaries
|
|
get_url:
|
|
url: "{{ promtail_dist_url }}"
|
|
dest: "{{ promtail_tmp_dir }}/{{ promtail_version }}_promtail-linux-{{ go_arch }}.zip"
|
|
force: True
|
|
checksum: "{{ promtail_custom_checksum if promtail_custom_checksum else 'sha256:' + __promtail_checksum }}"
|
|
when: not promtail_binary.stat.exists
|
|
|
|
- name: Unpack promtail binaries
|
|
ignore_errors: "{{ ansible_check_mode }}"
|
|
unarchive:
|
|
src: "{{ promtail_tmp_dir }}/{{ promtail_version }}_promtail-linux-{{ go_arch }}.zip"
|
|
dest: "{{ promtail_install_dir }}/{{ promtail_version }}"
|
|
creates: "{{ promtail_install_dir }}/{{ promtail_version }}/promtail-linux-{{ go_arch }}"
|
|
mode: 0755
|
|
remote_src: True
|
|
|
|
- name: Create symlink to latest version
|
|
notify:
|
|
- Restart promtail
|
|
ignore_errors: "{{ ansible_check_mode }}"
|
|
file:
|
|
state: link
|
|
src: "{{ promtail_install_dir }}/{{ promtail_version }}/promtail-linux-{{ go_arch }}"
|
|
dest: /usr/local/bin/promtail
|
|
mode: 0755
|
|
|
|
- name: Write config
|
|
notify:
|
|
- Restart promtail
|
|
template:
|
|
src: config.j2
|
|
dest: "{{ promtail_config_file }}"
|
|
owner: root
|
|
group: "{{ promtail_system_group }}"
|
|
mode: 0644
|
|
|
|
- name: Create systemd service unit
|
|
notify:
|
|
- Restart promtail
|
|
template:
|
|
src: "{{ promtail_systemd_service_template_file }}"
|
|
dest: "/etc/systemd/system/{{ promtail_systemd_service }}.service"
|
|
mode: 0644
|