Puppet Class: hdm::docker

Defined in:
manifests/docker.pp

Summary

Manage HDM using Docker

Overview

This class installs docker and runs the HDM container.



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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'manifests/docker.pp', line 7

class hdm::docker {
  assert_private()

  if $hdm::manage_docker {
    include docker
  }

  group { $hdm::group:
    ensure => present,
  }

  $shell = $facts['os']['family'] ? {
    'Debian'        => '/usr/sbin/nologin',
    /(RedHat|Suse)/ => '/sbin/nologin',
  }

  user { $hdm::user:
    ensure => present,
    gid    => $hdm::group,
    shell  => $shell,
  }

  $directories = [
    $hdm::hdm_path,
    "${hdm::hdm_path}/certs",
    "${hdm::hdm_path}/db",
  ]

  file { $directories:
    ensure => directory,
  }

  file { "${hdm::hdm_path}/hdm.yml":
    ensure  => file,
    content => epp('hdm/hdm.yml.epp'),
    notify  => Service['docker-hdm'],
  }

  file { "${hdm::hdm_path}/database.yml":
    ensure  => file,
    content => epp('hdm/database.yml'),
  }

  file { "${hdm::hdm_path}/db/production.sqlite3":
    ensure => file,
  }

  docker::image { $hdm::container_registry_url:
    image_tag => $hdm::version,
  }

  docker::run { 'hdm':
    image    => "${hdm::container_registry_url}:${hdm::version}",
    env      => [
      "TZ=${$hdm::timezone}",
      "RAILS_DEVELOPMENT_HOSTS=${hdm::hostname}",
      "SECRET_KEY_BASE=${hdm::secret_key_base}",
      "HDM_PORT=${hdm::port}",
      "HDM_HOST=${hdm::hostname}",
    ],
    volumes  => [
      "${hdm::hdm_path}:${hdm::hdm_path}",
      "${hdm::puppet_dir}:${hdm::puppet_dir}:ro",
      "${hdm::puppet_code_dir}:${hdm::puppet_code_dir}:ro",
      "${hdm::hdm_path}/hdm.yml:/hdm/config/hdm.yml:ro",
      "${hdm::hdm_path}/database.yml:/hdm/config/database.yml:ro",
    ],
    hostname => $hdm::hostname,
    ports    => [$hdm::port],
    net      => 'host',
  }
}