Browse Source

Merge pull request #135 from kasperisager/master

Thats pretty awesome.
Rafał Pitoń 12 years ago
parent
commit
9d5d8fae4b
6 changed files with 131 additions and 12 deletions
  1. 9 1
      .gitignore
  2. 3 0
      .gitmodules
  3. 73 0
      Vagrantfile
  4. 11 11
      deployment/settings.py
  5. 34 0
      vagrant/puppet/manifests/site.pp
  6. 1 0
      vagrant/puppet/modules/python

+ 9 - 1
.gitignore

@@ -190,4 +190,12 @@ yaml/**
 dev-manage.py
 path.py
 !templates/debug_toolbar/panels/acl.html
-templates/debug_toolbar/**
+templates/debug_toolbar/**
+
+
+############
+## Vagrant
+############
+
+.vagrant
+database.db

+ 3 - 0
.gitmodules

@@ -0,0 +1,3 @@
+[submodule "vagrant/puppet/modules/python"]
+	path = vagrant/puppet/modules/python
+	url = https://github.com/kasperisager/puppet-python.git

+ 73 - 0
Vagrantfile

@@ -0,0 +1,73 @@
+#!/usr/bin/env ruby
+
+Vagrant.configure("2") do |config|
+  # All Vagrant configuration is done here. The most common configuration
+  # options are documented and commented below. For a complete reference,
+  # please see the online documentation at vagrantup.com.
+
+  # Every Vagrant virtual environment requires a box to build off of.
+  config.vm.box = "precise32"
+
+  # The url from where the 'config.vm.box' box will be fetched if it
+  # doesn't already exist on the user's system.
+  config.vm.box_url = "http://files.vagrantup.com/precise32.box"
+
+  # Create a forwarded port mapping which allows access to a specific port
+  # within the machine from a port on the host machine. In the example below,
+  # accessing "localhost:8080" will access port 80 on the guest machine.
+  # config.vm.network :forwarded_port, guest: 80, host: 8080
+
+  # Create a private network, which allows host-only access to the machine
+  # using a specific IP.
+  config.vm.network :private_network, ip: "192.168.33.10"
+
+  # Create a public network, which generally matched to bridged network.
+  # Bridged networks make the machine appear as another physical device on
+  # your network.
+  # config.vm.network :public_network
+
+  # Share an additional folder to the guest VM. The first argument is
+  # the path on the host to the actual folder. The second argument is
+  # the path on the guest to mount the folder. And the optional third
+  # argument is a set of non-required options.
+  # config.vm.synced_folder "../data", "/vagrant_data"
+
+  # Provider-specific configuration so you can fine-tune various
+  # backing providers for Vagrant. These expose provider-specific options.
+  # Example for VirtualBox:
+  #
+  # config.vm.provider :virtualbox do |vb|
+  #   # Don't boot with headless mode
+  #   vb.gui = true
+  #
+  #   # Use VBoxManage to customize the VM. For example to change memory:
+  #   vb.customize ["modifyvm", :id, "--memory", "1024"]
+  # end
+  #
+  # View the documentation for the provider you're using for more
+  # information on available options.
+
+  # Enable provisioning with Puppet stand alone.  Puppet manifests
+  # are contained in a directory path relative to this Vagrantfile.
+  # You will need to create the manifests directory and a manifest in
+  # the file base.pp in the manifests_path directory.
+  #
+  # An example Puppet manifest to provision the message of the day:
+  #
+  # # group { "puppet":
+  # #   ensure => "present",
+  # # }
+  # #
+  # # File { owner => 0, group => 0, mode => 0644 }
+  # #
+  # # file { '/etc/motd':
+  # #   content => "Welcome to your Vagrant-built virtual machine!
+  # #               Managed by Puppet.\n"
+  # # }
+  #
+  config.vm.provision :puppet do |puppet|
+    puppet.manifests_path = "vagrant/puppet/manifests"
+    puppet.module_path    = "vagrant/puppet/modules"
+    puppet.manifest_file  = "site.pp"
+  end
+end

+ 11 - 11
deployment/settings.py

@@ -23,13 +23,13 @@ ADMINS = ()
 # NEVER EVER SHARE THIS KEY WITH ANYBODY!
 # Make it messed up and long, this is example of good secret key:
 # yaobeifl1a6hf&3)^uc#^vlu1ud7xp^+*c5zoq*tf)fvs#*o$#
-SECRET_KEY = ''
+SECRET_KEY = 'secret-key'
 
 # Database connection
 DATABASES = {
     'default': {
-        'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
-        'NAME': '', # Or path to database file if using sqlite3.
+        'ENGINE': 'django.db.backends.sqlite3', # Can be either 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
+        'NAME': 'database.db', # Name of the database or the path to the database file if using sqlite3.
         'USER': '', # Not used with sqlite3.
         'PASSWORD': '', # Not used with sqlite3.
         'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
@@ -44,14 +44,14 @@ DATABASES = {
 CACHES = {
     'default': {
         'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
-   }
+    }
 }
 
 # Cookies configuration
-COOKIES_DOMAIN = '' # For example cookie domain for "www.mysite.com" or "forum.mysite.com" is ".mysite.com"
-COOKIES_PATH = ''
+COOKIES_DOMAIN = '192.168.33.10' # E.g. a cookie domain for "www.mysite.com" or "forum.mysite.com" is ".mysite.com"
+COOKIES_PATH = '/'
 COOKIES_PREFIX = '' # Allows you to avoid cookies collisions with other applications.
-COOKIES_SECURE = False # Set this to true if AND ONLY IF you are using SSL on your forum.
+COOKIES_SECURE = False # Set this to true if, AND ONLY IF, you are using SSL on your forum.
 
 # Sessions configuration
 SESSION_LIFETIME = 3600 # Number of seconds since last request after which session is marked as expired.
@@ -72,7 +72,7 @@ LANGUAGE_CODE = 'en_US'
 # Absolute filesystem path to the directory that will hold user-uploaded files.
 # Always use forward slashes, even on Windows.
 # Example: "/home/media/media.lawrence.com/media/"
-MEDIA_ROOT = ''
+MEDIA_ROOT = '/vagrant/media/'
 
 # URL that handles the media served from MEDIA_ROOT. Make sure to use a
 # trailing slash.
@@ -96,7 +96,7 @@ STATICFILES_DIRS = (
     # Always use forward slashes, even on Windows.
     # Don't forget to use absolute paths, not relative paths.
     # Make sure directory containing avatars is located under first directory on list
-    '/static',
+    '/vagrant/static/',
 )
 
 # E-mail host
@@ -127,7 +127,7 @@ TEMPLATE_DIRS = (
     # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
     # Always use forward slashes, even on Windows.
     # Don't forget to use absolute paths, not relative paths.
-    '/templates'
+    '/vagrant/templates'
 )
 
 # List of installed themes
@@ -149,4 +149,4 @@ if 'test' in sys.argv:
         SECRET_KEY = 'SECRET4TESTS'
     DATABASES['default'] = {'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'db4testing'}
     CACHES['default'] = {'BACKEND': 'django.core.cache.backends.dummy.DummyCache'}
-    SKIP_SOUTH_TESTS = True
+    SKIP_SOUTH_TESTS = True

+ 34 - 0
vagrant/puppet/manifests/site.pp

@@ -0,0 +1,34 @@
+# Class: site
+#
+#
+class site
+{
+  $login    = "Admin"
+  $email    = "admin@example.com"
+  $password = "password"
+
+  class { "python":
+    version => "system",
+    dev     => true
+  } ->
+
+  python::requirements { "/vagrant/requirements.txt":
+    virtualenv => "system"
+  } ->
+
+  exec { "startmisago":
+    command => "python manage.py startmisago",
+    path    => "/usr/bin:/usr/sbin:/bin:/usr/local/bin",
+    cwd     => "/vagrant"
+  } ->
+
+  exec { "adduser":
+    command => "python manage.py adduser ${login} ${email} ${password} --admin \
+               && /bin/echo 'admin_user_created' >> /etc/puppet/puppet_history",
+    unless  => "/bin/grep 'admin_user_created' /etc/puppet/puppet_history",
+    path    => "/usr/bin:/usr/sbin:/bin:/usr/local/bin",
+    cwd     => "/vagrant"
+  }
+}
+
+include site

+ 1 - 0
vagrant/puppet/modules/python

@@ -0,0 +1 @@
+Subproject commit 0f02d6c2d5f00f2eb4f5cccdc8801622a6c1e050