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

Fix startup #45

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
- ansible_python_version is version_compare('2.6.0', '>=')
- ansible_python_version is version_compare('2.7.9', '<')

- import_tasks: preflight.yml

- include_tasks: install-server.yml
when: minio_install_server

Expand Down
26 changes: 26 additions & 0 deletions tasks/preflight.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
- name: Validate access key
fail:
msg: "minio_access_key is set but must be at least three characters"
when: minio_access_key|length < 3 and minio_access_key|length != 0

- name: Validate secret key
fail:
msg: "minio_secret_key is set but must be at least 8 characters"
when: minio_secret_key|length < 8 and minio_secret_key|length != 0

- name: Setup __minio_volumes (cluster context)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved the logic for this outside the template. So I could validate it.

set_fact:
__minio_volumes: "{{ minio_server_cluster_nodes | join(' ') }}"
when:
minio_server_cluster_nodes|length > 0

- name: Setup __minio_volumes (single node)
set_fact:
__minio_volumes: "{{ minio_server_datadirs | join(' ') }}"
when: minio_server_datadirs|length > 0 and minio_server_cluster_nodes|length == 0

- name: Validate __minio_volumes
fail:
msg: "Please set minio_server_cluster_nodes or minio_server_datadirs"
when: __minio_volumes|length == 0
7 changes: 2 additions & 5 deletions templates/minio.env.j2
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{{ ansible_managed | comment }}

# 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_VOLUMES="{{ __minio_volumes }}"

# Minio cli options.
MINIO_OPTS="--address {{ minio_server_addr }} {{ minio_server_opts }}"

Expand Down
2 changes: 1 addition & 1 deletion templates/minio.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Group={{ minio_group }}
PermissionsStartOnly=true

EnvironmentFile={{ minio_server_envfile }}
ExecStartPre=/bin/bash -c "[ -n \"${MINIO_VOLUMES}\" ] || echo \"Variable MINIO_VOLUMES not set in {{ minio_server_envfile }}\""
#ExecStartPre=/bin/bash -c "[ -n \"${MINIO_VOLUMES}\" ] || echo \"Variable MINIO_VOLUMES not set in {{ minio_server_envfile }}\""
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can remove this if you like.


ExecStart={{ minio_server_bin }} server $MINIO_OPTS $MINIO_VOLUMES

Expand Down