Skip to content

Standlone #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
8 changes: 8 additions & 0 deletions ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[defaults]
#roles_path = ./redis_role
inventory = /home/sahil/minio_ansible/minio_role/aws_ec2.yml
host_key_checking = False
remote_user = ubuntu
private_key_file = /home/sahil/Downloads/minio.pem
#[inventory]
#enable_plugins = aws_ec2
11 changes: 11 additions & 0 deletions aws_ec2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
plugin: aws_ec2
regions:
- ap-northeast-2

filters:
tag:Name: minio

ansible_user: "ubuntu"
host_key_checking: False
ansible_ssh_private_key_file: /home/sahil/downloads/minio.pem
38 changes: 38 additions & 0 deletions minio_role/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Role Name
=========

A brief description of the role goes here.

Requirements
------------

Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.

Role Variables
--------------

A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.

Dependencies
------------

A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.

Example Playbook
----------------

Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:

- hosts: servers
roles:
- { role: username.rolename, x: 42 }

License
-------

BSD

Author Information
------------------

An optional section for the role authors to include contact information, or a website (HTML is not allowed).
10 changes: 10 additions & 0 deletions minio_role/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
# defaults file for minio_role
minio_version: "RELEASE.2024-08-01T00-00-00Z"
minio_port: 9000
minio_data_dir: /data/minio
minio_config_dir: /etc/minio
minio_user: minio
minio_group: minio
minio_access_key: "minio1234567890"
minio_secret_key: "1234567890minio"
14 changes: 14 additions & 0 deletions minio_role/files/minio.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=MinIO
Documentation=https://docs.min.io
After=network.target

[Service]
User=minio
Group=minio
ExecStart=/usr/local/bin/minio server /data --config-dir /etc/minio
Restart=on-failure
EnvironmentFile=-/etc/default/minio

[Install]
WantedBy=multi-user.target
19 changes: 19 additions & 0 deletions minio_role/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
# handlers file for minio_role

- name: Restart MinIO
systemd:
name: "{{ handlers.restart_minio.name }}"
state: "{{ handlers.restart_minio.state }}"

- name: Reload systemd
command: "{{ handlers.reload_systemd.command }}"
become: "{{ handlers.reload_systemd.become }}"
async: "{{ handlers.reload_systemd.async }}"
poll: "{{ handlers.reload_systemd.poll }}"
register: result

- name: Debug systemd reload result
debug:
var: "{{ handlers.debug_systemd_result.debug_var }}"
become: "{{ handlers.debug_systemd_result.become }}"
10 changes: 10 additions & 0 deletions minio_role/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
# meta file for minio_role

dependencies: []

galaxy_info:
author: "{{ author }}"
description: "{{ description }}"
company: "{{ company }}"
license: "{{ license }}"
91 changes: 91 additions & 0 deletions minio_role/tasks/configure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
- name: Ensure minio group exists
group:
name: "{{ minio_group_name }}"
state: present
retries: 5
delay: 5
until: result is success
register: result
become: yes

- name: Ensure minio user exists
user:
name: "{{ minio_user_name }}"
group: "{{ minio_group_name }}"
create_home: yes
shell: "{{ minio_user_shell }}"
state: present
become: yes

- name: Create MinIO configuration directory
file:
path: "{{ minio_config_dir }}"
state: directory
mode: "{{ directory_mode }}"
owner: "{{ minio_user_name }}"
group: "{{ minio_group_name }}"
become: yes

- name: Create MinIO group
group:
name: "{{ minio_group_name }}"
state: present
become: yes
when: ansible_os_family in ['RedHat', 'Debian', 'CentOS']


- name: Create MinIO user
user:
name: "{{ minio_user_name }}"
group: "{{ minio_group_name }}"
system: "{{ minio_user_system }}"
shell: "{{ minio_user_shell }}"
become: yes

- name: Set ownership of MinIO binary
file:
path: "{{ minio_binary_path }}"
owner: "{{ minio_user_name }}"
group: "{{ minio_group_name }}"
mode: "{{ directory_mode }}"
become: yes

- name: Set ownership of MinIO data directory
file:
path: "{{ minio_data_dir }}"
owner: "{{ minio_user_name }}"
group: "{{ minio_group_name }}"
recurse: yes
become: yes

- name: Set ownership of MinIO config directory
file:
path: "{{ minio_config_dir }}"
owner: "{{ minio_user_name }}"
group: "{{ minio_group_name }}"
recurse: yes
become: yes

- name: Copy MinIO service file
copy:
src: "{{ minio_service_src }}"
dest: "{{ minio_service_dest }}"
mode: "{{ file_mode }}"
become: yes

- name: Ensure MinIO data directories exist
file:
path: "{{ item }}"
state: directory
owner: minio
group: minio
mode: '0755'
loop: "{{ minio_data_dirs[deployment_type] }}"
when: deployment_type in ['single-node-single-drive', 'single-node-multi-drive', 'multi-node-multi-drive']


- name: Start MinIO server with the chosen deployment type
include_tasks: "{{ deployment_type }}.yml"
when: deployment_type in ['single-node-single-drive', 'single-node-multi-drive', 'multi-node-multi-drive']

85 changes: 85 additions & 0 deletions minio_role/tasks/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---

- name: Install required packages on RedHat-based systems
yum:
name:
- wget
- unzip
state: present
when: ansible_os_family == "RedHat"

- name: Install required packages on Debian-based systems
apt:
name:
- wget
- unzip
state: present
update_cache: yes
when: ansible_os_family == "Debian"
become: yes

- name: Install required packages on CentOS
yum:
name:
- wget
- unzip
state: present
when: ansible_distribution == "CentOS"
become: yes

- name: Download MinIO binary
get_url:
url: "https://dl.min.io/server/minio/release/linux-amd64/minio"
dest: "/usr/local/bin/minio"
mode: '0755'

- name: Create MinIO service file on RedHat-based systems
template:
src: "minio.service.j2"
dest: "/etc/systemd/system/minio.service"
when: ansible_os_family == "RedHat"

- name: Create MinIO service file on Debian-based systems
template:
src: "minio.service.j2"
dest: "/etc/systemd/system/minio.service"
when: ansible_os_family == "Debian"

- name: Create MinIO service file on CentOS
template:
src: "minio.service.j2"
dest: "/etc/systemd/system/minio.service"
when: ansible_distribution == "CentOS"

- name: Update apt package list
ansible.builtin.apt:
update_cache: "{{ update_cache }}"
become: yes

- name: Download MinIO binary
get_url:
url: "{{ minio_download_url }}"
dest: "{{ minio_deb_path }}"
mode: "{{ deb_file_mode }}"
become: yes

- name: Install MinIO binary
apt:
deb: "{{ minio_deb_path }}"
become: yes

- name: Ensure MinIO binary has execute permissions
file:
path: "{{ minio_deb_path }}"
mode: '0755'
owner: minio
group: minio
become: yes








8 changes: 8 additions & 0 deletions minio_role/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- name: Install MinIO
include_tasks: "install.yml"

- name: Configure MinIO
include_tasks: "configure.yml"


8 changes: 8 additions & 0 deletions minio_role/tasks/multi-node-multi-drive.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- name: Start MinIO server with multiple drives
command: "minio server {{ minio_data_dirs[deployment_type]|join(' ') }} --config-dir /etc/minio"
environment:
MINIO_ACCESS_KEY: "{{ minio_access_key }}"
MINIO_SECRET_KEY: "{{ minio_secret_key }}"
become: yes
become_user: minio_user
10 changes: 10 additions & 0 deletions minio_role/tasks/single-node-multi-drive.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Start MinIO server with multiple drives
command: "minio server /data/minio1 /data/minio2 /data/minio3 /data/minio4 --config-dir /etc/minio"
environment:
MINIO_ACCESS_KEY: "{{ minio_access_key }}"
MINIO_SECRET_KEY: "{{ minio_secret_key }}"
state: started
enabled: yes
become: yes

8 changes: 8 additions & 0 deletions minio_role/tasks/single-node-single-drive.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- name: Start MinIO server with single drive
command: "minio server /data/minio1 "
environment:
MINIO_ACCESS_KEY: "{{ minio_access_key }}"
MINIO_SECRET_KEY: "{{ minio_secret_key }}"
become: yes

3 changes: 3 additions & 0 deletions minio_role/templates/minio.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# minio.conf.j2
MINIO_ACCESS_KEY={{ minio_access_key }}
MINIO_SECRET_KEY={{ minio_secret_key }}
Loading