From: karim hamidou Date: Thu, 26 Dec 2013 18:22:17 +0000 (+0100) Subject: making progress on deployment to a remote server X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=7d24483df74c9db7bcb35a906c367905e9f8e6ac;p=kite.git making progress on deployment to a remote server --- diff --git a/Vagrantfile b/Vagrantfile index b50487f..3b289c4 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -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" diff --git a/bootstrap.rb b/bootstrap.rb index ea8548a..b7fdef4 100644 --- a/bootstrap.rb +++ b/bootstrap.rb @@ -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 index 0000000..ceda6ea --- /dev/null +++ b/fabfile.py @@ -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") diff --git a/manifests/settings.pp b/manifests/settings.pp index 95f3184..a0faac8 100644 --- a/manifests/settings.pp +++ b/manifests/settings.pp @@ -1 +1 @@ -$server_name = "kitebox.dev" +$server_name = "dogfood.kiteapp.io" diff --git a/puppet_modules/sshd/manifests/init.pp b/puppet_modules/sshd/manifests/init.pp index 8811468..20c7b58 100644 --- a/puppet_modules/sshd/manifests/init.pp +++ b/puppet_modules/sshd/manifests/init.pp @@ -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"], } }