summaryrefslogtreecommitdiff
path: root/global/overlay/etc/puppet/modules/sunet/manifests/wordpress.pp
blob: 1d96d4ecd3864eecb8839975d5c498580a01a985 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# a basic wp setup using docker

define sunet::wordpress (
$db_host           = undef,
$wordpress_version = "4.1.1", 
$myqsl_version     = "5.7") 
{
   $db_hostname = $db_host ? {
      undef   => "${name}_mysql.docker",
      default => $db_host
   }
   $pwd = hiera("${name}_db_password",'NOT_SET_IN_HIERA')
   file {"/data/${name}": ensure => directory } ->
   file {"/data/${name}/html": ensure => directory } ->
   sunet::docker_run { "${name}_wordpress":
      image       => "wordpress",
      imagetag    => $wordpress_version,
      volumes     => ["/data/${name}/html:/var/www/html"],
      ports       => ["8080:80"],
      env         => [ "SERVICE_NAME=${name}",
                       "WORDPRESS_DB_HOST=${db_hostname}",
                       "WORDPRESS_DB_USER=${name}",
                       "WORDPRESS_DB_NAME=${name}",
                       "WORDPRESS_DB_PASSWORD=${pwd}" ]
   }

   if (!$db_host) {
      file {"/data/${name}/db": ensure => directory }
      group { 'mysql': ensure => 'present', system => true } ->
      user { 'mysql': ensure => 'present', groups => 'mysql', system => true } ->
      sunet::docker_run { "${name}_mysql":
          image       => "mysql",
          imagetag    => $mysql_version,
          volumes     => ["/data/${name}/db:/var/lib/mysql"],
          env         => ["MYSQL_USER=${name}",
                          "MYSQL_PASSWORD=${pwd}",
                          "MYSQL_ROOT_PASSWORD=${pwd}",
                          "MYSQL_DATABASE=${name}"]
      }
      package {'automysqlbackup': require => latest } -> 
      auges { 'automysqlbackup_settings': 
         incl    => "/etc/default/automysqlbackup",
         lens    => "Shellvars.lns",
         changes => [
            "set USERNAME=${name}",
            "set PASSWORD=${pwd}",
            "set DBHOST=${db_hostname}"
         ]
      }
   }
}