-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovision.yml
113 lines (93 loc) · 2.77 KB
/
provision.yml
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
- name: Docker pre-configuring
hosts: nodes
become: true
become_user: root
tasks:
- name: Create directory for ssh-keys
ansible.builtin.file:
state: directory
mode: 0700
dest: /root/.ssh/
- name: Adding rsa-key in /root/.ssh/authorized_keys
ansible.builtin.copy:
src: ~/.ssh/id_rsa.pub
dest: /root/.ssh/authorized_keys
owner: root
mode: 0600
ignore_errors: true
- name: Checking DNS
ansible.builtin.command: host -t A google.com
- name: Add Docker GPG apt Key
ansible.builtin.apt_key:
url: https://download.docker.com/linux/debian/gpg
state: present
- name: Installing tools
ansible.builtin.apt:
pkg:
- git
- curl
state: present
update_cache: true
- name: Add Docker Repository
ansible.builtin.apt_repository:
repo: 'deb https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable'
validate_certs: true
state: present
- name: Update apt and install docker-ce
ansible.builtin.apt:
pkg:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
state: latest
update_cache: true
- name: Install Docker Module for Python
ansible.builtin.pip:
name: docker
- name: Enable docker daemon
ansible.builtin.systemd:
name: docker
state: started
enabled: true
- name: adding existing user '{{ ansible_user }}' to group docker
ansible.builtin.user:
name: '{{ ansible_user }}'
groups: docker
append: yes
- name: Configure Manager stack
hosts: manager
become: true
become_user: root
tasks:
- name: Synchronization
ansible.builtin.copy:
src: stack/
dest: "/opt/stack/"
owner: root
group: root
mode: 0644
become: true
- name: Pull all images in compose
ansible.builtin.command: docker compose -f /opt/stack/docker-compose.yaml pull
- name: Up all services in compose
ansible.builtin.command: docker compose -f /opt/stack/docker-compose.yaml up -d
- name: Configure targets to observe
hosts: targets
become: true
become_user: root
tasks:
- name: Synchronization
ansible.builtin.copy:
src: stack/exporters/
dest: "/opt/exporters/"
owner: root
group: root
mode: 0644
become: true
- name: Pull all images in compose
ansible.builtin.command: docker compose -f /opt/exporters/docker-compose.exporters.yaml pull
- name: Up all services in compose
ansible.builtin.command: docker compose -f /opt/exporters/docker-compose.exporters.yaml up -d