Giter VIP home page Giter VIP logo

ansible-supervisor's Introduction

supervisor

CI Ansible Galaxy

Set up the latest or a specific version of supervisor in Debian-like systems.

Requirements

  • python (will be installed)
  • pip (will not installed)

Variables

  • supervisor_python_version_major [default: 2]: Python version to install supervisor for.

  • supervisor_python_version [default: supervisor_python_version]: Deprecated

  • supervisor_version [default: latest]: Supervisor version to install (e.g. latest, 3.3.1)

  • supervisor_unix_http_server_file [default: /var/run/supervisor.sock]: A path to a UNIX domain socket (e.g. /tmp/supervisord.sock) on which supervisor will listen for HTTP/XML-RPC requests. supervisorctl uses XML-RPC to communicate with supervisord over this port

  • supervisor_unix_http_server_chmod [default: '0700']: Change the UNIX permission mode bits of the UNIX domain socket to this value at startup

  • supervisor_unix_http_server_chown [optional]: The user and group of supervisor_unix_http_server_file file. Use the following format: user:group

  • supervisor_unix_http_server_username [optional]: The username for authentication to the HTTP/XML-RPC server

  • supervisor_unix_http_server_password [optional]: The password for authentication to the HTTP/XML-RPC server. This can be a cleartext password, or can be specified as a SHA-1 hash if prefixed by the string {SHA}

  • supervisor_system_user [default: root]: Name of the user that should own the config file/directory

  • supervisor_system_group [default: root]: Name of the group that should own the config file/directory

  • supervisor_inet_http_server_enabled [default: false]: Whether or not to enable the HTTP server

  • supervisor_inet_http_server_port [default: 9001]: A TCP host:port value or (e.g. 127.0.0.1:9001) on which supervisor will listen for HTTP/XML-RPC requests. supervisorctl will use XML-RPC to communicate with supervisord over this port

  • supervisor_inet_http_server_username [default: admin]: The username required for authentication to this HTTP server Make sure to change!

  • supervisor_inet_http_server_password [default: '4ubA&Et=ASPe']: The password required for authentication to this HTTP server. This can be a cleartext password, or can be specified as a SHA-1 hash if prefixed by the string {SHA} Make sure to change!

  • supervisor_supervisord_nodaemon [default: false]: If true, supervisord will start in the foreground instead of daemonizing

  • supervisor_supervisord_logfile [default: /var/log/supervisor/supervisord.log]: The path to the activity log of the supervisord process

  • supervisor_supervisord_pidfile [default: /var/run/supervisord.pid]: The location in which supervisord keeps its pid file

  • supervisor_supervisord_childlogdir [default: /var/log/supervisor]: The directory used for AUTO child log files

  • supervisor_supervisord_environment [default: '']: A list of key/value pairs comma separated that will be placed in the environment (e.g. 'KEY1="VALUE1",KEY2="VALUE2"')

  • supervisor_supervisorctl_serverurl [default: "unix://{{ supervisor_unix_http_server_file }}"]: The URL that should be used to access the supervisord server, e.g. http://localhost:9001. For UNIX domain sockets, use unix:///absolute/path/to/file.sock

  • supervisor_include [default: '/etc/supervisor/conf.d/*.conf']: A (single) absolute file glob of files to include

  • supervisor_programs_present [default: {}, see templates/etc/supervisor/conf.d/program.conf.j2]: Program definitions

  • supervisor_programs_present.{n} [required]: Program name

  • supervisor_programs_present.{n}.command [required]: The command that will be run when this program is started

  • supervisor_programs_present.{n}.directory [optional]: A directory to which supervisord should temporarily chdir before exec’ing the child

  • supervisor_programs_present.{n}.environment [optional]: A list of key/value pairs comma separated that will be placed in the child process’ environment (e.g. 'KEY1="VALUE1",KEY2="VALUE2"')

  • supervisor_programs_present.{n}.autostart [optional, default true]: If true, this program will start automatically when supervisord is started

  • supervisor_programs_present.{n}.autorestart [optional, default unexpected]: Whether the process will be autorestarted (e.g. true, false)

  • supervisor_programs_present.{n}.startretries [optional]: The number of serial failure attempts that supervisord will allow when attempting to start the program before giving up

  • supervisor_programs_present.{n}.startsecs [optional]: The total number of seconds which the program needs to stay running after a startup to consider the start successful

  • supervisor_programs_present.{n}.stdout_logfile [optional]: Put process stdout output in this file

  • supervisor_programs_present.{n}.stdout_logfile_maxbytes [optional]: The maximum number of bytes that may be consumed by stdout_logfile before it is rotated

  • supervisor_programs_present.{n}.stderr_logfile [optional]: Put process stderr output in this file

  • supervisor_programs_present.{n}.stderr_logfile_maxbytes [optional]: The maximum number of bytes before logfile rotation for stderr_logfile

  • supervisor_programs_present.{n}.user [optional]: This UNIX user account will be used as the account which runs the program

  • supervisor_programs_present.{n}.numprocs [optional]: Supervisor will start as many instances of this program as named by numprocs

  • supervisor_programs_present.{n}.process_name [optional]: Process name, defaults to %(program_name)s-%(process_num)s when numprocs > 1

  • supervisor_programs_present.{n}.stopsignal [optional]: The signal used to kill the program when a stop is requested

  • supervisor_programs_present.{n}.stopwaitsecs [optional]: The number of seconds to wait for the OS to return a SIGCHILD to supervisord after the program has been sent a stopsignal

  • supervisor_programs_present.{n}.stopasgroup [optional, default false]: If true, the flag causes supervisor to send the stop signal to the whole process group and implies killasgroup is true

  • supervisor_programs_present.{n}.killasgroup [optional, default false]: If true, when resorting to send SIGKILL to the program to terminate it send it to its whole process group instead, taking care of its children as well

  • supervisor_programs_absent [default: {}]: Program definitions (to be removed)

  • supervisor_groups_present [default: {}, see templates/etc/supervisor/conf.d/group.conf.j2]: Group definitions

  • supervisor_groups_present.{n} [required]: Group name

  • supervisor_groups_present.{n}.programs [required]: List of programs

  • supervisor_groups_present.{n}.priority [optional]: A priority number

  • supervisor_groups_absent [default: {}]: Group definitions (to be removed)

Dependencies

None

Recommended

  • ansible-pip (see)

Example

---
- hosts: all
  roles:
    - oefenweb.supervisor
Adding two programs in one group
supervisor_programs_present:
  foo:
    command: 'sleep 10'
    directory: /tmp
    autostart: true
    autorestart: true
    startretries: 3
    stdout_logfile: /tmp/foo.out
    stdout_logfile_maxbytes: 0
    stderr_logfile: /tmp/foo.err
    stderr_logfile_maxbytes: 0
    user: vagrant
    numprocs: 8
    process_name: '%(program_name)s-%(process_num)s'
  bar:
    command: 'sleep 10'
    directory: /tmp
    autostart: true
    autorestart: true
    startretries: 3
    stdout_logfile: /tmp/bar.out
    stdout_logfile_maxbytes: 0
    stderr_logfile: /tmp/bar.err
    stderr_logfile_maxbytes: 0
    user: vboxadd

supervisor_groups_present:
  foo-and-bar:
    programs:
      - foo
      - bar
    priority: 10
Removing a group
supervisor_groups_absent:
  foo-and-bar: {}

License

MIT

Author Information

Mischa ter Smitten

Feedback, bug-reports, requests, ...

Are welcome!

ansible-supervisor's People

Contributors

akondas avatar cmarquezrusso avatar czerasz avatar emielmolenaar avatar huseyinyilmaz avatar jamescarr avatar mvdriel avatar nicgirault avatar noizbuster avatar tersmitten avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ansible-supervisor's Issues

Example Role that depends on ansible-supervisor role

I have been having issues, which might be due to me being new to ansible, but yet I wanted to ask :

I have a playbook, with custom roles.
One of these role install a docker image (just example, could be any package or software).
I would like this same role to ensure that the docker container (or any software) is restarted to use the latest version. This docker container/software is managed by supervisor.

So far I haven't been able to do this, I can only do the supervisorctl restart as part of a playbook. It seems that variables passed to a role don't get passed to the dependencies of that role, but I would expect this to work...

So Is there a way to have :

playbook (pass supervisor_params) -> role (dependency on supervisor role + handler using supervisorctl to restart this software) -> supervisor role (using supervisor_params from playbook)

If so it would be helpful to have an example of this as part of the readme for example : how to use supervisor role as a dependency from another role...

Thanks a lot !

minfds does not work in Ubuntu

Setting minfds value in supervisor.conf does not work in Ubuntu 16.04 (possibly other versions too) if the value is larger than default value of 4096.

We are running supervisor as non-privileged user with custom paths for directories and sockets, but this does not seem to be of relevance to the issue as otherwise the service runs normally. Appropriate open file limits for user and system are raised sufficiently and supervisor version installed from official Ubuntu package works as expected.

The issue seems to be that the version installed with pip when started with systemd does not have some kind of privileges to raise the open file limit for supervisor itself and it's subprocesses. And it fails with error message like this for example:
Error: The minimum number of file descriptors required to run this process is 6000 as per the "minfds" command-line argument or config file setting. The current environment will only allow you to open 6000 file descriptors.

The actual value can be anything more than 4096 and I am using 6000 in the example.

Hopefully something can be done to solve this.

Thank you for your consideration.

Add systemd support

On Ubuntu 16.04 I got the following issue:

TASK [tersmitten.supervisor : start and enable service] ************************
fatal: [test-server-01]: FAILED! => {"changed": false, "failed": true, "msg": "Could not find the requested service \"'supervisor'\": "}

RUNNING HANDLER [tersmitten.supervisor : restart supervisor] *******************

Remove tags in role ?

Hello,

I am currently using tags a lot in my playbooks (partly with 2 tags : deploy and provisionning). The thing is, I want to run the supervisor role only on deploy tag... And as each tasks of this role has a specific tag (such as supervisor-programs-present), it doesn't mix unless I run the playbook with said tag...

On deployment, where I need that * everything * (From supervisor) is ran, especially updating present programs, i can't just run the playbook with the deploy tag... I need to run it with all this roles tags, which is not great.

Unless I'm doing something wrong... ?

supervisord fails on symlink (/var/run) in ansible v1.9.0.1

TASK: [supervisor | create directories] ***************************************
<192.168.33.11> REMOTE_MODULE file group=root state=directory path=/etc/supervisor owner=root
changed: [app-56.dev] => (item=/etc/supervisor/supervisord.conf) => {"changed": true, "gid": 0, "group": "root", "item": "/etc/supervisor/supervisord.conf", "mode": "0755", "owner": "root", "path": "/etc/supervisor", "size": 4096, "state": "directory", "uid": 0}
<192.168.33.11> REMOTE_MODULE file group=root state=directory path=/var/run owner=root
failed: [app-56.dev] => (item=/var/run/supervisor.sock) => {"failed": true, "gid": 0, "group": "root", "item": "/var/run/supervisor.sock", "mode": "0777", "owner": "root", "path": "/var/run", "size": 4, "state": "link", "uid": 0}
msg: /var/run already exists as a link
<192.168.33.11> REMOTE_MODULE file group=root state=directory path=/var/log/supervisor owner=root
changed: [app-56.dev] => (item=/var/log/supervisor/supervisord.log) => {"changed": true, "gid": 0, "group": "root", "item": "/var/log/supervisor/supervisord.log", "mode": "0755", "owner": "root", "path": "/var/log/supervisor", "size": 4096, "state": "directory", "uid": 0}
<192.168.33.11> REMOTE_MODULE file group=root state=directory path=/var/run owner=root
failed: [app-56.dev] => (item=/var/run/supervisord.pid) => {"failed": true, "gid": 0, "group": "root", "item": "/var/run/supervisord.pid", "mode": "0777", "owner": "root", "path": "/var/run", "size": 4, "state": "link", "uid": 0}
msg: /var/run already exists as a link
<192.168.33.11> REMOTE_MODULE file group=root state=directory path=/var/log owner=root
changed: [app-56.dev] => (item=/var/log/supervisor) => {"changed": true, "gid": 0, "group": "root", "item": "/var/log/supervisor", "mode": "0755", "owner": "root", "path": "/var/log", "size": 4096, "state": "directory", "uid": 0}
<192.168.33.11> REMOTE_MODULE file group=root state=directory path=/etc/supervisor/conf.d owner=root
changed: [app-56.dev] => (item=/etc/supervisor/conf.d/*.conf) => {"changed": true, "gid": 0, "group": "root", "item": "/etc/supervisor/conf.d/*.conf", "mode": "0755", "owner": "root", "path": "/etc/supervisor/conf.d", "size": 4096, "state": "directory", "uid": 0}

Releases v2.0.4 & v2.0.5 were not added to Ansible Galaxy

I am using requirements.yml file with this cool supervisor role:

---
- src: tersmitten.supervisor
  version: v2.0.3

But i can't upgrade it to a newer version because there is no such version on Ansible Galaxy - https://galaxy.ansible.com/tersmitten/supervisor/
That is why ansible-galaxy install -r requirements.yml --force return me this error: "The specified version (v2.0.4) of tersmitten.supervisor was not found in the list of available versions"
Please add it when you will have some free time! Thanks!

restarting supervisor fails

The current handler implementation fails "sometimes" because Ansible will not call:

service supervisor restart

but will call something like this instead:

service supervisor stop && service supervisor start

This will fail "sometimes" because supervisor programs (and supervisor itself) are not completely stopped when service supervisor stop returns. Then, when service supervisor start is called immediately, it will fail.

See this post: https://stackoverflow.com/questions/32738415/supervisor-fails-to-restart-half-of-the-time

It can be fixed by rewriting the restart handler this way:

- name: stop supervisor
  service:
    name: supervisor
    state: stopped
  listen: "restart supervisor"

- name: waiting for supervisor to be stopped
  wait_for:
    path: /var/run/supervisord.pid
    state: absent
    sleep: 5
  listen: "restart supervisor"

- shell: ps faux | grep supervisor

- name: start supervisor
  service:
    name: supervisor
    state: started
  listen: "restart supervisor"

Edit: the proposal above does not work as expected yet. I'll edit it when I can confirm it works.

Another solution might be to call service supervisor restart using the Ansible shell module.

If main python version is python3, installation raises an error.

I have python2 and 3 installed on the same machine and I am getting following error:

fatal: [104.131.157.212]: FAILED! => {"changed": false, "cmd": "/usr/local/bin/pip3 install supervisor", "failed": true, "msg": "stdout: Collecting supervisor\n  Using cached supervisor-3.3.1.tar.gz\n    Complete output from command python setup.py egg_info:\n    Supervisor requires Python 2.4 or later but does not work on any version of Python 3.  You are using version 3.6.0 (default, Jan 13 2017, 20:56:47)\n    [GCC 5.4.0 20160609].  Please install using a supported version.\n    \n    ----------------------------------------\n\n:stderr: Command \"python setup.py egg_info\" failed with error code 1 in /tmp/pip-build-0bp95_dc/supervisor/\n"}

I believe solution is to force python2 pip to be used like this:
https://github.com/ScorpionResponse/ansible-supervisord/blob/0a03f94af6a9ceb966b69690f04af9fa5ef623d6/tasks/main.yml#L18

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.