mirror of
https://github.com/atosatto/ansible-minio.git
synced 2024-11-22 11:25:11 +01:00
Switch from upstart to init.d to improve the support for non-systemd systems
This commit is contained in:
parent
438c20cc62
commit
b373160051
20
molecule.yml
20
molecule.yml
@ -7,12 +7,18 @@ docker:
|
||||
image: atosatto/centos
|
||||
image_version: 7-systemd
|
||||
privileged: True
|
||||
# - name: minio-ubuntu-16.04
|
||||
# image: atosatto/ubuntu
|
||||
# image_version: 16.04
|
||||
- name: minio-ubuntu-16.04
|
||||
image: atosatto/ubuntu
|
||||
image_version: 16.04
|
||||
privileged: True
|
||||
# TODO: Find a workaround to
|
||||
# https://github.com/ansible/ansible/issues/18894
|
||||
# and add ubuntu-14.04 to CI.
|
||||
# - name: minio-ubuntu-14.04
|
||||
# image: ubuntu
|
||||
# image_version: 14.04
|
||||
# privileged: True
|
||||
# Unfortunately, upstart does not run in Docker containers,
|
||||
# so no Ubuntu 14.04 docker tests :/
|
||||
|
||||
|
||||
# vagrant driver configuration (development)
|
||||
vagrant:
|
||||
@ -31,6 +37,10 @@ vagrant:
|
||||
cpus: 2
|
||||
instances:
|
||||
- name: ansible-minio-01
|
||||
interfaces:
|
||||
- network_name: private_network
|
||||
type: dhcp
|
||||
auto_config: true
|
||||
options:
|
||||
append_platform_to_hostname: yes
|
||||
|
||||
|
@ -3,6 +3,19 @@
|
||||
- name: include os-specific variables
|
||||
include_vars: "{{ ansible_os_family }}.yml"
|
||||
|
||||
# add the python sni support to legacy python installations
|
||||
- include: python_sni.yml
|
||||
when: ansible_os_family == 'Debian'
|
||||
and ansible_python_version | version_compare('2.6.0', '>=')
|
||||
and ansible_python_version | version_compare('2.7.9', '<')
|
||||
|
||||
# install additional ansible dependencies
|
||||
- name: install ansible support packages
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
with_items: "{{ ansible_support_packages }}"
|
||||
|
||||
- name: create minio group
|
||||
group:
|
||||
name: "{{ minio_group }}"
|
||||
|
24
tasks/python_sni.yml
Normal file
24
tasks/python_sni.yml
Normal file
@ -0,0 +1,24 @@
|
||||
---
|
||||
|
||||
# with_indexed_items is required as a workaround for this issue:
|
||||
# https://github.com/ansible/ansible-modules-core/issues/1178
|
||||
- name: install python-pip
|
||||
package:
|
||||
name: "{{ item.1 }}"
|
||||
state: present
|
||||
with_indexed_items: "{{ python_pip_packages }}"
|
||||
|
||||
- name: install the Python SNI support packages
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
with_items: "{{ python_sni_support_packages }}"
|
||||
|
||||
# There extra pip dependencies are needed to add SSL SNI support to
|
||||
# Python version prior to 2.7.9. SNI support is needed by the Ansible
|
||||
# get_url module in server.yml and client.yml.
|
||||
- name: install the Python SNI python-pip dependencies.
|
||||
pip:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
with_items: "{{ python_sni_pip_dependencies }}"
|
@ -10,7 +10,7 @@
|
||||
|
||||
- name: generate the minio server envfile
|
||||
template:
|
||||
src: minio_env.j2
|
||||
src: minio.env.j2
|
||||
dest: "{{ minio_server_envfile }}"
|
||||
notify: restart minio
|
||||
|
||||
@ -20,11 +20,12 @@
|
||||
dest: "{{ systemd_units_dir }}/minio.service"
|
||||
when: ansible_service_mgr == "systemd"
|
||||
|
||||
- name: create the minio server upstart config
|
||||
- name: create the minio server init.d config
|
||||
template:
|
||||
src: minio.upstart.j2
|
||||
dest: "{{ upstart_conf_dir }}/minio.conf"
|
||||
when: ansible_service_mgr == "upstart"
|
||||
src: minio.init.j2
|
||||
dest: "{{ initd_conf_dir }}/minio"
|
||||
mode: 0755
|
||||
when: ansible_service_mgr != "systemd"
|
||||
|
||||
- name: enable and start the minio service
|
||||
service:
|
||||
|
131
templates/minio.init.j2
Normal file
131
templates/minio.init.j2
Normal file
@ -0,0 +1,131 @@
|
||||
#! /bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: minio
|
||||
# Required-Start: $syslog $network
|
||||
# Required-Stop: $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Distributed object storage server built for cloud applications and devops.
|
||||
# Description: Distributed object storage server built for cloud applications and devops.
|
||||
### END INIT INFO
|
||||
|
||||
# Do NOT "set -e"
|
||||
|
||||
# PATH should only include /usr/* if it runs after the mountnfs.sh script
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||
NAME=minio
|
||||
SERVICEVERBOSE=yes
|
||||
PIDFILE=/var/run/$NAME.pid
|
||||
SCRIPTNAME=/etc/init.d/$NAME
|
||||
WORKINGDIR=/usr/local/
|
||||
DAEMON="{{ minio_server_bin }}"
|
||||
USER="{{ minio_user }}"
|
||||
|
||||
# Read configuration variable file if it is present
|
||||
[ -r "{{ minio_server_envfile }}" ] && . {{ minio_server_envfile }}
|
||||
|
||||
# Make sure the MINIO_VOLUMES variable is defined
|
||||
[ -n "${MINIO_VOLUMES}" ] || log_daemon_msg "Variable MINIO_VOLUMES not set in {{ minio_server_envfile }}"
|
||||
|
||||
# Set the DAEMON_ARGS variable
|
||||
DAEMON_ARGS="server $MINIO_OPTS $MINIO_VOLUMES"
|
||||
|
||||
# Specifies the maximum file descriptor number that can be opened by this process
|
||||
ulimit -n 65536
|
||||
|
||||
# Exit if the package is not installed
|
||||
[ -x "$DAEMON" ] || exit 0
|
||||
|
||||
# Load the VERBOSE setting and other rcS variables
|
||||
. /lib/init/vars.sh
|
||||
|
||||
# Define LSB log_* functions.
|
||||
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
|
||||
# and status_of_proc is working.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
#
|
||||
# Function that starts the daemon/service
|
||||
#
|
||||
do_start()
|
||||
{
|
||||
# Return
|
||||
# 0 if daemon has been started
|
||||
# 1 if daemon was already running
|
||||
# 2 if daemon could not be started
|
||||
sh -c "USER=$USER start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \\
|
||||
--test --chdir $WORKINGDIR --chuid $USER \\
|
||||
--exec $DAEMON -- $DAEMON_ARGS > /dev/null \\
|
||||
|| return 1"
|
||||
sh -c "USER=$USER start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \\
|
||||
--background --chdir $WORKINGDIR --chuid $USER \\
|
||||
--exec $DAEMON -- $DAEMON_ARGS \\
|
||||
|| return 2"
|
||||
}
|
||||
|
||||
#
|
||||
# Function that stops the daemon/service
|
||||
#
|
||||
do_stop()
|
||||
{
|
||||
# Return
|
||||
# 0 if daemon has been stopped
|
||||
# 1 if daemon was already stopped
|
||||
# 2 if daemon could not be stopped
|
||||
# other if a failure occurred
|
||||
start-stop-daemon --stop --quiet --retry=TERM/1/KILL/5 --pidfile $PIDFILE --name $NAME
|
||||
RETVAL="$?"
|
||||
[ "$RETVAL" = 2 ] && return 2
|
||||
start-stop-daemon --stop --quiet --oknodo --retry=0/1/KILL/5 --exec $DAEMON
|
||||
[ "$?" = 2 ] && return 2
|
||||
# Many daemons don't delete their pidfiles when they exit.
|
||||
rm -f $PIDFILE
|
||||
return "$RETVAL"
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
[ "$SERVICEVERBOSE" != no ] && log_daemon_msg "Starting" "$NAME"
|
||||
do_start
|
||||
case "$?" in
|
||||
0|1) [ "$SERVICEVERBOSE" != no ] && log_end_msg 0 ;;
|
||||
2) [ "$SERVICEVERBOSE" != no ] && log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
stop)
|
||||
[ "$SERVICEVERBOSE" != no ] && log_daemon_msg "Stopping" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1) [ "$SERVICEVERBOSE" != no ] && log_end_msg 0 ;;
|
||||
2) [ "$SERVICEVERBOSE" != no ] && log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
status)
|
||||
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
|
||||
;;
|
||||
restart|force-reload)
|
||||
log_daemon_msg "Restarting" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1)
|
||||
do_start
|
||||
case "$?" in
|
||||
0) log_end_msg 0 ;;
|
||||
1) log_end_msg 1 ;; # Old process is still running
|
||||
*) log_end_msg 1 ;; # Failed to start
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
# Failed to stop
|
||||
log_end_msg 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
|
||||
:
|
@ -1,36 +0,0 @@
|
||||
description "minio"
|
||||
|
||||
start on (local-filesystems and net-device-up IFACE!=lo)
|
||||
stop on shutdown
|
||||
|
||||
# Maximum file descriptor number that can be opened
|
||||
limit nofile 65536 65536
|
||||
|
||||
# Set the kill signal and timeout
|
||||
kill signal SIGTERM
|
||||
|
||||
pre-start script
|
||||
# enable the dash allexport feature
|
||||
set -a
|
||||
|
||||
# stop job from continuing if no config file found for daemon
|
||||
[ ! -f {{ minio_server_envfile }} ] && { stop; exit 0; }
|
||||
|
||||
# source the config file
|
||||
. {{ minio_server_envfile }}
|
||||
|
||||
# stop job from continuing if MINIO_VOLUMES not set
|
||||
[ -n "$MINIO_VOLUMES" ] || { echo "Variable MINIO_VOLUMES not set in {{ minio_server_envfile }}"; stop; exit 0; }
|
||||
|
||||
end script
|
||||
|
||||
script
|
||||
# enable the dash allexport feature
|
||||
set -a
|
||||
|
||||
# source the environment config file
|
||||
. {{ minio_server_envfile }}
|
||||
|
||||
# start the minio server
|
||||
exec sudo -u {{ minio_user }} {{ minio_server_bin }} server $MINIO_OPTS $MINIO_VOLUMES
|
||||
end script
|
@ -1,4 +1,18 @@
|
||||
---
|
||||
|
||||
# systemd unit files location
|
||||
systemd_units_dir: /lib/systemd/system
|
||||
upstart_conf_dir: /etc/init
|
||||
|
||||
# packages providing python-pip
|
||||
python_pip_packages:
|
||||
- python-pip
|
||||
|
||||
# extra packages required to add SNI support to legacy python versions
|
||||
python_sni_support_packages:
|
||||
- python-dev
|
||||
- libssl-dev
|
||||
- libffi-dev
|
||||
|
||||
# extra packages needed by ansible to correctly configure the system
|
||||
ansible_support_packages:
|
||||
- ca-certificates
|
||||
|
@ -1,3 +1,15 @@
|
||||
---
|
||||
|
||||
# systemd unit files location
|
||||
systemd_units_dir: /etc/systemd/system
|
||||
|
||||
# packages providing python-pip
|
||||
python_pip_packages:
|
||||
- epel-release
|
||||
- python-pip
|
||||
|
||||
# extra packages required to add SNI support to legacy python versions
|
||||
python_sni_support_packages: [ ]
|
||||
|
||||
# extra packages needed by ansible to correctly configure the system
|
||||
ansible_support_packages: [ ]
|
||||
|
@ -3,3 +3,12 @@
|
||||
# Minio and MC download urls
|
||||
minio_server_download_url: https://dl.minio.io/server/minio/release/linux-amd64/minio
|
||||
minio_client_download_url: https://dl.minio.io/client/mc/release/linux-amd64/mc
|
||||
|
||||
# default init scripts location
|
||||
initd_conf_dir: /etc/init.d
|
||||
|
||||
# python pip packages required to support SNI certificates
|
||||
python_sni_pip_dependencies:
|
||||
- pyopenssl
|
||||
- ndg-httpsclient
|
||||
- pyasn1
|
||||
|
Loading…
Reference in New Issue
Block a user