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 for Puppet 3 and rely on puppet-python #1

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
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
18 changes: 4 additions & 14 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,16 @@ celery for puppet
=================
This installs and configures `Celery`_.

This is a `puppet`_ module for using Python's `pip`_. Puppet has a
built-in pip provider, but it's implementation leaves out a few pieces:

* No ability to install from requirements file.
* No ability to add extra arguments
* No support for using mirrors or specifying alternate indexes.

This module fixes this.


Usage
-----
Make sure this module is available by adding this repository's contents
in a directory called ``celery`` inside your Puppet's ``moduledir``.
It also requires the `puppet-pip`_ module as well.
It also requires the `puppet-python`_ module as well.


Bootstrapping RabbitMQ
""""""""""""""""""""""
If you need to bootstrap RabbitMQ (note that this requires that you have
`this version`_ of `puppetlabs-rabbitmq`_ to run on RabbitMQ 2.6)::
If you need to bootstrap RabbitMQ ::

class { "celery::rabbitmq": }

Expand Down Expand Up @@ -57,9 +46,10 @@ Configuration


.. _Celery: http://celeryproject.org/
.. _puppet-python: https://github.com/stankevich/puppet-python
.. _distribute: http://packages.python.org/distribute/
.. _pip: http://www.pip-installer.org/
.. _puppet: http://puppetlabs.com/
.. _puppet-pip: https://github.com/armstrong/puppet-pip
.. _puppetlabs-rabbitmq: https://github.com/puppetlabs/puppetlabs-rabbitmq/
.. _this version: https://github.com/puppetlabs/puppetlabs-rabbitmq/pull/8
.. _this version: https://github.com/puppetlabs/puppetlabs-rabbitmq/pull/8
81 changes: 28 additions & 53 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@


class celery::rabbitmq($user="some_user",
$vhost="some_vhost",
$password="CHANGEME") {

class { 'rabbitmq::repo::apt':
pin => 900,
before => Class['rabbitmq::server']
}

class { 'rabbitmq::server':
delete_guest_user => true,
# rabbitmq module needs this
package {'curl':
ensure => present,
} ->
class { '::rabbitmq':
package_apt_pin => 900,
# use this for the time being remove once working
delete_guest_user => false,
}

rabbitmq_user { "$user":
rabbitmq_user { $user:
admin => true,
password => $password,
provider => 'rabbitmqctl',
Expand All @@ -32,27 +31,26 @@
}
}

class celery::server($requirements="/tmp/celery-requirements.txt",
class celery::server($venv="system-wide",
$proroot="",
$venvowner="root",
$requirements="/tmp/celery-requirements.txt",
$requirements_template="celery/requirements.txt",
$initd_template="celery/init.d.sh",
$config_template="celery/celeryconfig.py",
$defaults_template="celery/defaults.sh",
$defaults_template="celery/celery_defaults.sh.erb",
$broker_user="some_user",
$broker_vhost="some_vhost",
$broker_password="CHANGEME",
$broker_host="localhost",
$broker_port="5672") {
$broker_port="5672",
$user="celery",
$usergroup="celery") {

file { $requirements:
ensure => "present",
content => template($requirements_template),
}

pip::install {"celery":
requirements => $requirements,
require => [Exec["pip::bootstrapped"], File[$requirements],],
}

file { "/etc/default/celeryd":
ensure => "present",
content => template($defaults_template),
Expand All @@ -64,22 +62,17 @@
mode => "0755",
}

user { "celery":
user { $user:
ensure => "present",
}
groups => $usergroup
} ->

file { "/var/celery":
ensure => "directory",
owner => "celery",
require => User["celery"],
}

file { "/var/celery/celeryconfig.py":
ensure => "present",
content => template($config_template),
require => File["/var/celery"],
}

file { "/var/log/celery":
ensure => "directory",
owner => "celery",
Expand All @@ -90,36 +83,18 @@
owner => "celery",
}

python::requirements { $requirements:
virtualenv => $venv,
owner => $venvowner,
group => $venvowner,
} ->
service { "celeryd":
hasrestart => true,
ensure => "running",
require => [File["/var/celery/celeryconfig.py"],
File["/etc/init.d/celeryd"],
Exec["pip-celery"],
require => [File["/etc/init.d/celeryd"],
File["/etc/default/celeryd"],
File["/var/log/celery"],
File["/var/run/celery"],
Class["rabbitmq::service"], ],
}
}

class celery::django($requirements="/tmp/celery-django-requirements.txt",
$requirements_template="celery/django-requirements.txt",
$initd_template="celery/init.d.sh",
$config_template="celery/celeryconfig.py",
$defaults_template="celery/defaults.sh",
$broker_user="some_user",
$broker_vhost="some_vhost",
$broker_password="CHANGEME",
$broker_host="localhost",
$broker_port="5672") {

file { $requirements:
ensure => "present",
content => template($requirements_template),
}

pip::install {"celery":
requirements => $requirements,
require => [Exec["pip::bootstrapped"], File[$requirements],],
}

}
25 changes: 25 additions & 0 deletions templates/celery_defaults.sh.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# changed and simplfied for celery version 3.1 and larger

# Name of nodes to start, here we have a single node
CELERYD_NODES="w1"
# or we could have three nodes:

# Where to chdir at start.
CELERYD_CHDIR="<%= @proroot %>"

# Python interpreter from environment.
ENV_PYTHON="<%= @venv %>/bin/python"

# Use local env copy of celery
CELERY_BIN="<%= @venv %>/bin/celery"

# Extra arguments to celeryd
CELERYD_OPTS="--concurrency=8" #<% if @django_name != '' %> -A <%= @django_name%><% end %>"

# %n will be replaced with the nodename.
CELERYD_LOG_FILE="/var/log/celery/%n.log"
CELERYD_PID_FILE="/var/run/celery/%n.pid"

# Workers should run as an unprivileged user.
CELERYD_USER="celery"
CELERYD_GROUP="celery"
10 changes: 5 additions & 5 deletions templates/celeryconfig.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BROKER_HOST = "<%= broker_host %>"
BROKER_PORT = <%= broker_port %>
BROKER_USER = "<%= broker_user %>"
BROKER_PASSWORD = "<%= broker_password %>"
BROKER_VHOST = "<%= broker_vhost %>"
BROKER_HOST = "<%= @broker_host %>"
BROKER_PORT = <%= @broker_port %>
BROKER_USER = "<%= @broker_user %>"
BROKER_PASSWORD = "<%= @broker_password %>"
BROKER_VHOST = "<%= @broker_vhost %>"
2 changes: 1 addition & 1 deletion templates/defaults.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ CELERYD_PID_FILE="/var/run/celery/%n.pid"

# Workers should run as an unprivileged user.
CELERYD_USER="celery"
CELERYD_GROUP="celery"
CELERYD_GROUP="celery"
8 changes: 0 additions & 8 deletions templates/django-requirements.txt

This file was deleted.

Loading