]> khamidou — GitHub mirrors - kite.git/commitdiff
making progress on deployment to a remote server
authorkarim hamidou <khamidou@gmail.com>
Thu, 26 Dec 2013 18:22:17 +0000 (19:22 +0100)
committerkarim hamidou <khamidou@gmail.com>
Thu, 26 Dec 2013 18:22:17 +0000 (19:22 +0100)
Vagrantfile
bootstrap.rb
fabfile.py [new file with mode: 0644]
manifests/settings.pp
puppet_modules/sshd/manifests/init.pp

index b50487fdcfa79526d4b4434194af2513b41de813..3b289c4827129e8ad2f1852d88e4f79230fdd448 100644 (file)
@@ -3,7 +3,7 @@ Vagrant.configure("2") do |config|
     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"
index ea8548a1b1a507be0f657bc662400ac5916f937f..b7fdef410c4f8060bd0a58ce035cf74f3348b5ad 100644 (file)
@@ -3,8 +3,7 @@
 #
 # 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
@@ -18,26 +17,24 @@ if !ENV["SSH_AGENT_PID"] 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/\"")
diff --git a/fabfile.py b/fabfile.py
new file mode 100644 (file)
index 0000000..ceda6ea
--- /dev/null
@@ -0,0 +1,23 @@
+# 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")
index 95f31840fa8f7777ffbd7ddb0e7d3cbc531e5e39..a0faac88b21d4af0a995457c59bbb972a87187ad 100644 (file)
@@ -1 +1 @@
-$server_name = "kitebox.dev"
+$server_name = "dogfood.kiteapp.io"
index 88114682c9ef2acce4a73ff2faabdede1a98a764..20c7b581b45da3aaae285e24322dab98566d6412 100644 (file)
@@ -1,6 +1,6 @@
 # a class for installing and configuring a basic nginx setup
 
-class sshd ($server_name) {
+class sshd {
     $packages = ["openssh-server"]
 
     package { $packages:
@@ -10,8 +10,8 @@ class sshd ($server_name) {
     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':
@@ -19,6 +19,6 @@ class sshd ($server_name) {
         enable => true,
         hasstatus => true,
         hasrestart => true,
-        require => Package["openssh-server"]
+        require => Package["openssh-server"],
     }
 }