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
|
# a basic wp setup using docker
define sunet::wordpress (
$name = undef,
$db_host = undef,
$wordpress_version = "4.1.1",
$myqsl_version = "5.7")
{
$db_hostname = $db_host ? $db_host : "mysql_${sanitized_name}.docker"
$sanitized_name = regsubst($name, '[^0-9A-Za-z.\-]', '-', 'G')
$pwd = hiera('${sanitized_name}_db_password','NOT_SET_IN_HIERA')
sunet::docker_run {
name => "wordpress_${sanitized_name}",
image => "wordpress",
imagetag => $wordpress_version,
volumes => ["/data/${sanitized_name}/html":"/var/www/html"],
port => ["8080:80"]
environment => [ "WORDPRESS_DB_HOST=${db_hostname}",
"WORDPRESS_DB_USER=${sanitized_name}",
"WORDPRESS_DB_NAME=${sanitized_name}",
"WORDPRESS_DB_PASSWORD=${pwd}" ]
}
if (!$db_host) {
sunet::docker_run {
name => "mysql_${sanitized_name}",
image => "mysql",
imagetag => $mysql_version,
volumes => ["/data/${sanitized_name}/db":"/var/lib/mysql"],
environment => ["MYSQL_USER=${sanitized_name}",
"MYSQL_PASSWORD=${pwd}",
"MYSQL_ROOT_PASSWORD=${pwd}",
"MYSQL_DATABASE=${sanitized_name}"]
}
}
}
|