Skip to content

Commit

Permalink
Merge pull request #33 from Oefenweb/add-1604-support
Browse files Browse the repository at this point in the history
Add support for Ubuntu 16.04
  • Loading branch information
tersmitten authored Jan 3, 2017
2 parents 764f278 + 492ffd9 commit 6a3c2ff
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ supervisor_programs_present:
stderr_logfile_maxbytes: 0
user: vagrant
numprocs: 8
process_name: %(program_name)s-%(process_num)s
process_name: '%(program_name)s-%(process_num)s'
bar:
command: 'sleep 10'
directory: /tmp
Expand Down
7 changes: 7 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ boxes = [
:cpu => "50",
:ram => "256"
},
{
:name => "ubuntu-1604",
:box => "bento/ubuntu-16.04",
:ip => '10.0.0.13',
:cpu => "50",
:ram => "256"
},
]

Vagrant.configure("2") do |config|
Expand Down
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ supervisor_inet_http_server_port: 9001
supervisor_inet_http_server_username: admin
supervisor_inet_http_server_password: '4ubA&Et=ASPe'

supervisor_supervisord_restart_sec: 5

supervisor_supervisord_nodaemon: false
supervisor_supervisord_logfile: /var/log/supervisor/supervisord.log
supervisor_supervisord_pidfile: /var/run/supervisord.pid
Expand Down
9 changes: 5 additions & 4 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ galaxy_info:
license: MIT
min_ansible_version: 1.6
platforms:
- name: Ubuntu
versions:
- precise
- trusty
- name: Ubuntu
versions:
- precise
- trusty
- xenial
galaxy_tags:
- web
- system
Expand Down
21 changes: 11 additions & 10 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
path: "{{ item }}/"
register: stat_directories
with_items:
- "{{ supervisor_default_file | dirname }}"
- "{{ supervisor_configuration_file | dirname }}"
- "{{ supervisor_unix_http_server_file | dirname }}"
- "{{ supervisor_supervisord_logfile | dirname }}"
Expand All @@ -28,26 +29,26 @@
- supervisor-configure-directories
- supervisor-configure-directories-create

- name: configure | update configuration file - /etc/supervisor/supervisord.conf
- name: configure | update configuration file - /etc/default/supervisor
template:
src: etc/supervisor/supervisord.conf.j2
dest: "{{ supervisor_configuration_file }}"
src: "{{ supervisor_default_file.lstrip('/') }}.j2"
dest: "{{ supervisor_default_file }}"
owner: "{{ supervisor_system_user }}"
group: "{{ supervisor_system_group }}"
mode: 0640
mode: 0644
notify: restart supervisor
tags:
- supervisor-configure-configuration
- supervisor-configure-configuration-supervisord-conf
- supervisor-configure-configuration-default-supervisor

- name: configure | update init script - /etc/init.d/supervisor
- name: configure | update configuration file - /etc/supervisor/supervisord.conf
template:
src: etc/init.d/supervisor.j2
dest: /etc/init.d/supervisor
src: "{{ supervisor_configuration_file.lstrip('/') }}.j2"
dest: "{{ supervisor_configuration_file }}"
owner: "{{ supervisor_system_user }}"
group: "{{ supervisor_system_group }}"
mode: 0755
mode: 0640
notify: restart supervisor
tags:
- supervisor-configure-configuration
- supervisor-configure-configuration-init
- supervisor-configure-configuration-supervisord-conf
16 changes: 16 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@
- supervisor
- supervisor-configure

- include: service-initd.yml
when: ansible_distribution_version | version_compare('15.04', '<')
tags:
- configuration
- supervisor
- supervisor-configure
- supervisor-configure-initd

- include: service-systemd.yml
when: ansible_distribution_version | version_compare('15.04', '>=')
tags:
- configuration
- supervisor
- supervisor-configure
- supervisor-configure-systemd

- include: programs.yml
tags:
- configuration
Expand Down
12 changes: 12 additions & 0 deletions tasks/service-initd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# tasks file for supervisor
---
- name: configure | initd | update script
template:
src: etc/init.d/supervisor.j2
dest: /etc/init.d/supervisor
owner: "{{ supervisor_system_user }}"
group: "{{ supervisor_system_group }}"
mode: 0755
notify: restart supervisor
tags:
- supervisor-service-upstart-update
19 changes: 19 additions & 0 deletions tasks/service-systemd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# tasks file for supervisor
---
- name: configure | systemd | update script
template:
src: templates/lib/systemd/system/supervisor.j2
dest: /lib/systemd/system/supervisor.service
owner: "{{ supervisor_system_user }}"
group: "{{ supervisor_system_group }}"
mode: 0644
register: _update_systemd_script
notify: restart supervisor
tags:
- supervisor-service-systemd-update

- name: service | systemd | reload
command: systemctl daemon-reload
when: _update_systemd_script | changed
tags:
- supervisor-service-systemd-reload
3 changes: 3 additions & 0 deletions templates/etc/default/supervisor.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# {{ ansible_managed }}
#
DAEMON_OPTS=""
15 changes: 7 additions & 8 deletions templates/etc/init.d/supervisor.j2
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,22 @@
. /lib/lsb/init-functions

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/bin/supervisord
SUPERVISORCTL=/usr/local/bin/supervisorctl
DAEMON={{ supervisor_install_prefix }}/supervisord
SUPERVISORCTL={{ supervisor_install_prefix }}/supervisorctl
NAME=supervisord
DESC=supervisor

test -x $DAEMON || exit 0

LOGDIR={{ supervisor_supervisord_logfile | dirname }}
PIDFILE={{ supervisor_supervisord_pidfile }}
DODTIME=5 # Time to wait for the server to die, in seconds
# If this value is set too low you might not
# let some servers to die gracefully and
# 'restart' will not work
# Time to wait for the server to die, in seconds. If this value is set too low you might not let some servers to die
# gracefully and 'restart' will not work
DODTIME={{ supervisor_supervisord_restart_sec }}

# Include supervisor defaults if available
if [ -f /etc/default/supervisor ] ; then
. /etc/default/supervisor
if [ -f {{ supervisor_default_file }} ] ; then
. {{ supervisor_default_file }}
fi
DAEMON_OPTS="-c {{ supervisor_configuration_file }} $DAEMON_OPTS"

Expand Down
28 changes: 28 additions & 0 deletions templates/lib/systemd/system/supervisor.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
; {{ ansible_managed }}

[Unit]
Description=Start/stop supervisor daemon and its configured subprocesses
After=network.target

[Service]
Type=simple
EnvironmentFile={{ supervisor_default_file }}
PermissionsStartOnly=true
ExecStartPre=/usr/bin/test -x {{ supervisor_install_prefix }}/supervisord
ExecStartPre=/usr/bin/install -d \
-o {{ supervisor_system_user }} \
-g {{ supervisor_system_group }} \
-m 0755 \
{{ supervisor_supervisord_logfile | dirname }}
ExecStart={{ supervisor_install_prefix }}/supervisord -n -c {{ supervisor_configuration_file }} $DAEMON_OPTS
ExecStop={{ supervisor_install_prefix }}/supervisorctl -c {{ supervisor_configuration_file }} shutdown
KillMode=process
ExecReload={{ supervisor_install_prefix }}/supervisorctl -c {{ supervisor_configuration_file }} reload
PIDFile={{ supervisor_supervisord_pidfile }}
Restart=on-failure
RestartSec={{ supervisor_supervisord_restart_sec }}s
User={{ supervisor_system_user }}
Group={{ supervisor_system_group }}

[Install]
WantedBy=multi-user.target
2 changes: 2 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
---
supervisor_dependencies:
- python
supervisor_install_prefix: /usr/local/bin
supervisor_default_file: /etc/default/supervisor

0 comments on commit 6a3c2ff

Please sign in to comment.