# Installs all Docker containers to run dotCMS
class dotcms(
String $cms_heap_size = '3g',
String $cms_version = '20.11.1-master-v2.0',
String $config_repo_branch = 'master', # only relevant to our static config plugin
String $data_device = '/dev/nvme1n1',
String $db_host = $facts['dotcms']['db_host'], # grabs this from SSM Params
String $db_password = $facts['dotcms']['db_password'],
String $dotcms_user = '1000000000', # this is the magic user id used in the container
String $license_file = '',
String $role = 'dev', # this is something our custom plugins use to know what environment they are in.
) {
data_volume { '/data': # this just creates the EBS Volume Mount
device => $data_device,
owner => $dotcms_user,
group => $dotcms_user,
} -> file { # Create the docker mount directories
default:
ensure => directory,
owner => $dotcms_user,
group => $dotcms_user,
;
'/data/plugins':;
'/data/felix':;
'/data/license':;
'/data/shared':;
'/data/local':;
'/data/esdata':
owner => '1000',
group => '1000',
} -> file {
default:
ensure => directory,
owner => $dotcms_user,
group => $dotcms_user,
;
'/data/plugins/static':; # separate .../static due to Puppet not being able to do mkdir -p
'/data/plugins/osgi':;
'/data/shared/assets':; # The container seems to want to create this as root unless we do it first.
} -> file { # pipe in the license and osgi-extra files
default:
ensure => present,
owner => $dotcms_user,
group => $dotcms_user,
mode => '0644',
;
'/data/felix/osgi-extra.conf':
source => 'puppet:///modules/dotcms/osgi-extra.conf',
;
'/data/license/license.zip':
source => "puppet:///modules/dotcms/${license_file}",
;
} -> exec { 'clone-dotcms-config':
# This is our Configuration plugin, it just has the settings for the cache and the like
cwd => '/data/plugins/static',
command => '/usr/bin/git clone g...@github.com:aquent/dotcms.config.git',
unless => '/usr/bin/test -d /data/plugins/static/dotcms.config',
} -> exec { 'checkout-dotcms-config-branch':
cwd => '/data/plugins/static/dotcms.config',
command => "/usr/bin/git checkout ${config_repo_branch} ; /usr/bin/git pull",
} -> exec { 'clone-dotcms-hotfix-19895':
cwd => '/data/plugins/static',
command => '/usr/bin/git clone g...@github.com:aquent/dotcms-hotfix-GIT-19895.git',
unless => '/usr/bin/test -d /data/plugins/static/dotcms-hotfix-GIT-19895',
} -> exec { 'checkout-dotcms-hotfix-19895-branch':
# TODO: This should be removed after an upgrade to dotCMS v21.2+
cwd => '/data/plugins/static/dotcms-hotfix-GIT-19895',
command => '/usr/bin/git checkout main ; /usr/bin/git pull',
} -> docker_network { 'dotcms':
ensure => present,
} -> docker::run { 'elasticsearch':
net => ['dotcms'],
username => '1000:1000',
env => [
'discovery.type=single-node',
'data=',
'bootstrap.memory_lock=true',
'ES_JAVA_OPTS=-Xmx1G -Duser.timezone=US/Eastern',
],
volumes => [
# Persist Index Data -- Note that mapping it in the dotCMS instance didn't help.
'/data/esdata:/usr/share/elasticsearch/data',
]
} -> docker::run { 'dotcms':
image => "(Insert MOTIV's Container Repo here):${cms_version}",
net => ['dotcms'],
ports => '8080:8080',
username => "${dotcms_user}:0", # GID has to be 0 to make /data mount work correctly, possibly an ec2/puppet thing, but this got me going.
env => [
"CMS_HEAP_SIZE=${cms_heap_size}",
'CMS_JAVA_OPTS=-Duser.timezone=US/Eastern',
"PROVIDER_DB_DNSNAME=${db_host}",
"PROVIDER_DB_PASSWORD=${db_password}",
'ES_ADMIN_PASSWORD=pass',
"SERVER_ROLE=${role}",
],
volumes => [
# Persist Assets and felix/load
'/data/shared:/data/shared',
# Persist Elasticsearch Index -- didn't work in my experience
'/data/local:/data/local',
# Static plugins - deployed after restart
'/data/plugins/static:/plugins/static',
# OSGI Plugins - deployed after restart
'/data/plugins/osgi:/plugins/osgi',
# Persist and set the OSGI Exported Packages File
'/data/felix/osgi-extra.conf:/srv/dotserver/tomcat-8.5.60/webapps/ROOT/WEB-INF/felix/osgi-extra.conf',
# Apply License Pack
'/data/license/license.zip:/data/shared/assets/license.zip'
]
}
}