config.vm.box_url = "http://files.vagrantup.com/precise32.box"
config.vm.provision :puppet do |puppet|
puppet.module_path = "puppet_modules"
- puppet.manifest = "vagrant.pp"
+ puppet.manifest_file = "vagrant.pp"
#puppet.options = "--debug --verbose"
end
config.vm.host_name = "example.com"
#
# This script goes through the following steps
# - setup ssh key-based auth on server
-# - setup git and puppet
-# - clone the kite sources from github
+# - rsync the sources
# - run puppet on the server
if ARGV.length != 1 then
`ssh-add`
end
-printf "Setting up public key auth on #{hostname} "
-`ssh-copy-id root@#{hostname}`
-puts "OK"
+def exec_command(command)
+ out = `#{command}`
+ if !$?.success? then
+ puts "FAIL.\n An error happened executing #{command}"
+ puts "Output: #{out}"
+ else
+ puts "OK."
+ end
+end
-srcrepo = "https://github.com/khamidou/kite.git"
-printf "Getting the sources from #{srcrepo} "
+printf "Setting up public key auth on #{hostname}: "
+exec_command("ssh-copy-id root@#{hostname}")
-`ssh root@#{hostname} bash -c "\
-apt-get update;\
-apt-get install -y git puppet;\
-if [ ! -d /root/kite ]; then\
- git clone #{srcrepo} /root/kite;\
-else\
- cd /root/kite; git pull;\
-fi
-"`
+printf "Setting up puppet: "
+exec_command("ssh root@#{hostname} bash -c \"apt-get update && apt-get install -y rsync puppet\"")
-puts "OK"
+printf "Copying the sources: "
+exec_command("rsync -a -f\"- .git/\" ../kite root@#{hostname}:/root/")
-puts "Applying Puppet configuration "
-`ssh root@#{hostname} bash -c "\
- puppet apply /root/kite/manifests/server.pp --modulepath=/root/kite/puppet_modules/\"`
-puts "OK"
+puts "Applying Puppet configuration (this may take some time): "
+exec_command("ssh root@#{hostname} bash -c \"puppet apply /root/kite/manifests/server.pp --modulepath=/root/kite/puppet_modules/\"")
--- /dev/null
+# fabfile for update and deploy
+# it's necessary to specify an host
+from fabric.api import *
+from fabric.contrib.project import rsync_project
+from fabric.contrib.files import upload_template
+import paramiko
+
+remote_user = "karim" # this needs to be a user who can run sudo
+
+paramiko.util.log_to_file("paramiko.log", 10)
+env.hosts = ["dogfood.kiteapp.io"]
+
+PACKAGES = ('rsync', 'puppet')
+
+def setup():
+ local("ssh-copy-id %s@%s" % (remote_user, env.hosts[0]))
+ sudo("apt-get update")
+
+ for package in PACKAGES:
+ sudo('apt-get -y install %s' % package)
+
+ rsync_project("~", "../kite", exclude=[".git/", "*.swp", "*.pyc"])
+ sudo("puppet apply $HOME/kite/manifests/server.pp --modulepath=$HOME/kite/puppet_modules")
-$server_name = "kitebox.dev"
+$server_name = "dogfood.kiteapp.io"
# a class for installing and configuring a basic nginx setup
-class sshd ($server_name) {
+class sshd {
$packages = ["openssh-server"]
package { $packages:
file {"/etc/ssh/sshd_config":
owner => "root",
group => "root",
- content => template('sshd/sshd_config.erb')
- notify => Service['ssh']
+ content => template('sshd/sshd_config.erb'),
+ notify => Service['ssh'],
}
service {'ssh':
enable => true,
hasstatus => true,
hasrestart => true,
- require => Package["openssh-server"]
+ require => Package["openssh-server"],
}
}