diff --git a/puppet/bootstrap.sh b/puppet/bootstrap.sh index 7a1ab09..5d3aca4 100644 --- a/puppet/bootstrap.sh +++ b/puppet/bootstrap.sh @@ -1,3 +1,8 @@ #!/bin/bash -puppet module list | grep puppetlabs-vcsrepo || puppet module install puppetlabs/vcsrepo +puppet_install () { + puppet module list | grep $1 || puppet module install $1 +} + +puppet_install puppetlabs-vcsrepo +puppet_install stankevich-python diff --git a/puppet/manifests/site.pp b/puppet/manifests/site.pp index 772b98c..1eaba09 100644 --- a/puppet/manifests/site.pp +++ b/puppet/manifests/site.pp @@ -3,17 +3,24 @@ group { 'sigi': } user { 'sigi': - ensure => 'present', - system => 'true', - gid => 'sigi', + ensure => 'present', + system => true, + gid => 'sigi', require => Group['sigi'] } -package { [ 'git', 'tree', 'python-pip', 'python-dev', 'python-psycopg2', - 'supervisor', 'memcached', ]: } +package { [ 'git', 'tree', 'python-psycopg2', 'supervisor', 'memcached', ]: } $sigi_dir = '/srv/sigi' +vcsrepo { $sigi_dir: + ensure => latest, + provider => git, + source => 'https://github.com/interlegis/sigi.git', + revision => 'producao', + require => Package['git'], +} + file { [ '/var/log/sigi', '/var/run/sigi', @@ -21,9 +28,10 @@ file { [ "${sigi_dir}/media/apps", "${sigi_dir}/media/apps/metas", ]: - ensure => 'directory', - owner => 'sigi', - group => 'sigi', + ensure => 'directory', + owner => 'sigi', + group => 'sigi', + require => Vcsrepo[$sigi_dir], } # TODO A pasta "${sigi_dir}/media" deve ser compartilhada entre instancias de cluster @@ -32,12 +40,33 @@ file { '/var/log/sigi/sigi-supervisor.log': ensure => file, } -vcsrepo { $sigi_dir: - ensure => latest, - provider => git, - source => 'https://github.com/interlegis/sigi.git', - revision => 'producao', - require => Package['git'], +########################################################################### +# PYTHON + +if !defined(Class['python']) { + class { 'python': + version => 'system', + dev => true, + virtualenv => true, + pip => true, + } +} + +$python_ldap_deps = ['libldap2-dev', 'libsasl2-dev', 'libssl-dev'] + +package { $python_ldap_deps: } + +$sigi_venv_dir = '/srv/.virtualenvs/sigi' + +file { ['/srv/.virtualenvs',]: + ensure => 'directory', +} + +python::virtualenv { $sigi_venv_dir : + requirements => "${sigi_dir}/requirements/producao.txt", + require => [ File['/srv/.virtualenvs'], + Vcsrepo[$sigi_dir], + Package[$python_ldap_deps] ] } ###########################################################################