Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Installs/Configures a deployment user
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
attributes
recipes
templates/default
.gitignore
CHANGELOG.md
LICENSE
README.md
metadata.rb

README.md

deployer

Set up a deploy user with the necessary ssh authorized keys. This is great for working with Capistrano where you need to deploy code, but it doesn't make sense for each user to have a shell account.

This cookbook will create a deployment user (deploy by default) with passwordless-sudo permissions for deployment. As a result, it is highly recommended that you disable password authentication and only support key-based authentication.

Requirements

At this time, you must have a Unix-based machine. This could easily be adapted for Windows machines. Please submit a Pull Request if you wish to add Windows support.

Configuration

There are three attributes that you can override in your node:

  • node['deployer']['user'] - the name of the deploy user (default: deploy)
  • node['deployer']['group'] - the group for the deploy user (default: deploy)
  • node['deployer']['home'] - the home directory for the deploy user (default: /home/deploy)

Adding keys

There are two ways to add keys to the deployer. If you're using the opscode users cookbook, deployer easily integrates with the existing :users data_bags. Simply add the deploy key to an existing user:

// data_bags/users/svargo.json
{
  "id": "svargo",
  "uid": "1000",
  "deploy": "any",
  ssh_keys: [...]
}

or specify an array of servers or IP addresses that the user should be allowed to deploy to:

// data_bags/users/svargo.json
{
  "id": "svargo",
  "uid": "1000",
  "deploy": [
    "1.2.3.4",
    "mynode.example.com"
  ],
  ssh_keys: [...]
}

If you're not using the users cookbook, or if you have a conflict, you can use the :deployers data_bag instead:

Create the data_bag:

knife data bag create deployers

Create a deployer:

// data_bags/deployers/svargo.json
{
  "id": "svargo",
  "deploy": [
    "1.2.3.4",
    "mynode.example.com"
  ],
  ssh_keys: [...]
}

The same options apply to the deploy key as above. Note: this will not actually create system user accounts.

Usage

If you're using Berkshelf, just add deployer to your Berksfile:

cookbook 'deployer'

Otherwise, install the cookbook from the community site:

knife cookbook site install deployer

Have any other cookbooks depend on deployer by editing editing the metadata.rb for your cookbook.

depends 'deployer'

Once you have the cookbook installed, add it to your node's run_list or role:

"run_list": [
  "recipe[deployer]"
]

And override attributes as necessary:

# mynode.example.com
"override_attributes": {
  "deployer": {
    "user": "apache",
    "group": "apache",
    "home": "/usr/bin/false"
  }
},
"run_list": [
  "recipe[deployer]"
]

Contributing

  1. Fork the project
  2. Create a feature branch corresponding to you change
  3. Commit and test thoroughly
  4. Create a Pull Request on github
    • ensure you add a detailed description of your changes

License and Authors

Copyright 2012, Seth Vargo

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License

Something went wrong with that request. Please try again.