Index: modules/discourse_docker/manifests/init.pp |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/modules/discourse_docker/manifests/init.pp |
@@ -0,0 +1,88 @@ |
+class discourse_docker( |
+ $domain, |
f.lopez
2017/01/03 20:22:45
we need to set default values for these variables,
|
+ $certificate, |
+ $private_key, |
f.lopez
2017/01/03 20:22:45
we might want to add a $ensure variable so we can
|
+ $site_settings, |
+ $is_default = false, |
+ $admins = hiera('discourse_docker::admins', []) |
+) { |
+ |
+ apt::source {'docker': |
+ before => Package['docker-engine'], |
+ location => 'https://apt.dockerproject.org/repo', |
+ release => downcase("$::osfamily-$::lsbdistcodename"), |
+ include_src => false, |
+ key => '58118E89F3A912897C070ADBF76221572C52609D', |
+ key_server => 'hkp://ha.pool.sks-keyservers.net:80', |
+ } |
+ |
+ package {'git': |
+ ensure => present, |
+ } |
+ |
f.lopez
2017/01/03 20:22:45
for these packages we can use the `ensure_resource
|
+ package {'docker-engine': |
+ ensure => 'present', |
+ require => Apt::Source['docker'], |
+ } |
+ |
+ service {'docker': |
+ ensure => running, |
+ require => Package['docker-engine'], |
+ } |
+ |
+ file {'/var/discourse': |
+ ensure => directory, |
+ mode => 755, |
+ owner => root, |
+ group => root |
+ } |
+ |
+ exec {'fetch-discourse-docker': |
+ command => "git clone https://github.com/discourse/discourse_docker.git /var/discourse", |
+ path => ["/usr/bin/", "/bin/"], |
+ user => root, |
+ timeout => 0, |
+ require => [Package['git'], File['/var/discourse']], |
+ unless => "test -d /var/discourse/.git" |
+ } |
+ |
+ file {'/var/discourse/containers/app.yml': |
+ ensure => file, |
+ mode => 600, |
+ owner => root, |
+ group => root, |
+ content => template('discourse_docker/app.yml.erb'), |
+ require => Package['docker-engine'], |
+ } |
+ |
+ exec {'rebuild': |
+ command => '/var/discourse/launcher rebuild app --skip-prereqs', |
+ user => root, |
+ subscribe => File['/var/discourse/containers/app.yml'], |
+ refreshonly => true, |
+ logoutput => 'on_failure', |
+ timeout => 0, |
+ require => [Exec['fetch-discourse-docker'], |
+ Service['docker'], |
+ Package['git']], |
+ } |
+ |
+ exec {'start': |
+ command => '/var/discourse/launcher start app --skip-prereqs', |
+ user => root, |
+ logoutput => 'on_failure', |
+ require => Exec['rebuild'], |
+ } |
f.lopez
2017/01/03 20:22:45
this can be inside a conditional from `service {'d
|
+ |
+ class {'nginx': |
+ worker_connections => 500 |
+ } |
+ |
+ nginx::hostconfig {$domain: |
+ source => 'puppet:///modules/discourse_docker/site.conf', |
+ is_default => $is_default, |
+ certificate => $certificate, |
+ private_key => $private_key, |
+ log => 'access_log_intraforum' |
+ } |
+} |