blob: 3078b688df78bf286b258764b717f956914b0965 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
---
- name: Install prerequisites
ansible.builtin.apt:
name:
- ca-certificates
- curl
- gnupg
state: present
update_cache: yes
- name: Create apt keyrings dir
ansible.builtin.file:
path: /etc/apt/keyrings
state: directory
mode: '0755'
- name: Add Docker GPG key
ansible.builtin.get_url:
url: https://download.docker.com/linux/debian/gpg
dest: /etc/apt/keyrings/docker.asc
mode: '0644'
- name: Get system arch
ansible.builtin.command: dpkg --print-architecture
register: dpkg_arch
changed_when: false
- name: Add Docker repo
ansible.builtin.apt_repository:
repo: "deb [arch={{ dpkg_arch.stdout }} signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable"
state: present
filename: docker
- name: Install Docker
ansible.builtin.apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-compose-plugin
state: present
update_cache: yes
- name: Start Docker service
ansible.builtin.systemd:
name: docker
state: started
enabled: yes
- name: Create PLG dir
ansible.builtin.file:
path: "{{ plg_install_dir }}"
state: directory
mode: '0755'
- name: Copy PLG configs
ansible.builtin.copy:
src: "{{ item }}"
dest: "{{ plg_install_dir }}/{{ item }}"
mode: '0644'
loop:
- loki-config.yaml
- promtail-config.yml
- name: Template docker-compose
ansible.builtin.template:
src: docker-compose.yml.j2
dest: "{{ plg_install_dir }}/docker-compose.yml"
mode: '0644'
- name: Start PLG containers
ansible.builtin.command: docker compose up -d
args:
chdir: "{{ plg_install_dir }}"
register: compose_output
changed_when: "'Started' in compose_output.stdout or 'Created' in compose_output.stdout"
|