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
130
131
132
133
134
135
136
# https://min.io/docs/minio/linux/operations/install-deploy-manage/deploy-minio-single-node-single-drive.html

- name: "Deploy MinIO: Single Node Single Drive"
  tags: minio
  hosts: mountain-of-faith
  become: true
  vars:
    minio_version: "20250907161309.0.0"
    minio_data_dir: /mnt/data
  tasks:

    - name: Assert distribution is Debian
      ansible.builtin.assert:
        that:
          - ansible_facts["distribution"] == "Debian"
        fail_msg: "This playbook only supports Debian distributions"

    # wget https://dl.min.io/server/minio/release/linux-arm64/archive/minio_20250613113347.0.0_arm64.deb -O minio.deb
    # sudo dpkg -i minio.deb
    - name: Install MinIO DEB package
      ansible.builtin.apt:
        deb: https://dl.min.io/server/minio/release/linux-arm64/archive/minio_{{ minio_version }}_arm64.deb
        state: present

    - name: Create MinIO systemd service file
      ansible.builtin.copy:
        content: |
          [Unit]
          Description=MinIO
          Documentation=https://min.io/docs/minio/linux/index.html
          Wants=network-online.target
          After=network-online.target
          AssertFileIsExecutable=/usr/local/bin/minio

          [Service]
          WorkingDirectory=/usr/local

          User=minio
          Group=minio
          ProtectProc=invisible

          EnvironmentFile=-/etc/default/minio
          ExecStartPre=/bin/bash -c "if [ -z \"${MINIO_VOLUMES}\" ]; then echo \"Variable MINIO_VOLUMES not set in /etc/default/minio\"; exit 1; fi"
          ExecStart=/usr/local/bin/minio server $MINIO_OPTS $MINIO_VOLUMES

          # MinIO RELEASE.2023-05-04T21-44-30Z adds support for Type=notify (https://www.freedesktop.org/software/systemd/man/systemd.service.html#Type=)
          # This may improve systemctl setups where other services use `After=minio.server`
          # Uncomment the line to enable the functionality
          # Type=notify

          # Let systemd restart this service always
          Restart=always

          # Specifies the maximum file descriptor number that can be opened by this process
          LimitNOFILE=65536

          # Specifies the maximum number of threads this process can create
          TasksMax=infinity

          # Disable timeout logic and wait until process is stopped
          TimeoutStopSec=infinity
          SendSIGKILL=no

          [Install]
          WantedBy=multi-user.target

          # Built for ${project.name}-${project.version} (${project.name})
        dest: /usr/lib/systemd/system/minio.service
        owner: root
        group: root
        mode: "0644"
      notify: restart minio

    # groupadd -r minio-user
    - name: Create MinIO group
      ansible.builtin.group:
        name: minio
        system: true
        state: present

    # useradd -M -r -g minio-user minio-user
    - name: Create MinIO user
      ansible.builtin.user:
        name: minio
        group: minio
        system: true
        shell: /sbin/nologin

    # chown minio-user:minio-user /mnt/data
    - name: Create MinIO data directory
      ansible.builtin.file:
        path: /mnt/mountain-of-faith/minio
        state: directory
        owner: minio
        group: minio
        mode: "0755"

    - name: Create MinIO environment file
      ansible.builtin.copy:
        content: |
          # 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=root
          MINIO_ROOT_PASSWORD="{{ minio.password }}"

          # MINIO_VOLUMES sets the storage volume or path to use for the MinIO server.

          MINIO_VOLUMES="/mnt/mountain-of-faith/minio"

          # MINIO_OPTS sets any additional commandline options to pass to the MinIO server.
          # For example, `--console-address :9001` sets the MinIO Console listen port
          MINIO_OPTS="--console-address :9001"
        dest: /etc/default/minio
        owner: root
        group: root
        mode: "0644"
      notify: restart minio

    - name: Enable and start MinIO service
      ansible.builtin.systemd:
        name: minio
        enabled: true
        state: started
        daemon_reload: true

  handlers:
    - name: restart minio
      ansible.builtin.systemd:
        name: minio
        state: restarted
        daemon_reload: true

# vim: ft=yaml.ansible