-
Notifications
You must be signed in to change notification settings - Fork 0
/
swarm_prepare.yml
129 lines (108 loc) · 3.43 KB
/
swarm_prepare.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
---
- name: Swarm prepare
hosts: all
gather_facts: yes
become: yes
vars:
folder_path: /home/robo/docker-volumes
fstab_path: /etc/fstab
cifs_detail: "//Unord-fil.efif.dk/HomeM-Z/R/robo/volumes/ /home/robo/docker-volumes cifs username={{ ansible_user }},password={{ ansible_sudo_pass }},iocharset=utf8,rw,uid=1000,sec=ntlmssp,vers=3.0 0 0"
tasks:
- name: Patch the server
tags: Patch
become: yes
shell: "dnf upgrade -y"
register: patchresult
- name: Ensure /home/robo/docker-volumes directory exists
ansible.builtin.file:
path: "{{ folder_path }}"
state: directory
- name: Install cifs-utils
ansible.builtin.dnf:
name: cifs-utils
state: latest
- name: Ensure fstab contains the CIFS mount //Unord-fil.efif.dk/HomeM-Z/R/robo/volumes/
ansible.builtin.mount:
path: "{{ folder_path }}"
src: "//Unord-fil.efif.dk/HomeM-Z/R/robo/volumes/"
fstype: cifs
opts: "username={{ ansible_user }},password={{ ansible_sudo_pass }},iocharset=utf8,rw,uid=1000,sec=ntlmssp,vers=3.0"
state: present
- name: Install fastfetch packages
dnf:
name:
- fastfetch
state: present
- name: Uninstall Docker
dnf:
name:
- docker-ce
- docker-ce-cli
- containerd.io
state: absent
- name: Install dnf-plugins-core
dnf:
name: dnf-plugins-core
state: present
- name: Add Docker repo
command: dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
args:
warn: no
register: docker_repo_result
changed_when: "'Repository successfully added' in docker_repo_result.stdout"
- name: Install Docker packages
dnf:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
state: present
- name: Enable and start Docker service
systemd:
name: docker
enabled: yes
state: started
- name: Ensure docker group exists
group:
name: docker
state: present
- name: Add user to docker group
user:
name: "{{ ansible_user }}"
groups: docker
append: yes
- name: Download Node Exporter
get_url:
url: https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz
dest: /tmp/node_exporter.tar.gz
- name: Extract Node Exporter
unarchive:
src: /tmp/node_exporter.tar.gz
dest: /usr/local/bin/
remote_src: yes
creates: /usr/local/bin/node_exporter-1.3.1.linux-amd64
- name: Move Node Exporter binary
command: mv /usr/local/bin/node_exporter-1.3.1.linux-amd64/node_exporter /usr/local/bin/node_exporter
args:
creates: /usr/local/bin/node_exporter
- name: Create systemd service
copy:
dest: /etc/systemd/system/node_exporter.service
content: |
[Unit]
Description=Node Exporter
After=network.target
[Service]
User=nobody
ExecStart=/usr/local/bin/node_exporter
[Install]
WantedBy=default.target
- name: Enable and start Node Exporter
systemd:
name: node_exporter
enabled: yes
state: started
- name: Reboot the servers
reboot: