Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 2095b50c38
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 62 lines (51 sloc) 1.516 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
package :deploy do
  requires :deploy_user, :deploy_id_rsa, :deploy_id_rsa_pub, :deploy_sudoers
end

package :deploy_user do
  noop do
    pre :install, 'groupadd deploy'
    pre :install, 'useradd -m -g deploy deploy'
    pre :install, 'mkdir -p /home/deploy/.ssh'
    pre :install, 'touch /home/deploy/.ssh/id_rsa'
    pre :install, 'touch /home/deploy/.ssh/id_rsa.pub'
    pre :install, 'touch /home/deploy/.ssh/known_hosts'
    pre :install, 'cp /root/.ssh/authorized_keys /home/deploy/.ssh/authorized_keys'
    pre :install, 'chown -R deploy:deploy /home/deploy/.ssh/'
    pre :install, 'chmod 0600 /home/deploy/.ssh/id_rsa'
  end

  verify do
    has_file '/home/deploy/.ssh/id_rsa'
    has_file '/home/deploy/.ssh/authorized_keys'
  end
end

# generate keys to use with your "deploy" user(s), see ssh.rb for an example
package :deploy_id_rsa do
  config_file = '/home/deploy/.ssh/id_rsa'
  config_text = %q[
-----BEGIN RSA PRIVATE KEY----- [etc...]
].lstrip

  push_text config_text, config_file

  verify do
    file_contains config_file, "..."
  end
end

package :deploy_id_rsa_pub do
  config_file = '/home/deploy/.ssh/id_rsa.pub'
  config_text = %q[
ssh-rsa [etc...]
].lstrip

  push_text config_text, config_file

  verify do
    file_contains config_file, "..."
  end
end

package :deploy_sudoers do
  config_file = '/etc/sudoers'
  config_text = %q[
deploy ALL=NOPASSWD: ALL
].lstrip

  push_text config_text, config_file

  verify do
    file_contains config_file, "deploy ALL=NOPASSWD: ALL"
  end
end
Something went wrong with that request. Please try again.