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

Update systemd service file #16

Merged
merged 5 commits into from
Jun 25, 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
50 changes: 50 additions & 0 deletions molecule/alternative/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
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: alternative
verifier:
name: testinfra
lint:
name: flake8
enabled: true
14 changes: 14 additions & 0 deletions molecule/alternative/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---

- hosts: all
any_errors_fatal: true
roles:
- ansible-minio
vars:
minio_server_envfile: "/opt/minio"
minio_server_addr: ":80"
minio_server_datadirs:
- "/srv/data1"
- "/srv/data2"
- "/srv/data3"
- "/srv/data4"
49 changes: 49 additions & 0 deletions molecule/alternative/tests/test_minio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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'


@pytest.mark.parametrize('minio_bin_var', [
'minio_server_bin',
'minio_client_bin',
])
def test_minio_installed(File, AnsibleDefaults, minio_bin_var):

f = File(AnsibleDefaults[minio_bin_var])
assert f.exists
assert f.user == AnsibleDefaults['minio_user']
assert f.group == AnsibleDefaults['minio_group']
assert oct(f.mode) == '0755'


def test_minio_service(Service):

s = Service('minio')
assert s.is_running
assert s.is_enabled


def test_capabilities(host):
service_file = host.file("/etc/systemd/system/minio.service")
assert service_file.contains("AmbientCapabilities=CAP_NET_BIND_SERVICE")
2 changes: 2 additions & 0 deletions templates/minio.init.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
# Description: Distributed object storage server built for cloud applications and devops.
### END INIT INFO

# {{ ansible_managed }}

# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the mountnfs.sh script
Expand Down
10 changes: 10 additions & 0 deletions templates/minio.service.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# {{ ansible_managed }}

[Unit]
Description=Minio
Documentation=https://docs.minio.io
Expand All @@ -15,8 +17,12 @@ PermissionsStartOnly=true

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

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

# Let systemd restart this service only if it has ended with the clean exit code or signal.
Restart=on-success

StandardOutput=journal
StandardError=inherit

Expand All @@ -33,5 +39,9 @@ SendSIGKILL=no

SuccessExitStatus=0

{% if (minio_server_addr.split(':')[-1] | int) < 1024 %}
AmbientCapabilities=CAP_NET_BIND_SERVICE
{% endif %}

[Install]
WantedBy=multi-user.target