Skip to content
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

Add option to create minio clusters #19

Merged
merged 3 commits into from
Jun 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,27 @@ minio_server_make_datadirs: true

Create directories from `minio_server_datadirs`

```yaml
minio_server_cluster_nodes: [ ]
```

Set a list of nodes to create a [distributed cluster](https://docs.minio.io/docs/distributed-minio-quickstart-guide).

In this mode, ansible will create your server datadirs, but use this list for the server startup. Note you will need a number of disks to satisfy Minio's distributed storage requirements.

Example:

```yaml
minio_server_datadirs:
- '/minio-data'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs at least 4 directories, not 1.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need 4 storage targets over the whole cluster, not per server.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right.

- ...
minio_server_cluster_nodes:
- 'https://server1/minio-data'
- 'https://server2/minio-data'
- 'https://server3/minio-data'
- ...
```

```yaml
minio_server_opts: ""
```
Expand Down
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ minio_server_addr: ":9091"
minio_server_datadirs: [ ]
minio_server_make_datadirs: true

# Minio server cluster node list.
minio_server_cluster_nodes: [ ]

# Additional minio server CLI options
minio_server_opts: ""

Expand Down
51 changes: 51 additions & 0 deletions molecule/cluster/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
driver:
name: docker
lint:
name: yamllint

platforms:
- name: minio-centos-7
image: paulfantom/centos-molecule:7
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- name: minio-fedora-27
image: paulfantom/fedora-molecule:27
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- name: minio-debian-9
image: paulfantom/debian-molecule:9
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- name: minio-ubuntu-18.04
image: paulfantom/ubuntu-molecule:18.04
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- name: minio-ubuntu-16.04
image: paulfantom/ubuntu-molecule:16.04
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro


provisioner:
name: ansible
lint:
name: ansible-lint
playbooks:
create: ../default/create.yml
prepare: ../default/prepare.yml
converge: playbook.yml
destroy: ../default/destroy.yml

scenario:
name: cluster
verifier:
name: testinfra
lint:
name: flake8
enabled: true
17 changes: 17 additions & 0 deletions molecule/cluster/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---

- hosts: all
any_errors_fatal: true
roles:
- ansible-minio
vars:
minio_server_datadirs:
- "/test1"
- "/test2"
- "/test3"
- "/test4"
minio_server_cluster_nodes:
- "http://{{ ansible_hostname }}:9091/test1"
- "http://{{ ansible_hostname }}:9091/test2"
- "http://{{ ansible_hostname }}:9091/test3"
- "http://{{ ansible_hostname }}:9091/test4"
38 changes: 38 additions & 0 deletions molecule/cluster/tests/test_minio_cluster.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import yaml
import pytest
import testinfra.utils.ansible_runner

testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
'.molecule/ansible_inventory').get_hosts('all')


@pytest.fixture()
def AnsibleDefaults(Ansible):
with open("./defaults/main.yml", 'r') as stream:
return yaml.load(stream)


@pytest.mark.parametrize("dirs", [
"/minio-test"
])
def test_directories(host, dirs):
d = host.file(dirs)
assert d.is_directory
assert d.exists
assert d.user == AnsibleDefaults['minio_user']
assert d.group == AnsibleDefaults['minio_group']
assert oct(d.mode) == '0750'


def test_env_file(host):
env_file = host.file("/etc/default/minio")
a = host.ansible.get_variables()
host = a['ansible_hostname']
volume_string = "MINIO_VOLUMES=\"http://%s:9091/test1 " % (host)
assert env_file.contains(volume_string)


def test_minio_service(Service):
s = Service('minio')
assert s.is_running
assert s.is_enabled
4 changes: 4 additions & 0 deletions templates/minio.env.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# {{ ansible_managed }}

# Minio local/remote volumes.
{% if minio_server_cluster_nodes | length > 0 %}
MINIO_VOLUMES="{{ minio_server_cluster_nodes | join(' ') }}"
{% else %}
MINIO_VOLUMES="{{ minio_server_datadirs | join(' ') }}"
{% endif %}
# Minio cli options.
MINIO_OPTS="--address {{ minio_server_addr }} {{ minio_server_opts }}"

Expand Down