├── .gitignore ├── .travis.yml ├── LICENSE.md ├── README.md ├── Vagrantfile ├── defaults └── main.yml ├── handlers └── main.yml ├── inventory ├── main.yml ├── meta └── main.yml ├── tasks ├── configure.yml ├── install.yml └── main.yml ├── templates ├── init.Debian └── supervisord.conf └── test.yml /.gitignore: -------------------------------------------------------------------------------- 1 | # Don't commit vagrant's machine specifications, 2 | # which are unique for each installation. 3 | /.vagrant/ 4 | 5 | # Ignore some common junk. 6 | *~ 7 | *.swp 8 | *.lock 9 | *.orig 10 | *.retry 11 | .DS_Store 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # Configuration directives for Travis CI 4 | # -------------------------------------- 5 | 6 | # See the Travis documentation for help on writing this file. 7 | 8 | # [Travis CI] http://travis-ci.org 9 | # [configuration] http://about.travis-ci.org/docs/user/build-configuration/ 10 | 11 | 12 | language: python 13 | 14 | python: 15 | - "2.7" 16 | 17 | install: 18 | - pip install ansible 19 | 20 | script: 21 | # Syntax check every ansible playbook in root 22 | # Don't check main, though, as vars_prompt still 23 | # trigger during syntax checks, and travis fails 24 | - find . -maxdepth 1 -type f -name '*.yml' -not -name '.*' -not -name 'main.yml' | xargs -t -n1 ansible-playbook --syntax-check -i inventory 25 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015, zenoamaro 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Supervisor for Ansible 2 | ====================== 3 | A role for deploying and configuring [Supervisor](http://supervisord.org) and extensions on unix hosts using [Ansible](http://www.ansibleworks.com). 4 | 5 | It can additionally be used as a playbook for quickly provisioning hosts. 6 | 7 | Vagrant machines are provided to produce VMs for integration testing. 8 | 9 | 10 | Supports 11 | -------- 12 | Supported Supervisor versions: 13 | - Supervisor 3+ 14 | 15 | Supported targets: 16 | - Ubuntu 14.04 LTS "Trusty Tahr" 17 | - Ubuntu 12.04 LTS "Precise Pangolin" 18 | - Debian (untested) 19 | - RedHat (untested) 20 | 21 | Installation methods: 22 | - Binary packages from the system repos. 23 | 24 | 25 | Usage 26 | ----- 27 | Clone this repo into your roles directory: 28 | 29 | $ git clone https://github.com/zenoamaro/ansible-supervisord.git roles/supervisord 30 | 31 | And add it to your play's roles: 32 | 33 | - hosts: ... 34 | roles: 35 | - supervisord 36 | - ... 37 | 38 | This roles comes preloaded with almost every available default. You can override each one in your hosts/group vars, in your inventory, or in your play. See the annotated defaults in `defaults/main.yml` for help in configuration. All provided variables start with `supervisord_` or `supervisorctl_`. 39 | 40 | You can also use the role as a playbook. You will be asked which hosts to provision, and you can further configure the play by using `--extra-vars`. 41 | 42 | $ ansible-playbook -i inventory --extra-vars='{...}' main.yml 43 | 44 | Run the tests by provisioning the appropriate VM: 45 | 46 | $ vagrant up test-ubuntu-trusty 47 | 48 | At the moment, the following test boxes are available: 49 | 50 | - `test-ubuntu-precise` 51 | - `test-ubuntu-trusty` 52 | 53 | 54 | Still to do 55 | ----------- 56 | - Add tasks for quickly creating supervisor programs 57 | - Support for fastcgi programs, event listeners, ... 58 | 59 | 60 | Changelog 61 | --------- 62 | ### 0.3.2 63 | - The package list is not being updated in playbooks anymore. 64 | 65 | ### 0.3.1 66 | - Fixed missing newlines for some configuration variables. 67 | - Added warning for auto-generated files. 68 | - Updated provisioning to use the new Vagrant private keys. 69 | 70 | ### 0.3.0 71 | - Revised the INIT script's restart sequence. 72 | - Added a test box for Ubuntu Trusty 14.04. 73 | - Sleep time between daemon restarts is now configurable. 74 | 75 | ### 0.2.0 76 | - Delegated installation of supervisord to the OS package manager. 77 | 78 | ### 0.1.0 79 | Initial version. 80 | 81 | 82 | License 83 | ------- 84 | The MIT License (MIT) 85 | 86 | Copyright (c) 2015, zenoamaro 87 | 88 | Permission is hereby granted, free of charge, to any person obtaining a copy 89 | of this software and associated documentation files (the "Software"), to deal 90 | in the Software without restriction, including without limitation the rights 91 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 92 | copies of the Software, and to permit persons to whom the Software is 93 | furnished to do so, subject to the following conditions: 94 | 95 | The above copyright notice and this permission notice shall be included in 96 | all copies or substantial portions of the Software. 97 | 98 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 99 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 100 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 101 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 102 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 103 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 104 | THE SOFTWARE. -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure '2' do |config| 5 | 6 | 7 | # Test machines 8 | # ------------- 9 | 10 | # These test machines will configure the installation with all 11 | # its extensions enabled, in order to test the validity 12 | # of the role. 13 | 14 | # Ubuntu machines are available: 15 | # - "test-ubuntu-precise" 16 | # - "test-ubuntu-trusty" 17 | 18 | def apply_test_ansible_defaults(ansible) 19 | ansible.playbook = './test.yml' 20 | ansible.inventory_path = './inventory' 21 | end 22 | 23 | config.vm.define 'test-ubuntu-trusty', autostart:false do |box| 24 | box.vm.box = "ubuntu/trusty64" 25 | config.vm.network :private_network, ip: "192.168.33.21" 26 | config.vm.provision :ansible do |ansible| 27 | apply_test_ansible_defaults ansible 28 | ansible.extra_vars = {} 29 | end 30 | end 31 | 32 | config.vm.define 'test-ubuntu-precise', autostart:false do |box| 33 | box.vm.box = "ubuntu/precise64" 34 | config.vm.network :private_network, ip: "192.168.33.20" 35 | config.vm.provision :ansible do |ansible| 36 | apply_test_ansible_defaults ansible 37 | ansible.extra_vars = {} 38 | end 39 | end 40 | 41 | end 42 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # See the documentation for help in configuring Supervisor. 4 | # [docs] http://supervisord.org/configuration.html 5 | 6 | 7 | # Daemon 8 | # ------ 9 | 10 | # The identifier string for this supervisor process, used by the RPC interface. 11 | supervisord_identifier: supervisor 12 | supervisord_service_name: "{{supervisord_identifier}}" 13 | 14 | supervisord_bin_dir: /usr/bin 15 | supervisord_conf_dir: /etc/supervisor 16 | supervisord_runtime_dir: /var/run 17 | 18 | supervisord_conf_file: "{{supervisord_conf_dir}}/supervisord.conf" 19 | supervisord_conf_file_link: "/etc/supervisord.conf" # FIXME: This is too hardcoded 20 | supervisord_additional_conf_dir: "{{supervisord_conf_dir}}/conf.d" 21 | 22 | supervisord_init_script: "/etc/init.d/{{supervisord_service_name}}" 23 | supervisord_daemon: "{{supervisord_bin_dir}}/supervisord" 24 | supervisord_supervisorctl: "{{supervisord_bin_dir}}/supervisorctl" 25 | 26 | # Sleep time between restarts to catch slowpoke processes. 27 | supervisord_restart_delay_time: 5 28 | 29 | # If true, supervisord will start daemonized. 30 | supervisord_daemonize: yes 31 | 32 | # The location in which supervisord keeps its pid file. This option can include 33 | # the value %(here)s, which expands to the directory in which the supervisord 34 | # configuration file was found, or shell `$variables`. 35 | supervisord_pid_file: "{{supervisord_runtime_dir}}/supervisord.pid" 36 | 37 | # The umask of the supervisord process. 38 | supervisord_umask: '022' 39 | 40 | # A list of key/value pairs in the form KEY="val",KEY2="val2" that will be 41 | # placed in the supervisord process’ environment (and as a result in all of its 42 | # child process’ environments). This option can include the value %(here)s, 43 | # which expands to the directory in which the supervisord configuration file was 44 | # found. Note that subprocesses will inherit the environment variables of the 45 | # shell used to start supervisord except for the ones overridden here and within 46 | # the program’s environment option. See Subprocess Environment. 47 | supervisord_environment: {} 48 | 49 | # If supervisord is run as the root user, switch users to this UNIX user account 50 | # before doing any meaningful processing. This value has no effect if 51 | # supervisord is not run as root. 52 | supervisord_user: 53 | 54 | # When supervisord daemonizes, switch to this directory. This option can include 55 | # the value %(here)s, which expands to the directory in which the supervisord 56 | # configuration file was found. 57 | supervisord_pwd: 58 | 59 | 60 | # Unix socket server 61 | # ------------------ 62 | 63 | supervisord_socket_server: on 64 | 65 | # A path to a UNIX domain socket (e.g. `/tmp/supervisord.sock`) on which 66 | # supervisor will listen for HTTP/XML-RPC requests. supervisorctl uses XML-RPC 67 | # to communicate with supervisord over this port. This option can include the 68 | # value `%(here)s`, which expands to the directory in which the supervisord 69 | # configuration file was found, or shell `$variables`. 70 | supervisord_socket_file: "{{supervisord_runtime_dir}}/supervisor.sock" 71 | 72 | supervisord_socket_chmod: '0700' 73 | supervisord_socket_chown: # Defaults to the `user:group` who started it 74 | 75 | # Specifies the authentication details required to connect to this server. The 76 | # password can be cleartext, or can be specified as a SHA-1 hash if prefixed by 77 | # the string {SHA}. For example, {SHA}82ab876d1387bfafe46cc1c8a2ef074eae50cb1d 78 | # is the SHA-stored version of the password “thepassword”. Note that hashed 79 | # password must be in hex format. 80 | supervisord_socket_authenticated: no 81 | supervisord_socket_username: 82 | supervisord_socket_password: 83 | 84 | 85 | # HTTP server 86 | # ----------- 87 | 88 | supervisord_inet_server: off 89 | 90 | # Host:port values or (e.g. 127.0.0.1 and 9001) on which supervisor will listen 91 | # for HTTP/XML-RPC requests. Supervisorctl will use XML-RPC to communicate with 92 | # supervisord over this port. To listen on all interfaces in the machine, 93 | # specify an empty address or use '*'. 94 | supervisord_inet_address: 127.0.0.1 95 | supervisord_inet_port: 9001 96 | 97 | # Specifies the authentication details required to connect to this server. The 98 | # password can be cleartext, or can be specified as a SHA-1 hash if prefixed by 99 | # the string {SHA}. For example, {SHA}82ab876d1387bfafe46cc1c8a2ef074eae50cb1d 100 | # is the SHA-stored version of the password “thepassword”. Note that hashed 101 | # password must be in hex format. 102 | supervisord_inet_authenticated: no 103 | supervisord_inet_username: 104 | supervisord_inet_password: 105 | 106 | 107 | # Interfaces 108 | # ---------- 109 | 110 | supervisord_rpc_interfaces: {} 111 | 112 | 113 | # Controller 114 | # ---------- 115 | 116 | # The URL that should be used to access the supervisord server, e.g. 117 | # http://localhost:9001. For UNIX domain sockets, use 118 | # unix:///absolute/path/to/file.sock. 119 | supervisorctl_server_url: "unix://{{supervisord_socket_file}}" 120 | 121 | # Specifies the authentication details required to connect to the server. The 122 | # password should be the cleartext version of password from the supervisord 123 | # server configuration for the port or UNIX domain socket you’re attempting to 124 | # access. This value cannot be passed as a SHA hash. Unlike other passwords 125 | # specified in this file, it must be provided in cleartext. 126 | supervisorctl_username: 127 | supervisorctl_password: 128 | 129 | # String used as supervisorctl prompt. 130 | supervisorctl_prompt: "{{supervisord_identifier}}" 131 | 132 | # A path to use as the readline persistent history file. If you enable this 133 | # feature by choosing a path, your supervisorctl commands will be kept in the 134 | # file, and you can use readline (e.g. arrow-up) to invoke commands you 135 | # performed in your last supervisorctl session. 136 | supervisorctl_history_file: 137 | 138 | 139 | # Logging 140 | # ------- 141 | 142 | supervisord_logs_dir: /var/log/supervisor 143 | 144 | # The path to the activity log of the supervisord process. This option can 145 | # include the value %(here)s, which expands to the directory in which the 146 | # supervisord configuration file was found. 147 | supervisord_log_file: "{{supervisord_logs_dir}}/supervisord.log" 148 | 149 | # The logging level, dictating what is written to the supervisord activity log. 150 | # One of critical, error, warn, info, debug, trace, or blather. Note that at log 151 | # level debug, the supervisord log file will record the stderr/stdout output of 152 | # its child processes and extended info info about process state changes, which 153 | # is useful for debugging a process which isn’t starting properly. See also: 154 | # Activity Log Levels. 155 | supervisord_log_level: info 156 | 157 | # The maximum number of bytes that may be consumed by the activity log file 158 | # before it is rotated (suffix multipliers like “KB”, “MB”, and “GB” can be used 159 | # in the value). Set this value to 0 to indicate an unlimited log size. 160 | supervisord_log_file_size: 5MB 161 | 162 | # The number of backups to keep around resulting from activity log file 163 | # rotation. If set to 0, no backups will be kept. 164 | supervisord_log_file_backups: 5 165 | 166 | # The directory used for AUTO child log files. This option can include the value 167 | # %(here)s, which expands to the directory in which the supervisord 168 | # configuration file was found. 169 | supervisord_child_logs_dir: "{{supervisord_logs_dir}}" 170 | 171 | # Strip all ANSI escape sequences from child log files. 172 | supervisord_strip_ansi_from_child_logs: no 173 | 174 | 175 | # Tuning and debugging 176 | # -------------------- 177 | 178 | # Prevent supervisord from clearing any existing AUTO chlild log files at 179 | # startup time. Useful for debugging. 180 | supervisord_no_cleanup: no 181 | 182 | # The minimum number of file descriptors that must be available before 183 | # supervisord will start successfully. A call to setrlimit will be made to 184 | # attempt to raise the soft and hard limits of the supervisord process to 185 | # satisfy minfds. The hard limit may only be raised if supervisord is run as 186 | # root. supervisord uses file descriptors liberally, and will enter a failure 187 | # mode when one cannot be obtained from the OS, so it’s useful to be able to 188 | # specify a minimum value to ensure it doesn’t run out of them during execution. 189 | # This option is particularly useful on Solaris, which has a low per-process fd 190 | # limit by default. 191 | supervisord_min_fds: 1024 192 | 193 | # The minimum number of process descriptors that must be available before 194 | # supervisord will start successfully. A call to setrlimit will be made to 195 | # attempt to raise the soft and hard limits of the supervisord process to 196 | # satisfy minprocs. The hard limit may only be raised if supervisord is run as 197 | # root. supervisord will enter a failure mode when the OS runs out of process 198 | # descriptors, so it’s useful to ensure that enough process descriptors are 199 | # available upon supervisord startup. 200 | supervisord_min_procs: 200 201 | 202 | 203 | # Include 204 | # ------- 205 | 206 | # A list of file globs. Each file glob may be absolute or relative. If the file 207 | # glob is relative, it is considered relative to the location of the 208 | # configuration file which includes it. A “glob” is a file pattern which matches 209 | # a specified pattern according to the rules used by the Unix shell. No tilde 210 | # expansion is done, but *, ?, and character ranges expressed with [] will be 211 | # correctly matched. Recursive includes from included files are not supported. 212 | supervisord_additional_conf_files: 213 | - "{{supervisord_additional_conf_dir}}/*.conf" 214 | -------------------------------------------------------------------------------- /handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: restart supervisord 4 | sudo: yes 5 | service: name=supervisor state=restarted 6 | 7 | - name: reread supervisord 8 | sudo: yes 9 | command: supervisorctl reread 10 | 11 | - name: update supervisord 12 | sudo: yes 13 | command: supervisorctl update 14 | -------------------------------------------------------------------------------- /inventory: -------------------------------------------------------------------------------- 1 | [test-ubuntu-precise] 2 | 192.168.33.20 ansible_ssh_private_key_file=.vagrant/machines/test-ubuntu-precise/virtualbox/private_key 3 | 4 | [test-ubuntu-trusty] 5 | 192.168.33.21 ansible_ssh_private_key_file=.vagrant/machines/test-ubuntu-trusty/virtualbox/private_key 6 | 7 | [test:children] 8 | test-ubuntu-precise 9 | test-ubuntu-trusty 10 | 11 | [vagrant:children] 12 | test 13 | 14 | [vagrant:vars] 15 | ansible_ssh_user=vagrant -------------------------------------------------------------------------------- /main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # Quick-provisioning playbook 4 | # --------------------------- 5 | 6 | # A Simple, straight playbook for quick remote installations. 7 | # You will be asked which hosts to provision before-hand. 8 | 9 | 10 | - name: 'Supervisor' 11 | 12 | vars_prompt: 13 | selected_hosts: Specify the hosts to provision 14 | 15 | hosts: "{{selected_hosts}}" 16 | 17 | roles: 18 | - '.' # The current directory itself is the role 19 | 20 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | galaxy_info: 4 | author: zenoamaro 5 | description: A role to install and configure Supervisord 6 | version: 0.3.2 7 | license: MIT 8 | min_ansible_version: 1.4 9 | 10 | platforms: 11 | - name: Debian 12 | - name: Ubuntu 13 | versions: 14 | - precise 15 | - trusty 16 | 17 | categories: 18 | - monitoring 19 | 20 | dependencies: [] 21 | -------------------------------------------------------------------------------- /tasks/configure.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # Targeting specific OSes or distributions: 4 | # 5 | # - `ansible_system` → Linux, BSD, ... 6 | # - `ansible_os_family` → Debian, RedHat, ... 7 | # - `ansible_distribution` → Debian, Ubuntu, RedHat, ... 8 | # - `ansible_distribution_release` → precise, wheezy, ... 9 | # - `ansible_pkg_mgr` → apt, yum, ... 10 | 11 | - name: Create Supervisor conf and log directories 12 | sudo: yes 13 | file: 14 | dest: "{{item}}" 15 | state: directory 16 | with_items: 17 | - "{{supervisord_conf_dir}}" 18 | - "{{supervisord_additional_conf_dir}}" 19 | - "{{supervisord_logs_dir}}" 20 | notify: restart supervisord 21 | tags: 22 | - conf 23 | - supervisor 24 | - supervisord 25 | 26 | - name: Configure Supervisord 27 | sudo: yes 28 | template: 29 | src: supervisord.conf 30 | dest: "{{supervisord_conf_file}}" 31 | notify: restart supervisord 32 | tags: 33 | - conf 34 | - supervisor 35 | - supervisord 36 | 37 | - name: Link Supervisord conf 38 | sudo: yes 39 | file: 40 | src: "{{supervisord_conf_file}}" 41 | dest: "{{supervisord_conf_file_link}}" 42 | state: link 43 | notify: restart supervisord 44 | tags: 45 | - conf 46 | - supervisor 47 | - supervisord 48 | 49 | - name: Create supervisord init script 50 | sudo: yes 51 | template: 52 | src: "{{item}}" 53 | dest: "{{supervisord_init_script}}" 54 | mode: 0755 55 | with_first_found: 56 | - files: 57 | - "init.{{ansible_distribution}}-{{ansible_distribution_release}}" 58 | - "init.{{ansible_distribution}}" 59 | - "init.{{ansible_os_family}}" 60 | paths: 61 | - ../templates/ 62 | notify: restart supervisord 63 | tags: 64 | - init 65 | - conf 66 | - supervisor 67 | - supervisord 68 | 69 | - name: Add supervisord to init 70 | sudo: yes 71 | service: 72 | name: "{{supervisord_service_name}}" 73 | enabled: yes 74 | tags: 75 | - init 76 | - conf 77 | - supervisor 78 | - supervisord 79 | -------------------------------------------------------------------------------- /tasks/install.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # Targeting specific OSes or distributions: 4 | # 5 | # - `ansible_system` → Linux, BSD, ... 6 | # - `ansible_os_family` → Debian, RedHat, ... 7 | # - `ansible_distribution` → Debian, Ubuntu, RedHat, ... 8 | # - `ansible_distribution_release` → precise, wheezy, ... 9 | # - `ansible_pkg_mgr` → apt, yum, ... 10 | 11 | - name: Update the packages list 12 | sudo: yes 13 | when: ansible_os_family == 'Debian' 14 | apt: 15 | update_cache: yes 16 | cache_valid_time: 3600 17 | tags: 18 | - deps 19 | - supervisor 20 | - supervisord 21 | 22 | - name: Install Supervisord 23 | sudo: yes 24 | when: ansible_os_family == 'Debian' 25 | apt: 26 | name: supervisor 27 | state: present 28 | tags: 29 | - deps 30 | - supervisor 31 | - supervisord 32 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # Delegate further configuration to subtasks 4 | # placed in this same directory. 5 | 6 | - include: install.yml 7 | - include: configure.yml 8 | 9 | - name: Ensure supervisord is running 10 | sudo: yes 11 | service: 12 | name: "{{supervisord_service_name}}" 13 | state: running 14 | enabled: yes 15 | tags: 16 | - init 17 | - supervisor 18 | - supervisord 19 | -------------------------------------------------------------------------------- /templates/init.Debian: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # WARNING: This file is auto-generated from the provisioning 4 | # scripts. Do not edit by hand because your changes 5 | # will likely be overwritten. 6 | # 7 | # skeleton example file to build /etc/init.d/ scripts. 8 | # This file should be used to construct scripts for /etc/init.d. 9 | # 10 | # Written by Miquel van Smoorenburg . 11 | # Modified for Debian 12 | # by Ian Murdock . 13 | # Further changes by Javier Fernandez-Sanguino 14 | # Modified by sbilly Added supervisorctl to status 15 | # 16 | # Version: @(#)skeleton 1.9 26-Feb-2001 miquels@cistron.nl 17 | # 18 | ### BEGIN INIT INFO 19 | # Provides: supervisor 20 | # Required-Start: $remote_fs $network $named 21 | # Required-Stop: $remote_fs $network $named 22 | # Default-Start: 2 3 4 5 23 | # Default-Stop: 0 1 6 24 | # Short-Description: Start/stop supervisor 25 | # Description: Start/stop supervisor daemon and its configured 26 | # subprocesses. 27 | ### END INIT INFO 28 | 29 | . /lib/lsb/init-functions 30 | 31 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 32 | DAEMON={{supervisord_daemon}} 33 | SUPERVISORCTL={{supervisord_supervisorctl}} 34 | NAME={{supervisord_service_name}} 35 | DESC=Supervisor 36 | 37 | test -x $DAEMON || exit 0 38 | 39 | LOGDIR={{supervisord_logs_dir}} 40 | PIDFILE={{supervisord_pid_file}} 41 | 42 | # Time to wait for the server to die, in seconds 43 | # If this value is set too low you might not 44 | # let some servers to die gracefully and 45 | # 'restart' will not work 46 | DODTIME={{supervisord_restart_delay_time}} 47 | 48 | # Include supervisor defaults if available 49 | if [ -f /etc/default/{{supervisord_service_name}} ] ; then 50 | . /etc/default/{{supervisord_service_name}} 51 | fi 52 | 53 | # Load these global settings 54 | DAEMON_OPTS="-c /etc/supervisor/supervisord.conf $DAEMON_OPTS" 55 | 56 | set -e 57 | 58 | running_pid() 59 | { 60 | # Check if a given process pid's cmdline matches a given name 61 | pid=$1 62 | name=$2 63 | [ -z "$pid" ] && return 1 64 | [ ! -d /proc/$pid ] && return 1 65 | (cat /proc/$pid/cmdline | tr "\000" "\n"|grep -q $name) || return 1 66 | return 0 67 | } 68 | 69 | running() 70 | { 71 | # Check if the process is running looking at /proc 72 | # (works for all users) 73 | 74 | # No pidfile, probably no daemon present 75 | [ ! -f "$PIDFILE" ] && return 1 76 | # Obtain the pid and check it against the binary name 77 | pid=`cat $PIDFILE` 78 | running_pid $pid $DAEMON || return 1 79 | return 0 80 | } 81 | 82 | force_stop() { 83 | # Forcefully kill the process 84 | [ ! -f "$PIDFILE" ] && return 85 | if running ; then 86 | kill -15 $pid 87 | # Is it really dead? 88 | [ -n "$DODTIME" ] && sleep "$DODTIME"s 89 | if running ; then 90 | kill -9 $pid 91 | [ -n "$DODTIME" ] && sleep "$DODTIME"s 92 | if running ; then 93 | echo "Cannot kill $NAME (pid=$pid)!" 94 | exit 1 95 | fi 96 | fi 97 | fi 98 | rm -f $PIDFILE 99 | return 0 100 | } 101 | 102 | case "$1" in 103 | start) 104 | echo -n "Starting $DESC: " 105 | start-stop-daemon --start --pidfile $PIDFILE \ 106 | --startas $DAEMON -- $DAEMON_OPTS 107 | test -f $PIDFILE || sleep 1 108 | if running ; then 109 | echo "$NAME." 110 | else 111 | echo "ERROR." 112 | fi 113 | ;; 114 | stop) 115 | echo -n "Stopping $DESC: " 116 | start-stop-daemon --stop --oknodo --pidfile $PIDFILE 117 | echo "$NAME." 118 | ;; 119 | force-stop) 120 | echo -n "Forcefully stopping $DESC: " 121 | force_stop 122 | if ! running ; then 123 | echo "$NAME." 124 | else 125 | echo "ERROR." 126 | fi 127 | ;; 128 | #reload) 129 | # 130 | # If the daemon can reload its config files on the fly 131 | # for example by sending it SIGHUP, do it here. 132 | # 133 | # If the daemon responds to changes in its config file 134 | # directly anyway, make this a do-nothing entry. 135 | # 136 | # echo "Reloading $DESC configuration files." 137 | # start-stop-daemon --stop --signal 1 --pidfile \ 138 | # /var/run/$NAME.pid --exec $DAEMON 139 | #;; 140 | force-reload) 141 | # 142 | # If the "reload" option is implemented, move the "force-reload" 143 | # option to the "reload" entry above. If not, "force-reload" is 144 | # just the same as "restart" except that it does nothing if the 145 | # daemon isn't already running. 146 | # check wether $DAEMON is running. If so, restart 147 | start-stop-daemon --stop --test --pidfile $PIDFILE \ 148 | --startas $DAEMON \ 149 | && $0 restart \ 150 | || exit 0 151 | ;; 152 | restart) 153 | echo -n "Restarting $DESC: " 154 | start-stop-daemon --stop --oknodo --pidfile $PIDFILE 155 | [ -n "$DODTIME" ] && sleep $DODTIME 156 | start-stop-daemon --start --pidfile $PIDFILE \ 157 | --startas $DAEMON -- $DAEMON_OPTS 158 | echo "$NAME." 159 | ;; 160 | status) 161 | echo -n "$NAME is " 162 | if running ; then 163 | echo "running" 164 | else 165 | echo "not running." 166 | exit 1 167 | fi 168 | $SUPERVISORCTL $DAEMON_OPTS status 169 | ;; 170 | *) 171 | N=/etc/init.d/$NAME 172 | # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 173 | echo "Usage: $N {start|stop|restart|force-reload|status|force-stop}" >&2 174 | exit 1 175 | ;; 176 | esac 177 | 178 | exit 0 -------------------------------------------------------------------------------- /templates/supervisord.conf: -------------------------------------------------------------------------------- 1 | ; WARNING: This file is auto-generated from the provisioning 2 | ; scripts. Do not edit by hand because your changes 3 | ; will likely be overwritten. 4 | 5 | ; See the documentation for help in configuring this file. 6 | ; [docs] http://supervisord.org/configuration.html 7 | 8 | 9 | [supervisord] ;---------------------------------------------------------------- 10 | 11 | ; Daemon 12 | ; ------ 13 | 14 | nodaemon = {{'false' if supervisord_daemonize else 'true'}} 15 | pidfile = {{supervisord_pid_file}} 16 | identifier = {{supervisord_identifier}} 17 | umask = {{supervisord_umask}} 18 | {% if supervisord_user %} 19 | user = {{supervisord_user}} 20 | {% endif %} 21 | {% if supervisord_pwd %} 22 | directory = {{supervisord_pwd}} 23 | {% endif %} 24 | {% if supervisord_environment %} 25 | environment = {% for key, value in supervisord_environment.items() -%} 26 | {{key}}="{{value}}" 27 | {%- if not loop.last %},{% endif %} 28 | {%- endfor %} 29 | {% endif %} 30 | 31 | 32 | ; Tuning parameters 33 | ; ----------------- 34 | 35 | ; The minimum number of file descriptors that must be available 36 | minfds = {{supervisord_min_fds}} 37 | ; The minimum number of process descriptors that must be available 38 | minprocs = {{supervisord_min_procs}} 39 | ; Prevent supervisord from clearing any existing AUTO chlild log files at 40 | ; startup time. Useful for debugging. 41 | nocleanup = {{'true' if supervisord_no_cleanup else 'false'}} 42 | 43 | ; Logging 44 | ; ------- 45 | 46 | logfile = {{supervisord_log_file}} 47 | loglevel = {{supervisord_log_level}} 48 | logfile_maxbytes = {{supervisord_log_file_size}} 49 | logfile_backups = {{supervisord_log_file_backups}} 50 | childlogdir = {{supervisord_child_logs_dir}} 51 | strip_ansi = {{'true' if supervisord_strip_ansi_from_child_logs else 'false'}} 52 | 53 | 54 | {% if supervisord_socket_server %} 55 | [unix_http_server] ;----------------------------------------------------------- 56 | 57 | file = {{supervisord_socket_file}} ; Path to the socket file 58 | {% if supervisord_socket_chmod %} 59 | chmod = {{supervisord_socket_chmod}} 60 | {% endif %} 61 | {% if supervisord_socket_chown %} 62 | chown = {{supervisord_socket_chown}} 63 | {% endif %} 64 | {% if supervisord_socket_authenticated %} 65 | username = {{supervisord_socket_username}} 66 | password = {{supervisord_socket_username}} 67 | {% endif %} 68 | {% endif %} 69 | 70 | 71 | {% if supervisord_inet_server %} 72 | [unix_inet_server] ;----------------------------------------------------------- 73 | 74 | port = {{supervisord_inet_address}}:{{supervisord_inet_port}} 75 | {% if supervisord_inet_authenticated %} 76 | username = {{supervisord_inet_username}} 77 | password = {{supervisord_inet_username}} 78 | {% endif %} 79 | {% endif %} 80 | 81 | [rpcinterface:supervisor] ;---------------------------------------------------- 82 | 83 | ; This section must remain in the config file for RPC (supervisorctl/ 84 | ; web interface) to work, additional interfaces may be added by defining 85 | ; them in separate `rpcinterface: sections`. 86 | supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface 87 | 88 | {% for name, interface in supervisord_rpc_interfaces.items() %} 89 | [rpcinterface:{{name}}] 90 | {% for key, value in interface.items() %} 91 | {{name}} = {{interface.factory}} 92 | {% endfor %} 93 | 94 | {% endfor %} 95 | 96 | [supervisorctl] ;-------------------------------------------------------------- 97 | 98 | serverurl = {{supervisorctl_server_url}} ; Use a unix:// URL for a unix socket 99 | 100 | 101 | [include] ;-------------------------------------------------------------------- 102 | 103 | ; This section can just contain the "files" setting. This setting can list 104 | ; multiple files (separated by whitespace). It can also contain wildcards. 105 | ; The filenames are interpreted as relative to this file. 106 | ; Included files *cannot* include files themselves. 107 | 108 | files = {% for file in supervisord_additional_conf_files %}{{file}} {% endfor %} 109 | 110 | -------------------------------------------------------------------------------- /test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # Integration testing playbook 4 | # ---------------------------- 5 | 6 | # A playbook for testing and integration. 7 | 8 | # It will provision the `test` hosts in the inventory, 9 | # which will, by default, specify the provided vagrant VM. 10 | 11 | # This playbook should aim to test the most extensive 12 | # or comprehensive configuration possible for your role. 13 | 14 | 15 | - name: 'Role integration tests' 16 | 17 | hosts: test 18 | 19 | vars: 20 | # custom_configuration: value 21 | 22 | roles: 23 | - '.' # The current directory itself is the role 24 | 25 | --------------------------------------------------------------------------------