diff --git a/README.md b/README.md index 097ee81..d6e825f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1 @@ -ToDo: - - evaluate alternantives [garage] \ No newline at end of file +# minio diff --git a/compose.yml b/compose.yml deleted file mode 100644 index 836e978..0000000 --- a/compose.yml +++ /dev/null @@ -1,35 +0,0 @@ -services: - minio: - image: quay.io/minio/minio:RELEASE.2025-09-07T16-13-09Z - command: server /data - networks: - - proxy - environment: - MINIO_ROOT_USER: "${MINIO_USER}" - MINIO_ROOT_PASSWORD: "${MINIO_PASSWORD}" - healthcheck: - test: ["CMD", "mc", "ready", "local"] - interval: 5s - timeout: 5s - retries: 5 - volumes: - - data:/data - labels: - traefik.enable: true - traefik.http.routers.minio.rule: "Host(`s3.urmel.de`)" - traefik.http.routers.minio.tls: true - traefik.http.routers.minio.tls.certResolver: hetzner - traefik.http.services.minio-https.loadbalancer.server.port: 9000 - - -volumes: - data: - driver_opts: - type: nfs4 - o: addr=217.100.0.2,rw,noatime,tcp - device: ":/mnt/Main/servicesData/s3" - -networks: - proxy: - name: traefik_exposed - external: true \ No newline at end of file diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..dca93d8 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,15 @@ +path: /srv/{{ role_name }} + +minio_override: {} +minio_defaults: + version: "latest" + url: "" + admin_url: "" + user: "" + password: "" + data_path: "" + networkmount: + host: "" + host_path: "" + args: "" + type: "" diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..75bf64b --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,8 @@ +- name: restart container + community.docker.docker_compose_v2: + project_src: "{{ path }}" + project_name: "{{ role_name }}" + recreate: "always" + services: ["minio"] + state: "restarted" + when: not _minio_already_restarted diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..e3392c3 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,20 @@ +--- +galaxy_info: + author: "Niklas Freese " + description: minio + company: "Urmel Services" + license: AGPL-3.0-or-later + min_ansible_version: 2.1 + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: + - role: traefik diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..d129369 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,32 @@ +--- +- name: "set local variables from overrides and defaults" + set_fact: + minio: "{{ (minio_defaults | combine(minio_override, recursive=True)) if minio_override else minio_defaults }}" + +- name: ensure that path exists + file: + path: "{{ path }}/config/minio" + state: directory + +- name: template docker compose + template: + src: compose.yml.j2 + dest: "{{ path }}/compose.yml" + +- import_role: + name: storage_mount + vars: + storage_mount_override: + host: "{{ minio.networkmount.host }}" + host_path: "{{ minio.networkmount.host_path }}" + type: "{{ minio.networkmount.type }}" + args: "{{ minio.networkmount.args }}" + dest_path: "{{ minio.data_path }}" + when: minio.networkmount.host | length > 1 + +- name: ensure everything is up + community.docker.docker_compose_v2: + project_src: "{{ path }}" + project_name: "{{ role_name }}" + recreate: always + state: "present" diff --git a/templates/compose.yml.j2 b/templates/compose.yml.j2 new file mode 100644 index 0000000..4d22f72 --- /dev/null +++ b/templates/compose.yml.j2 @@ -0,0 +1,51 @@ +services: + rustfs_perms: + image: alpine + user: root + volumes: + - "{{ minio.data_path }}:/fix_path" + command: chown -R 10001:10001 /fix_path + + rustfs: + image: "rustfs/rustfs:{{ minio.version }}" + networks: + - proxy + environment: + RUSTFS_VOLUMES: /data + RUSTFS_ADDRESS: 0.0.0.0:9000 + RUSTFS_CONSOLE_ENABLE: true + RUSTFS_CONSOLE_ADDRESS: 0.0.0.0:9001 + RUSTFS_ACCESS_KEY: "{{ minio.user }}" + RUSTFS_SECRET_KEY: "{{ minio.password }}" + volumes: + - "{{ minio.data_path }}:/data" + + depends_on: + rustfs_perms: + condition: service_completed_successfully + + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:9000/health"] + interval: 1m30s + timeout: 10s + retries: 3 + start_period: 20s + + labels: + traefik.enable: true + traefik.http.routers.rustfs.rule: "Host(`{{ minio.url }}`)" + traefik.http.routers.rustfs.tls: true + traefik.http.routers.rustfs.tls.certResolver: hetzner + traefik.http.routers.rustfs.service: rustfs-https + traefik.http.services.rustfs-https.loadbalancer.server.port: 9000 + + traefik.http.routers.rustfs-admin.rule: "Host(`{{ minio.admin_url }}`)" + traefik.http.routers.rustfs-admin.tls: true + traefik.http.routers.rustfs-admin.tls.certResolver: hetzner + traefik.http.routers.rustfs-admin.service: rustfs-admin-https + traefik.http.services.rustfs-admin-https.loadbalancer.server.port: 9001 + +networks: + proxy: + name: traefik_exposed + external: true