Skip to content

Commit

Permalink
Merge pull request #13 from dave-shawley/add-server-lwrp
Browse files Browse the repository at this point in the history
Add LWRPs.
  • Loading branch information
dave-shawley committed Dec 7, 2014
2 parents efe4d55 + e339fd5 commit 2709270
Show file tree
Hide file tree
Showing 23 changed files with 643 additions and 76 deletions.
5 changes: 4 additions & 1 deletion .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ platforms:
suites:
- name: server
run_list:
- "recipe[devpi::nginx]"
- "recipe[devpi::server]"
- "recipe[devpi::nginx]"
- "recipe[supervisor-daemon::install]"
attributes: {}
- name: client
run_list:
- "recipe[devpi::client]"
attributes: {}
- name: lwrp
run_list:
- "recipe[lwrp-test]"
1 change: 1 addition & 0 deletions Berksfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ cookbook 'nginx'

group :testing do
cookbook 'supervisor'
cookbook 'lwrp-test', path: 'test/cookbooks/lwrp-test'
cookbook 'supervisor-daemon', path: 'test/cookbooks/supervisor-daemon'
end
4 changes: 4 additions & 0 deletions Berksfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ DEPENDENCIES
devpi
path: .
metadata: true
lwrp-test
path: test/cookbooks/lwrp-test
nginx
supervisor
supervisor-daemon
Expand All @@ -16,6 +18,8 @@ GRAPH
devpi (2.0.0)
nginx (>= 0.0.0)
python (>= 0.0.0)
lwrp-test (0.1.0)
devpi (>= 0.0.0)
nginx (2.7.4)
apt (~> 2.2)
bluepill (~> 2.3)
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ This file is used to list changes made in each version of the devpi cookbook.
- Fully embrace ChefDK for development.
- Switch attribute access from symbols to strings.
- Remove runit and supervisor recipes.
- Add `devpi_server` and `devpi_nginx_site` LWRPs.
- Removed nginx site template in lieu of letting the *devpi-server* utility
generate one for us. That is precisely what the `devpi_nginx_site` LWRP
does.
- Remove log directory management. The generated nginx configuration does
not provide a means to configure this.

## 1.1.0 (Never Released)
- Add the *client* recipe that installs the `devpi` command line utility.
Expand Down
9 changes: 5 additions & 4 deletions FEATURES.org
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ this file is -- /a list of things that need do'ing/.
[ ] +import LWRP+
[ ] +export LWRP+

* Version 2.0 [4/6]
* Version 2.0 [7/7]
[X] Remove supporting recipes (e.g., supervisor, runit)
[ ] Use =devpi-server --gen-config= to generate nginx configuration
[ ] Convert server recipe into LWRP
[X] Use =devpi-server --gen-config= to generate nginx configuration
[X] Convert server recipe into LWRP
[X] Switch to ChefDK
[X] Appease all style checks
[X] Remove git-flow nonsense
[X] Remove git-flow nonsense
[X] Add nginx configuration LWRP
187 changes: 162 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
devpi Cookbook
==============
# devpi Cookbook

This cookbook installs and configures a devpi server. [Devpi server]
is a PyPI-compatible Python Index server that acts as both a freestanding
Python Index as well as a pull-through cache of the official Python Package
Index.

[devpi server]: http://doc.devpi.net/latest/

Requirements
------------
## Requirements

* **Python Versions**: Python 2.6 amd 2.7
* **Operating Systems**: Debian/Ubuntu, Enterprise Linux/CentOS

Attributes
----------
## Attributes

<table>
<tr>
Expand Down Expand Up @@ -63,16 +62,10 @@ Attributes
<td>Install Python virtual environment here</td>
<td>/opt/devpi-server</td>
</tr>
<tr>
<th><tt>['devpiserver']['log_directory']</tt></th>
<td>Path</td>
<td>Write server logs here</td>
<td>/var/log/devpi-server</td>
</tr>
</table>

Usage
-----
## Usage

Add the **devpi::server** recipe to your `run_list` to install [devpi server]
into a Python virtual environment created just for it. The **devpi::nginx**
recipe creates an nginx site configured to expose the server on port 80.
Expand All @@ -82,24 +75,168 @@ a virtual directory. The **devpi::server** recipe does not install the
command line client so you have to apply this recipe if you want the client
installed alongside the server.

### Recipes

#### devpi::server
### devpi::server
Include this recipe in the `run_list` to install the devpi server. It
will also create the daemon user and administrative group if necessary.

#### devpi::nginx
### devpi::nginx
Include this recipe to expose the devpi-server using [nginx] as a
front-end server.

#### devpi::client
### devpi::client
Include this recipe to install the devpi command-line client. This will
create a workstation from which you can manage a devpi-server installation.

[nginx]: http://nginx.org/

Contributing
------------
### devpi_server
This resource defines a complete installation of the [devpi server]. It will
create the Python virtual environment, install the packages/users/groups
needed to run the server, and even generate an nginx site definition for you.

#### Syntax
The simplest usage of the **devpi_server** resource is a single line that
identifies where the server instance should be installed into:

devpi_server '/opt/devpi'

If you want to control more aspects of the installed server, you do so
using the normal syntax:

devpi_server '/opt/devpi' do
admin_group 'admins'
port 6543
nginx_site 'devpi'
end

#### Actions
<table>
<tr><th>Action</th><th>Description</th></tr>
<tr>
<td><tt>:create</tt></td>
<td>Default. Installs a new devpi server instance into the named
directory.</td>
</tr>
<tr>
<td><tt>:delete</tt></td>
<td>Removes an existing server instance.</td>
</tr>
</table>

#### Attributes
<table>
<tr><th>Attribute</th><th>Description</th></tr>
<tr>
<td><tt>directory</tt></td>
<td>Install the devpi server into this directory. This will
be used as the root of the Python virtual environment created
for the server. If a virtual environment already exists, then
it will be used as-is. <b>This is the name attribute for this
resource.</b></td>
</tr>
<tr>
<td><tt>daemon_user</tt></td>
<td>The user that will run the daemon. This is used to set the
appropriate permissions on the data directories. The default
value for this attribute is <i>devpi</i>.</td>
</tr>
<tr>
<td><tt>admin_group</tt></td>
<td>The user group responsible for managing the devpi server. This
is used to set the appropriate permissions on the devpi related
directories. The default value for this attribute is also
<i>devpi</i>.</td>
</tr>
<tr>
<td><tt>port</tt></td>
<td>The port that the devpi server instance will listen on. The
default value for this attribute is <i>3141</i>.</td>
</tr>
<tr>
<td><tt>data_directory</tt></td>
<td>The directory used by the server to store the repository data.
The default value for this attribute is a sub-directory of
the server root named <i>data</i>.</td>
</tr>
<tr>
<td><tt>nginx_site</tt></td>
<td>If this attribute is set, then a new nginx site is created
with the specified name. It will be configured as a front-end
for the installed server.</td>
</tr>
<tr>
<td><tt>version</tt></td>
<td>If this attribute is set, then this version of the devpi
package will be installed. If this is omitted or set to
<tt>nil</tt>, then the most recent package will be installed.</td>
</tr>
</table>

### devpi\_nginx_site
This resource uses the `devpi-server` command to generate an nginx site for
the server and optionally enable it.

#### Syntax
The root directory of the server installation is the only required parameter.

devpi_nginx_site 'devpi' do
directory '/opt/devpi'
end

This will create and enable an nginx site named *devpi* for the server that
is installed in the */opt/devpi* virtual environment.

#### Actions
<table>
<tr><th>Action</th><th>Description</th></tr>
<tr>
<td><tt>:create</tt></td>
<td>Generate and optionally install the nginx configuration.</td>
</tr>
</table>

#### Attributes
<table>
<tr><th>Attribute</th><th>Description</th></tr>
<tr>
<td><tt>directory</tt></td>
<td>Generate the site for the devpi server installed in this
directory.</td>
</tr>
<tr>
<td><tt>daemon_user</tt></td>
<td>The user that will run the daemon. The default value for this
attribute is <i>devpi</i>.</td>
</tr>
<tr>
<td><tt>admin_group</tt></td>
<td>The user group responsible for managing the devpi server.
The default value for this attribute is <i>devpi</i>.</td>
</tr>
<tr>
<td><tt>port</tt></td>
<td>The port that the devpi server listens on. The
default value for this attribute is <i>3141</i>.</td>
</tr>
<tr>
<td><tt>data_directory</tt></td>
<td>The directory used by the server to store the repository data.
The default value for this attribute is a sub-directory of
the server root named <i>data</i>.</td>
</tr>
<tr>
<td><tt>enable</tt></td>
<td>Boolean flag that controls whether the site is enabled or not.
By default, the site will be enabled.</td>
</tr>
</table>

### Vagrantfile
Though not a usage of the cookbook per-se, the *Vagrantfile* can be used
to start a stand-alone devpi-server instance. **vagrant up** will start
the server and make it available at <http://172.16.0.11/>.

## Contributing

1. Fork the repository on Github
2. Create a new branch from `master` to hold your changes.
Expand All @@ -120,13 +257,13 @@ Contributing

*HACKING.md* contains additional details about developing in this cookbook.

License and Authors
-------------------
#### Cookbook Authors:
## License and Authors

### Cookbook Authors:

* Dave Shawley

#### License:
### License:

Copyright (C) 2013-2014 Dave Shawley

Expand Down
9 changes: 4 additions & 5 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
Vagrant.configure('2') do |config|

config.vm.hostname = 'devpi-berkshelf'
config.vm.box = 'ubuntu-14.04'
config.vm.box_url = 'https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef-provisionerless.box'

config.vm.box = 'ubuntu/trusty64'
config.vm.network :private_network, ip: '172.16.0.11'

config.berkshelf.berksfile_path = './Berksfile'
Expand All @@ -17,9 +15,10 @@ Vagrant.configure('2') do |config|
chef.json = {}
chef.run_list = [
'recipe[apt]',
'recipe[devpi::runit]',
'recipe[devpi::server]',
'recipe[devpi::nginx]',
'recipe[devpi::client]'
'recipe[devpi::client]',
'recipe[supervisor-daemon::install]'
]
end

Expand Down
1 change: 0 additions & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

default['devpiserver']['virtualenv'] = '/opt/devpi-server'
default['devpiserver']['server_root'] = '/opt/devpi-server/data'
default['devpiserver']['log_directory'] = '/var/log/devpi-server'
default['devpiserver']['server_port'] = 3141
default['devpiserver']['version'] = nil # install latest
default['devpiserver']['daemon_user'] = 'devpi'
Expand Down
Loading

0 comments on commit 2709270

Please sign in to comment.