mirror of
https://github.com/batonogov/learn-devops.git
synced 2025-11-29 08:43:01 +00:00
Add MinIO cluster (#15)
Co-authored-by: Fedor Batonogov <f.batonogov@yandex.ru>
This commit is contained in:
committed by
GitHub
parent
a45b92d625
commit
55deb994c6
13
ansible/roles/minio_start/handlers/main.yml
Normal file
13
ansible/roles/minio_start/handlers/main.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
- name: Загружаю образ
|
||||
community.docker.docker_image:
|
||||
name: "quay.io/minio/minio"
|
||||
tag: "{{ minio_version }}"
|
||||
source: pull
|
||||
|
||||
- name: Перезапускаю minio.service
|
||||
ansible.builtin.systemd:
|
||||
name: minio.service
|
||||
state: restarted
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
8
ansible/roles/minio_start/tasks/add_dirs.yml
Normal file
8
ansible/roles/minio_start/tasks/add_dirs.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: Create a directory if it does not exist
|
||||
ansible.builtin.file:
|
||||
path: /var/lib/minio
|
||||
state: directory
|
||||
owner: "{{ minio_username }}"
|
||||
group: "{{ minio_username }}"
|
||||
mode: "755"
|
||||
8
ansible/roles/minio_start/tasks/add_user.yml
Normal file
8
ansible/roles/minio_start/tasks/add_user.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: Создаю пользователя
|
||||
ansible.builtin.user:
|
||||
name: "{{ minio_username }}"
|
||||
shell: /sbin/nologin
|
||||
create_home: true
|
||||
groups: docker
|
||||
uid: "{{ minio_uid }}"
|
||||
10
ansible/roles/minio_start/tasks/main.yml
Normal file
10
ansible/roles/minio_start/tasks/main.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
# tasks file for minio_start
|
||||
- name: Создаю пользователя
|
||||
ansible.builtin.import_tasks: add_user.yml
|
||||
|
||||
- name: Создаю директории
|
||||
ansible.builtin.import_tasks: add_dirs.yml
|
||||
|
||||
- name: Запускаю minio
|
||||
ansible.builtin.import_tasks: start_minio.yml
|
||||
34
ansible/roles/minio_start/tasks/start_minio.yml
Normal file
34
ansible/roles/minio_start/tasks/start_minio.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
- name: Наливаю переменные
|
||||
ansible.builtin.template:
|
||||
src: minio.config.j2
|
||||
dest: /etc/default/minio
|
||||
owner: "{{ minio_username }}"
|
||||
group: "{{ minio_username }}"
|
||||
mode: "644"
|
||||
notify:
|
||||
- Перезапускаю minio.service
|
||||
|
||||
- name: Наливаю юнит файл
|
||||
ansible.builtin.template:
|
||||
src: minio.service.j2
|
||||
dest: /etc/systemd/system/minio.service
|
||||
mode: "644"
|
||||
notify:
|
||||
- Загружаю образ
|
||||
- Перезапускаю minio.service
|
||||
|
||||
- name: Create a directory if it does not exist
|
||||
ansible.builtin.file:
|
||||
path: '{{ item["path"] }}/minio'
|
||||
state: directory
|
||||
owner: "{{ minio_username }}"
|
||||
group: "{{ minio_username }}"
|
||||
mode: "755"
|
||||
loop: "{{ device }}"
|
||||
|
||||
- name: Настраиваю minio.service
|
||||
ansible.builtin.systemd:
|
||||
name: minio.service
|
||||
state: started
|
||||
enabled: true
|
||||
21
ansible/roles/minio_start/templates/minio.config.j2
Normal file
21
ansible/roles/minio_start/templates/minio.config.j2
Normal file
@@ -0,0 +1,21 @@
|
||||
# MINIO_ROOT_USER and MINIO_ROOT_PASSWORD sets the root account for the MinIO server.
|
||||
# This user has unrestricted permissions to perform S3 and administrative API operations on any resource in the deployment.
|
||||
# Omit to use the default values 'minioadmin:minioadmin'.
|
||||
# MinIO recommends setting non-default values as a best practice, regardless of environment.
|
||||
|
||||
MINIO_ROOT_USER=admin
|
||||
MINIO_ROOT_PASSWORD={{ lookup('password', 'secrets/minio/admin_secret length=64') }}
|
||||
|
||||
# MINIO_VOLUMES sets the storage volumes or paths to use for the MinIO server.
|
||||
# The specified path uses MinIO expansion notation to denote a sequential series of drives between 1 and 4, inclusive.
|
||||
# All drives or paths included in the expanded drive list must exist *and* be empty or freshly formatted for MinIO to start successfully.
|
||||
|
||||
MINIO_VOLUMES="http://minio-node{1...4}:9000/mnt/disk1/minio"
|
||||
|
||||
# MINIO_SERVER_URL sets the hostname of the local machine for use with the MinIO Server.
|
||||
# MinIO assumes your network control plane can correctly resolve this hostname to the local machine.
|
||||
|
||||
# Uncomment the following line and replace the value with the correct hostname for the local machine.
|
||||
|
||||
MINIO_SERVER_URL="http://10.0.75.90"
|
||||
MINIO_BROWSER_REDIRECT_URL="https://s3.example.local/minio/ui"
|
||||
29
ansible/roles/minio_start/templates/minio.service.j2
Normal file
29
ansible/roles/minio_start/templates/minio.service.j2
Normal file
@@ -0,0 +1,29 @@
|
||||
[Unit]
|
||||
Description=minio
|
||||
Requires=docker.service
|
||||
After=docker.service
|
||||
|
||||
[Service]
|
||||
User={{ minio_username }}
|
||||
Group={{ minio_username }}
|
||||
Restart=always
|
||||
ExecStartPre=-/usr/bin/docker rm -f minio
|
||||
ExecStart=/usr/bin/docker run \
|
||||
--rm \
|
||||
--network host \
|
||||
--user {{ minio_uid }}:{{ minio_uid }} \
|
||||
--name minio \
|
||||
--env "MINIO_CONFIG_ENV_FILE=/etc/config.env" \
|
||||
--add-host "minio-node1:10.0.75.55" \
|
||||
--add-host "minio-node2:10.0.75.56" \
|
||||
--add-host "minio-node3:10.0.75.57" \
|
||||
--add-host "minio-node4:10.0.75.58" \
|
||||
--volume /etc/default/minio:/etc/config.env:ro \
|
||||
--volume /var/lib/minio:/var/lib/minio \
|
||||
--volume /mnt/disk1/minio:/mnt/disk1/minio \
|
||||
quay.io/minio/minio:{{ minio_version }} \
|
||||
server /var/lib/minio --console-address ":9001"
|
||||
ExecStop=/usr/bin/docker stop -t 10 minio
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
5
ansible/roles/minio_start/vars/main.yml
Normal file
5
ansible/roles/minio_start/vars/main.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
# vars file for minio_start
|
||||
# Мы качаем docker image отсюда: https://quay.io/minio/minio/
|
||||
minio_version: RELEASE.2024-07-16T23-46-41Z
|
||||
minio_uid: 1111
|
||||
Reference in New Issue
Block a user