Skip to content

Instantly share code, notes, and snippets.

@madAndroid
Created August 9, 2013 08:43
Show Gist options
  • Save madAndroid/6192104 to your computer and use it in GitHub Desktop.
Save madAndroid/6192104 to your computer and use it in GitHub Desktop.
class tw_django::install {
Package {
ensure => installed,
}
package { [ 'python27-mod_wsgi',
'python27-mod_wsgi-debuginfo',
'libjpeg-turbo',
'libjpeg-turbo-devel',
'libpng',
'libpng-devel',
'freetype',
'freetype-devel',
'python-imaging',
]:
}
#### Deprecated in favour of Elasticsearch
# package { [ 'xapian-core',
# 'xapian-bindings',
# 'xapian-bindings-python',
# ]:
# }
}
class tw_django::config {
# Defaults for all files in here:
File {
require => [ Class['tw_django::install'],
Class['tw_python::install'],
Class['tw_django::users']],
owner => 'django',
group => 'admin',
mode => 644
}
Exec {
path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:/usr/local/bin',
# logoutput => on_failure,
logoutput => true,
}
file { '/srv/django/BASELINE':
ensure => directory
}
$venv_wrapper = '/usr/bin/virtualenvwrapper.sh'
exec { 'virtualenv_BASELINE':
# command => '/usr/bin/virtualenv --verbose --no-site-packages /srv/django/BASELINE',
command => "source ${venv_wrapper} && source ~/.bashrc && mkvirtualenv --verbose --no-site-packages BASELINE/",
user => 'django',
provider => 'shell',
unless => 'test -x /srv/django/BASELINE/bin/python2.7',
cwd => '/srv/django/',
require => [ Class['tw_django::install'],
Class['tw_python::install'],
File ['/srv/django/BASELINE'],
Class['tw_django::users']],
}
file {[ '/usr/local/src/tarballs/',
'/usr/local/src/tarballs/pip_download-cache',
]:
ensure => directory,
mode => 777,
}
}
class tw_django::users {
User {
ensure => present,
}
user { 'django':
uid => '110',
managehome => false,
home => '/srv/django',
groups => [ 'admin' ],
shell => '/bin/bash',
password => '$1$I8yQvX2k$mxGV.T1cwZXv43La.l6Jz.',
}
group { 'admin':
gid => '110',
}
File {
owner => 'django',
group => 'admin',
}
file { '/srv/django':
ensure => directory
}
file { '/srv/django/.ssh':
ensure => directory,
mode => 600,
}
$deploy_rsa = hiera('deploy_rsa', undef)
if $deploy_rsa {
file { '/srv/django/.ssh/id_rsa':
mode => 600,
content => $deploy_rsa,
}
}
file { '/srv/django/.ssh/config':
content => 'Host github.com\n\tStrictHostKeyChecking no\n',
require => User [ 'django' ],
}
file { '/srv/django/.bash_profile':
content => '. ~/.bashrc',
require => User [ 'django' ],
}
file { '/srv/django/.bashrc':
content => template('tw_users/virtual_env_bashrc'),
require => User [ 'django' ],
}
}
class tw_django {
include tw_django::install
include tw_django::config
include tw_django::users
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment