From 3e101cb3151c3e739cd8541dfbc5329f6ae6b647 Mon Sep 17 00:00:00 2001 From: praj1001 <134480625+praj1001@users.noreply.github.com> Date: Mon, 7 Aug 2023 14:39:00 +0530 Subject: [PATCH] (CAT-1143) Conversion of ERB Templates to EPP --- manifests/compose.pp | 8 +- manifests/image.pp | 9 +- manifests/install.pp | 38 +++++- manifests/machine.pp | 8 +- manifests/params.pp | 24 ++-- manifests/run.pp | 67 +++++++++- manifests/service.pp | 122 +++++++++++++++++- spec/helper/get_defaults.rb | 16 +-- spec/shared_examples/compose.rb | 1 - spec/shared_examples/image.rb | 4 +- spec/shared_examples/machine.rb | 1 - spec/shared_examples/service.rb | 2 - templates/docker-run-start.epp | 37 ++++++ templates/docker-run-start.erb | 37 ------ templates/docker-run-stop.epp | 10 ++ templates/docker-run-stop.erb | 10 -- templates/etc/conf.d/docker.epp | 56 ++++++++ templates/etc/conf.d/docker.erb | 56 -------- templates/etc/conf.d/docker.gentoo.epp | 56 ++++++++ templates/etc/conf.d/docker.gentoo.erb | 56 -------- templates/etc/default/docker.epp | 70 ++++++++++ templates/etc/default/docker.erb | 70 ---------- .../init.d/{docker-run.erb => docker-run.epp} | 42 +++--- .../etc/sysconfig/docker-storage-setup.epp | 19 +++ .../etc/sysconfig/docker-storage-setup.erb | 30 ----- templates/etc/sysconfig/docker-storage.epp | 39 ++++++ templates/etc/sysconfig/docker-storage.erb | 39 ------ templates/etc/sysconfig/docker.epp | 40 ++++++ templates/etc/sysconfig/docker.erb | 40 ------ templates/etc/sysconfig/docker.systemd.epp | 38 ++++++ templates/etc/sysconfig/docker.systemd.erb | 38 ------ templates/etc/systemd/system/docker-run.epp | 63 +++++++++ templates/etc/systemd/system/docker-run.erb | 63 --------- ....erb => service-overrides-debian.conf.epp} | 8 +- ...nf.erb => service-overrides-rhel.conf.epp} | 12 +- .../docker.socket.d/socket-overrides.conf.epp | 2 + .../docker.socket.d/socket-overrides.conf.erb | 2 - ...mage.sh.erb => update_docker_image.sh.epp} | 2 +- ...ck_docker.ps1.erb => check_docker.ps1.epp} | 4 +- ...r_url.ps1.erb => check_docker_url.ps1.epp} | 4 +- ....erb => check_powershell_provider.ps1.epp} | 21 ++- templates/windows/config/daemon.json.epp | 23 ++++ templates/windows/config/daemon.json.erb | 23 ---- ...docker.ps1.erb => download_docker.ps1.epp} | 4 +- ...s1.erb => download_docker_compose.ps1.epp} | 12 +- ...s1.erb => download_docker_machine.ps1.epp} | 12 +- ...rb => install_powershell_provider.ps1.epp} | 6 +- ...e_docker.ps1.erb => remove_docker.ps1.epp} | 12 +- ...ge.ps1.erb => update_docker_image.ps1.epp} | 6 +- 49 files changed, 778 insertions(+), 584 deletions(-) create mode 100644 templates/docker-run-start.epp delete mode 100644 templates/docker-run-start.erb create mode 100644 templates/docker-run-stop.epp delete mode 100644 templates/docker-run-stop.erb create mode 100644 templates/etc/conf.d/docker.epp delete mode 100644 templates/etc/conf.d/docker.erb create mode 100644 templates/etc/conf.d/docker.gentoo.epp delete mode 100644 templates/etc/conf.d/docker.gentoo.erb create mode 100644 templates/etc/default/docker.epp delete mode 100644 templates/etc/default/docker.erb rename templates/etc/init.d/{docker-run.erb => docker-run.epp} (66%) create mode 100644 templates/etc/sysconfig/docker-storage-setup.epp delete mode 100644 templates/etc/sysconfig/docker-storage-setup.erb create mode 100644 templates/etc/sysconfig/docker-storage.epp delete mode 100644 templates/etc/sysconfig/docker-storage.erb create mode 100644 templates/etc/sysconfig/docker.epp delete mode 100644 templates/etc/sysconfig/docker.erb create mode 100644 templates/etc/sysconfig/docker.systemd.epp delete mode 100644 templates/etc/sysconfig/docker.systemd.erb create mode 100644 templates/etc/systemd/system/docker-run.epp delete mode 100644 templates/etc/systemd/system/docker-run.erb rename templates/etc/systemd/system/docker.service.d/{service-overrides-debian.conf.erb => service-overrides-debian.conf.epp} (50%) rename templates/etc/systemd/system/docker.service.d/{service-overrides-rhel.conf.erb => service-overrides-rhel.conf.epp} (50%) create mode 100644 templates/etc/systemd/system/docker.socket.d/socket-overrides.conf.epp delete mode 100644 templates/etc/systemd/system/docker.socket.d/socket-overrides.conf.erb rename templates/{update_docker_image.sh.erb => update_docker_image.sh.epp} (93%) rename templates/windows/{check_docker.ps1.erb => check_docker.ps1.epp} (85%) rename templates/windows/{check_docker_url.ps1.erb => check_docker_url.ps1.epp} (86%) rename templates/windows/{check_powershell_provider.ps1.erb => check_powershell_provider.ps1.epp} (77%) create mode 100644 templates/windows/config/daemon.json.epp delete mode 100644 templates/windows/config/daemon.json.erb rename templates/windows/{download_docker.ps1.erb => download_docker.ps1.epp} (98%) rename templates/windows/{download_docker_compose.ps1.erb => download_docker_compose.ps1.epp} (74%) rename templates/windows/{download_docker_machine.ps1.erb => download_docker_machine.ps1.epp} (74%) rename templates/windows/{install_powershell_provider.ps1.erb => install_powershell_provider.ps1.epp} (67%) rename templates/windows/{remove_docker.ps1.erb => remove_docker.ps1.epp} (88%) rename templates/windows/{update_docker_image.ps1.erb => update_docker_image.ps1.epp} (79%) diff --git a/manifests/compose.pp b/manifests/compose.pp index 302b4539..fc485909 100644 --- a/manifests/compose.pp +++ b/manifests/compose.pp @@ -69,8 +69,14 @@ if $facts['os']['family'] == 'windows' { $docker_download_command = "if (Invoke-WebRequest ${docker_compose_url} ${proxy_opt} -UseBasicParsing -OutFile \"${docker_compose_location_versioned}\") { exit 0 } else { exit 1}" # lint:ignore:140chars + $parameters = { + 'proxy' => $proxy, + 'docker_compose_url' => $docker_compose_url, + 'docker_compose_location_versioned' => $docker_compose_location_versioned, + } + exec { "Install Docker Compose ${version}": - command => template('docker/windows/download_docker_compose.ps1.erb'), + command => epp('docker/windows/download_docker_compose.ps1.epp', $parameters), provider => powershell, creates => $docker_compose_location_versioned, } diff --git a/manifests/image.pp b/manifests/image.pp index dcdb7de9..54534f6e 100644 --- a/manifests/image.pp +++ b/manifests/image.pp @@ -40,7 +40,7 @@ $docker_command = $docker::params::docker_command if $facts['os']['family'] == 'windows' { - $update_docker_image_template = 'docker/windows/update_docker_image.ps1.erb' + $update_docker_image_template = 'docker/windows/update_docker_image.ps1.epp' $update_docker_image_path = "${facts['docker_user_temp_path']}/update_docker_image.ps1" $exec_environment = "PATH=${facts['docker_program_files_path']}/Docker/" $exec_timeout = 3000 @@ -48,7 +48,7 @@ $exec_path = ["${facts['docker_program_files_path']}/Docker/",] $exec_provider = 'powershell' } else { - $update_docker_image_template = 'docker/update_docker_image.sh.erb' + $update_docker_image_template = 'docker/update_docker_image.sh.epp' $update_docker_image_path = '/usr/local/bin/update_docker_image.sh' $update_docker_image_owner = 'root' $exec_environment = 'HOME=/root' @@ -57,6 +57,9 @@ $exec_provider = undef } + $parameters = { + 'docker_command' => $docker_command, + } # Wrapper used to ensure images are up to date ensure_resource('file', $update_docker_image_path, { @@ -64,7 +67,7 @@ owner => $update_docker_image_owner, group => $update_docker_image_owner, mode => '0555', - content => template($update_docker_image_template), + content => epp($update_docker_image_template, $parameters), } ) diff --git a/manifests/install.pp b/manifests/install.pp index 82e3fc09..36c535af 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -88,26 +88,52 @@ } } else { if $ensure == 'absent' { + $remove_docker_parameters = { + 'docker_ee_package_name' => $docker_ee_package_name, + 'version' => $version, + } + $check_docker_parameters = { + 'docker_ee_package_name' => $docker_ee_package_name, + } exec { 'remove-docker-package': - command => template('docker/windows/remove_docker.ps1.erb'), + command => epp('docker/windows/remove_docker.ps1.epp', $remove_docker_parameters), provider => powershell, - unless => template('docker/windows/check_docker.ps1.erb'), + unless => epp('docker/windows/check_docker.ps1.epp', $check_docker_parameters), logoutput => true, } } else { if $docker::package_location { + $download_docker_parameters = { + 'docker_download_url' => $docker_download_url, + } + $check_docker_url_parameters = { + 'docker_download_url' => $docker_download_url, + } exec { 'install-docker-package': - command => template('docker/windows/download_docker.ps1.erb'), + command => epp('docker/windows/download_docker.ps1.epp', $download_docker_parameters), provider => powershell, - unless => template('docker/windows/check_docker_url.ps1.erb'), + unless => epp('docker/windows/check_docker_url.ps1.epp', $check_docker_url_parameters), logoutput => true, notify => Exec['service-restart-on-failure'], } } else { + $install_powershell_provider_parameters = { + 'nuget_package_provider_version' => $nuget_package_provider_version, + 'docker_msft_provider_version' => $docker_msft_provider_version, + 'version' => $version, + } + + $check_powershell_provider_parameters = { + 'nuget_package_provider_version' => $nuget_package_provider_version, + 'docker_msft_provider_version' => $docker_msft_provider_version, + 'docker_ee_package_name' => $docker_ee_package_name, + 'version' => $version, + } + exec { 'install-docker-package': - command => template('docker/windows/install_powershell_provider.ps1.erb'), + command => epp('docker/windows/install_powershell_provider.ps1.epp', $install_powershell_provider_parameters), provider => powershell, - unless => template('docker/windows/check_powershell_provider.ps1.erb'), + unless => epp('docker/windows/check_powershell_provider.ps1.epp', $check_powershell_provider_parameters), logoutput => true, timeout => 1800, notify => Exec['service-restart-on-failure'], diff --git a/manifests/machine.pp b/manifests/machine.pp index 0f3f50c2..00b6e009 100644 --- a/manifests/machine.pp +++ b/manifests/machine.pp @@ -54,8 +54,14 @@ if $facts['os']['family'] == 'windows' { $docker_download_command = "if (Invoke-WebRequest ${docker_machine_url} ${proxy_opt} -UseBasicParsing -OutFile \"${docker_machine_location_versioned}\") { exit 0 } else { exit 1}" # lint:ignore:140chars + $parameters = { + 'proxy' => $proxy, + 'docker_machine_url' => $docker_machine_url, + 'docker_machine_location_versioned' => $docker_machine_location_versioned, + } + exec { "Install Docker Machine ${version}": - command => template('docker/windows/download_docker_machine.ps1.erb'), + command => epp('docker/windows/download_docker_machine.ps1.epp', $parameters), provider => powershell, creates => $docker_machine_location_versioned, } diff --git a/manifests/params.pp b/manifests/params.pp index c7d1e115..540abee9 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -81,7 +81,7 @@ $storage_auto_extend_pool = undef $storage_pool_autoextend_threshold = undef $storage_pool_autoextend_percent = undef - $storage_config_template = 'docker/etc/sysconfig/docker-storage.erb' + $storage_config_template = 'docker/etc/sysconfig/docker-storage.epp' $registry_mirror = undef $curl_ensure = true $os_lc = downcase($facts['os']['name']) @@ -115,17 +115,17 @@ if (versioncmp($facts['os']['release']['full'], '15.04') >= 0) { $service_after_override = undef - $service_config_template = 'docker/etc/sysconfig/docker.systemd.erb' + $service_config_template = 'docker/etc/sysconfig/docker.systemd.epp' $service_hasrestart = true $service_hasstatus = true - $service_overrides_template = 'docker/etc/systemd/system/docker.service.d/service-overrides-debian.conf.erb' + $service_overrides_template = 'docker/etc/systemd/system/docker.service.d/service-overrides-debian.conf.epp' $service_provider = 'systemd' $socket_override = false - $socket_overrides_template = 'docker/etc/systemd/system/docker.socket.d/socket-overrides.conf.erb' + $socket_overrides_template = 'docker/etc/systemd/system/docker.socket.d/socket-overrides.conf.epp' $storage_config = '/etc/default/docker-storage' include docker::systemd_reload } else { - $service_config_template = 'docker/etc/default/docker.erb' + $service_config_template = 'docker/etc/default/docker.epp' $service_overrides_template = undef $socket_overrides_template = undef $socket_override = false @@ -144,9 +144,9 @@ } $service_provider = 'systemd' $storage_config = '/etc/default/docker-storage' - $service_config_template = 'docker/etc/sysconfig/docker.systemd.erb' - $service_overrides_template = 'docker/etc/systemd/system/docker.service.d/service-overrides-debian.conf.erb' - $socket_overrides_template = 'docker/etc/systemd/system/docker.socket.d/socket-overrides.conf.erb' + $service_config_template = 'docker/etc/sysconfig/docker.systemd.epp' + $service_overrides_template = 'docker/etc/systemd/system/docker.service.d/service-overrides-debian.conf.epp' + $socket_overrides_template = 'docker/etc/systemd/system/docker.socket.d/socket-overrides.conf.epp' $socket_override = false $service_after_override = undef $service_hasstatus = true @@ -198,13 +198,13 @@ 'RedHat' : { $service_after_override = undef $service_config = '/etc/sysconfig/docker' - $service_config_template = 'docker/etc/sysconfig/docker.systemd.erb' + $service_config_template = 'docker/etc/sysconfig/docker.systemd.epp' $service_hasrestart = true $service_hasstatus = true - $service_overrides_template = 'docker/etc/systemd/system/docker.service.d/service-overrides-rhel.conf.erb' + $service_overrides_template = 'docker/etc/systemd/system/docker.service.d/service-overrides-rhel.conf.epp' $service_provider = 'systemd' $socket_override = false - $socket_overrides_template = 'docker/etc/systemd/system/docker.socket.d/socket-overrides.conf.erb' + $socket_overrides_template = 'docker/etc/systemd/system/docker.socket.d/socket-overrides.conf.epp' $storage_config = '/etc/sysconfig/docker-storage' $storage_setup_file = '/etc/sysconfig/docker-storage-setup' $use_upstream_package_source = true @@ -242,7 +242,7 @@ $msft_nuget_package_provider_version = $nuget_package_provider_version $msft_provider_version = $docker_msft_provider_version $msft_package_version = $version - $service_config_template = 'docker/windows/config/daemon.json.erb' + $service_config_template = 'docker/windows/config/daemon.json.epp' $service_config = "${facts['docker_program_data_path']}/docker/config/daemon.json" $docker_group = 'docker' $package_ce_source_location = undef diff --git a/manifests/run.pp b/manifests/run.pp index 19b8091b..535d6efe 100644 --- a/manifests/run.pp +++ b/manifests/run.pp @@ -475,8 +475,36 @@ } } } else { - $docker_run_inline_start = template('docker/docker-run-start.erb') - $docker_run_inline_stop = template('docker/docker-run-stop.erb') + $run_start_parameters = { + 'before_start' => $before_start, + 'remove_container_on_start' => $remove_container_on_start, + 'docker_command' => $docker_command, + 'remove_volume_on_start' => $remove_volume_on_start, + 'sanitised_title' => $sanitised_title, + 'pull_on_start' => $pull_on_start, + 'image' => $image, + 'verify_digest' => $verify_digest, + 'docker_run_flags' => $docker_run_flags, + 'command' => $command, + 'after_create' => $after_create, + 'net' => $net, + 'valid_detach' => $valid_detach, + 'after_start' => $after_start, + } + + $docker_run_inline_start = epp('docker/docker-run-start.epp', $run_start_parameters) + + $run_stop_parameters = { + 'before_stop' => $before_stop, + 'docker_command' => $docker_command, + 'stop_wait_time' => $stop_wait_time, + 'sanitised_title' => $sanitised_title, + 'remove_container_on_stop' => $remove_container_on_stop, + 'remove_volume_on_stop' => $remove_volume_on_stop, + 'after_stop' => $after_stop, + } + + $docker_run_inline_stop = epp('docker/docker-run-stop.epp', $run_stop_parameters) case $service_provider_real { 'systemd': { @@ -484,13 +512,13 @@ $startscript = "/usr/local/bin/docker-run-${sanitised_title}-start.sh" $stopscript = "/usr/local/bin/docker-run-${sanitised_title}-stop.sh" $startstop_template = 'docker/usr/local/bin/docker-run.sh.epp' - $init_template = 'docker/etc/systemd/system/docker-run.erb' + $init_template = 'docker/etc/systemd/system/docker-run.epp' $mode = '0644' $hasstatus = true } 'upstart': { $initscript = "/etc/init.d/${service_prefix}${sanitised_title}" - $init_template = 'docker/etc/init.d/docker-run.erb' + $init_template = 'docker/etc/init.d/docker-run.epp' $mode = '0750' $startscript = undef $stopscript = undef @@ -589,9 +617,38 @@ } } + if $service_provider_real == 'systemd' { + $init_template_parameters = { + 'depend_services_array' => $depend_services_array, + 'sanitised_after_array' => $sanitised_after_array, + 'service_prefix' => $service_prefix, + 'sanitised_depends_array' => $sanitised_depends_array, + 'title' => $title, + 'have_systemd_v230' => $docker::params::have_systemd_v230, + 'extra_systemd_parameters' => $extra_systemd_parameters, + 'systemd_restart' => $systemd_restart, + '_syslog_identifier' => $_syslog_identifier, + 'syslog_facility' => $syslog_facility, + 'sanitised_title' => $sanitised_title, + 'remain_after_exit' => $remain_after_exit, + 'service_name' => $service_name, + } + } elsif $service_provider_real == 'upstart' { + $init_template_parameters = { + 'sanitised_after_array' => $sanitised_after_array, + 'service_prefix' => $service_prefix, + 'sanitised_depends_array' => $sanitised_depends_array, + 'depend_services_array' => $depend_services_array, + 'docker_command' => $docker_command, + 'sanitised_title' => $sanitised_title, + 'docker_run_inline_start' => $docker_run_inline_start, + 'docker_run_inline_stop' => $docker_run_inline_stop, + } + } + file { $initscript: ensure => file, - content => template($init_template), + content => epp($init_template, $init_template_parameters), seltype => 'container_unit_file_t', owner => 'root', group => $docker_group, diff --git a/manifests/service.pp b/manifests/service.pp index b4472ded..80c429b7 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -287,11 +287,25 @@ default => [], } + $docker_storage_setup_parameters = { + 'storage_driver' => $storage_driver, + 'storage_devs' => $storage_devs, + 'storage_vg' => $storage_vg, + 'storage_root_size' => $storage_root_size, + 'storage_data_size' => $storage_data_size, + 'storage_min_data_size' => $storage_min_data_size, + 'storage_chunk_size' => $storage_chunk_size, + 'storage_growpart' => $storage_growpart, + 'storage_auto_extend_pool' => $storage_auto_extend_pool, + 'storage_pool_autoextend_threshold' => $storage_pool_autoextend_threshold, + 'storage_pool_autoextend_percent' => $storage_pool_autoextend_percent, + } + if $facts['os']['family'] == 'RedHat' { file { $storage_setup_file: ensure => file, force => true, - content => template('docker/etc/sysconfig/docker-storage-setup.erb'), + content => epp('docker/etc/sysconfig/docker-storage-setup.epp', $docker_storage_setup_parameters), before => $_manage_service, notify => $_manage_service, } @@ -310,6 +324,12 @@ } } + $parameters_service_overrides_template = { + 'service_after_override' => $service_after_override, + 'docker_start_command' => $docker_start_command, + 'daemon_environment_files' => $daemon_environment_files, + } + case $service_provider { 'systemd': { file { '/etc/systemd/system/docker.service.d': @@ -319,7 +339,7 @@ if $service_overrides_template { file { '/etc/systemd/system/docker.service.d/service-overrides.conf': ensure => file, - content => template($service_overrides_template), + content => epp($service_overrides_template, $parameters_service_overrides_template), seltype => 'container_unit_file_t', notify => Exec['docker-systemd-reload-before-service'], before => $_manage_service, @@ -333,7 +353,7 @@ file { '/etc/systemd/system/docker.socket.d/socket-overrides.conf': ensure => file, - content => template($socket_overrides_template), + content => epp($socket_overrides_template, { 'socket_group' => $socket_group }), seltype => 'container_unit_file_t', notify => Exec['docker-systemd-reload-before-service'], before => $_manage_service, @@ -369,22 +389,114 @@ $_skip_storage_config = false } + $storage_config_parameters = { + 'storage_driver' => $storage_driver, + 'storage_devs' => $storage_devs, + 'storage_vg' => $storage_vg, + 'storage_root_size' => $storage_root_size, + 'storage_data_size' => $storage_data_size, + 'storage_min_data_size' => $storage_min_data_size, + 'storage_chunk_size' => $storage_chunk_size, + 'storage_growpart' => $storage_growpart, + 'storage_auto_extend_pool' => $storage_auto_extend_pool, + 'storage_pool_autoextend_threshold' => $storage_pool_autoextend_threshold, + 'storage_pool_autoextend_percent' => $storage_pool_autoextend_percent, + 'dm_basesize' => $dm_basesize, + 'dm_fs' => $dm_fs, + 'dm_mkfsarg' => $dm_mkfsarg, + 'dm_mountopt' => $dm_mountopt, + 'dm_blocksize' => $dm_blocksize, + 'dm_loopdatasize' => $dm_loopdatasize, + 'dm_loopmetadatasize' => $dm_loopmetadatasize, + 'dm_thinpooldev' => $dm_thinpooldev, + 'dm_datadev' => $dm_datadev, + 'dm_metadatadev' => $dm_metadatadev, + 'dm_use_deferred_removal' => $dm_use_deferred_removal, + 'dm_use_deferred_deletion' => $dm_use_deferred_deletion, + 'dm_blkdiscard' => $dm_blkdiscard, + 'dm_override_udev_sync_check' => $dm_override_udev_sync_check, + 'overlay2_override_kernel_check' => $overlay2_override_kernel_check, + } + if $storage_config { unless $_skip_storage_config { file { $storage_config: ensure => file, force => true, #force rewrite storage configuration - content => template($storage_config_template), + content => epp($storage_config_template, $storage_config_parameters), notify => $_manage_service, } } } + $parameters = { + 'docker_command' => $docker_command, + 'proxy' => $proxy, + 'no_proxy' => $no_proxy, + 'tmp_dir' => $tmp_dir, + 'root_dir' => $root_dir, + 'root_dir_flag' => $root_dir_flag, + 'tcp_bind' => $tcp_bind, + 'tcp_bind_array' => $tcp_bind_array, + 'tls_enable' => $tls_enable, + 'tls_verify' => $tls_verify, + 'tls_cacert' => $tls_cacert, + 'tls_cert' => $tls_cert, + 'tls_key' => $tls_key, + 'socket_bind' => $socket_bind, + 'ip_forward' => $ip_forward, + 'iptables' => $iptables, + 'ip_masq' => $ip_masq, + 'icc' => $icc, + 'fixed_cidr' => $fixed_cidr, + 'bridge' => $bridge, + 'default_gateway' => $default_gateway, + 'log_level' => $log_level, + 'log_driver' => $log_driver, + 'log_opt' => $log_opt, + 'selinux_enabled' => $selinux_enabled, + 'socket_group' => $socket_group, + 'dns' => $dns, + 'dns_array' => $dns_array, + 'dns_search' => $dns_search, + 'dns_search_array' => $dns_search_array, + 'execdriver' => $execdriver, + 'bip' => $bip, + 'mtu' => $mtu, + 'registry_mirror' => $registry_mirror, + 'storage_driver' => $storage_driver, + 'dm_basesize' => $dm_basesize, + 'dm_fs' => $dm_fs, + 'dm_mkfsarg' => $dm_mkfsarg, + 'dm_mountopt' => $dm_mountopt, + 'dm_blocksize' => $dm_blocksize, + 'dm_loopdatasize' => $dm_loopdatasize, + 'dm_loopmetadatasize' => $dm_loopmetadatasize, + 'dm_thinpooldev' => $dm_thinpooldev, + 'dm_datadev' => $dm_datadev, + 'dm_metadatadev' => $dm_metadatadev, + 'dm_use_deferred_removal' => $dm_use_deferred_removal, + 'dm_use_deferred_deletion' => $dm_use_deferred_deletion, + 'dm_blkdiscard' => $dm_blkdiscard, + 'dm_override_udev_sync_check' => $dm_override_udev_sync_check, + 'overlay2_override_kernel_check' => $overlay2_override_kernel_check, + 'labels' => $labels, + 'extra_parameters' => $extra_parameters, + 'extra_parameters_array' => $extra_parameters_array, + 'shell_values' => $shell_values, + 'shell_values_array' => $shell_values_array, + 'labels_array' => $labels_array, + 'ipv6' => $ipv6, + 'ipv6_cidr' => $ipv6_cidr, + 'default_gateway_ipv6' => $default_gateway_ipv6, + 'tmp_dir_config' => $tmp_dir_config, + } + if $_service_config { file { $_service_config: ensure => file, force => true, - content => template($service_config_template), + content => epp($service_config_template, $parameters), notify => $_manage_service, } } diff --git a/spec/helper/get_defaults.rb b/spec/helper/get_defaults.rb index d22e00b8..c4ea9b08 100644 --- a/spec/helper/get_defaults.rb +++ b/spec/helper/get_defaults.rb @@ -72,7 +72,7 @@ def get_defaults(_facts) socket_group_default = 'docker' storage_auto_extend_pool = :undef storage_chunk_size = :undef - storage_config_template = 'docker/etc/sysconfig/docker-storage.erb' + storage_config_template = 'docker/etc/sysconfig/docker-storage.epp' storage_data_size = :undef storage_devs = :undef storage_driver = :undef @@ -116,13 +116,13 @@ def get_defaults(_facts) "debian-#{_facts[:os]['distro']['codename']}" end service_after_override = :undef - service_config_template = 'docker/etc/sysconfig/docker.systemd.erb' + service_config_template = 'docker/etc/sysconfig/docker.systemd.epp' service_hasrestart = true service_hasstatus = true - service_overrides_template = 'docker/etc/systemd/system/docker.service.d/service-overrides-debian.conf.erb' + service_overrides_template = 'docker/etc/systemd/system/docker.service.d/service-overrides-debian.conf.epp' service_provider = 'systemd' socket_override = false - socket_overrides_template = 'docker/etc/systemd/system/docker.socket.d/socket-overrides.conf.erb' + socket_overrides_template = 'docker/etc/systemd/system/docker.socket.d/socket-overrides.conf.epp' storage_config = '/etc/default/docker-storage' apt_source_pin_level = 500 @@ -154,13 +154,13 @@ def get_defaults(_facts) when 'RedHat' service_after_override = :undef service_config = '/etc/sysconfig/docker' - service_config_template = 'docker/etc/sysconfig/docker.systemd.erb' + service_config_template = 'docker/etc/sysconfig/docker.systemd.epp' service_hasrestart = true service_hasstatus = true - service_overrides_template = 'docker/etc/systemd/system/docker.service.d/service-overrides-rhel.conf.erb' + service_overrides_template = 'docker/etc/systemd/system/docker.service.d/service-overrides-rhel.conf.epp' service_provider = 'systemd' socket_override = false - socket_overrides_template = 'docker/etc/systemd/system/docker.socket.d/socket-overrides.conf.erb' + socket_overrides_template = 'docker/etc/systemd/system/docker.socket.d/socket-overrides.conf.epp' storage_config = '/etc/sysconfig/docker-storage' storage_setup_file = '/etc/sysconfig/docker-storage-setup' use_upstream_package_source = true @@ -203,7 +203,7 @@ def get_defaults(_facts) msft_nuget_package_provider_version = nuget_package_provider_version msft_provider_version = docker_msft_provider_version msft_package_version = version - service_config_template = 'docker/windows/config/daemon.json.erb' + service_config_template = 'docker/windows/config/daemon.json.epp' service_config = "#{_facts['docker_program_data_path']}/docker/config/daemon.json" docker_group = 'docker' package_ce_source_location = :undef diff --git a/spec/shared_examples/compose.rb b/spec/shared_examples/compose.rb index d9ff9f57..a34790c2 100644 --- a/spec/shared_examples/compose.rb +++ b/spec/shared_examples/compose.rb @@ -39,7 +39,6 @@ it { expect(subject).to contain_exec("Install Docker Compose #{version}").with( - # 'command' => template('docker/windows/download_docker_compose.ps1.erb'), 'provider' => 'powershell', 'creates' => docker_compose_location_versioned, ) diff --git a/spec/shared_examples/image.rb b/spec/shared_examples/image.rb index 6a4492fa..35dc22d3 100644 --- a/spec/shared_examples/image.rb +++ b/spec/shared_examples/image.rb @@ -12,7 +12,7 @@ image_tag = _params['image_tag'] if _facts[:os]['family'] == 'windows' - update_docker_image_template = 'docker/windows/update_docker_image.ps1.erb' + update_docker_image_template = 'docker/windows/update_docker_image.ps1.epp' update_docker_image_path = "#{_facts['docker_user_temp_path']}/update_docker_image.ps1" exec_environment = "PATH=#{_facts['docker_program_files_path']}/Docker/" exec_timeout = 3000 @@ -20,7 +20,7 @@ exec_path = ["#{_facts['docker_program_files_path']}/Docker/"] exec_provider = 'powershell' else - update_docker_image_template = 'docker/update_docker_image.sh.erb' + update_docker_image_template = 'docker/update_docker_image.sh.epp' update_docker_image_path = '/usr/local/bin/update_docker_image.sh' update_docker_image_owner = 'root' exec_environment = 'HOME=/root' diff --git a/spec/shared_examples/machine.rb b/spec/shared_examples/machine.rb index 9661a837..04b895f7 100644 --- a/spec/shared_examples/machine.rb +++ b/spec/shared_examples/machine.rb @@ -39,7 +39,6 @@ it { expect(subject).to contain_exec("Install Docker Machine #{version}").with( - # 'command' => template('docker/windows/download_docker_machine.ps1.erb'), 'provider' => 'powershell', 'creates' => docker_machine_location_versioned, ) diff --git a/spec/shared_examples/service.rb b/spec/shared_examples/service.rb index 36b50b64..dce78e78 100644 --- a/spec/shared_examples/service.rb +++ b/spec/shared_examples/service.rb @@ -55,7 +55,6 @@ it { expect(subject).to contain_file('/etc/systemd/system/docker.service.d/service-overrides.conf').with( 'ensure' => 'file', - # 'content' => template($service_overrides_template), 'before' => manage_service, ).that_notifies( 'Exec[docker-systemd-reload-before-service]', @@ -71,7 +70,6 @@ it { expect(subject).to contain_file('/etc/systemd/system/docker.socket.d/socket-overrides.conf').with( 'ensure' => 'file', - # 'content' => template($socket_overrides_template), ).that_comes_before( manage_service, ).that_notifies( diff --git a/templates/docker-run-start.epp b/templates/docker-run-start.epp new file mode 100644 index 00000000..fad9c4a6 --- /dev/null +++ b/templates/docker-run-start.epp @@ -0,0 +1,37 @@ +<% if $before_start { -%> + <%= $before_start %> +<% } -%> +<% if $remove_container_on_start { -%> + /usr/bin/<%= $docker_command %> rm <% if $remove_volume_on_start { %>-v<% } %> <%= $sanitised_title %> >/dev/null 2>&1 +<% } -%> + +<% if $pull_on_start { -%> + /usr/bin/<%= $docker_command %> pull <%= $image %> +<% } -%> + +<% if $verify_digest { -%> + digest_local=$(docker image inspect <%= $image %> --format='{{index .RepoDigests 0}}') + digest_verify="<%= $verify_digest %>" + if [ "${digest_local##*:}" != "${digest_verify##*:}" ]; then + echo "Digest verify failed! Expected checksum 'sha256:$digest_verify' does not match with local checksum 'sha256:$digest_local'!" + exit 2 + fi +<% } -%> + +/usr/bin/<%= $docker_command %> create \ +<%= $docker_run_flags %> \ +--name <%= $sanitised_title %> \ +<%= $image %> <% if $command { %> \ +<%= $command %><% } %> + +<% if $after_create { %><%= $after_create %><% } %> +<% if String(type($net, 'generalized')).index('Array') == 0 { %> + <% $net.each |$n| { %> +/usr/bin/<%= $docker_command %> network connect <%= $n %> <%= $sanitised_title %> + <% } %> +<% } %> + +/usr/bin/<%= $docker_command %> start <% if ! $valid_detach { %>-a<% } %> <%= $sanitised_title %> +<% if $after_start { -%> + <%= $after_start %> +<% } -%> diff --git a/templates/docker-run-start.erb b/templates/docker-run-start.erb deleted file mode 100644 index b1aecba1..00000000 --- a/templates/docker-run-start.erb +++ /dev/null @@ -1,37 +0,0 @@ -<% if @before_start -%> - <%= @before_start %> -<% end -%> -<% if @remove_container_on_start -%> - /usr/bin/<%= @docker_command %> rm <% if @remove_volume_on_start %>-v<% end %> <%= @sanitised_title %> >/dev/null 2>&1 -<% end -%> - -<% if @pull_on_start -%> - /usr/bin/<%= @docker_command %> pull <%= @image %> -<% end -%> - -<% if @verify_digest -%> - digest_local=$(docker image inspect <%= @image %> --format='{{index .RepoDigests 0}}') - digest_verify="<%= @verify_digest %>" - if [ "${digest_local##*:}" != "${digest_verify##*:}" ]; then - echo "Digest verify failed! Expected checksum 'sha256:$digest_verify' does not match with local checksum 'sha256:$digest_local'!" - exit 2 - fi -<% end -%> - -/usr/bin/<%= @docker_command %> create \ -<%= @docker_run_flags %> \ ---name <%= @sanitised_title %> \ -<%= @image %> <% if @command %> \ -<%= @command %><% end %> - -<% if @after_create %><%= @after_create %><% end %> -<% if @net.is_a? Array%> - <% @net.each do |n| %> -/usr/bin/<%= @docker_command %> network connect <%= n %> <%= @sanitised_title %> - <% end %> -<% end %> - -/usr/bin/<%= @docker_command %> start <% if ! @valid_detach %>-a<% end %> <%= @sanitised_title %> -<% if @after_start -%> - <%= @after_start %> -<% end -%> diff --git a/templates/docker-run-stop.epp b/templates/docker-run-stop.epp new file mode 100644 index 00000000..c8db6073 --- /dev/null +++ b/templates/docker-run-stop.epp @@ -0,0 +1,10 @@ +<% if $before_stop { -%> + <%= $before_stop %> +<% } -%> +/usr/bin/<%= $docker_command %> stop --time=<%= $stop_wait_time %> <%= $sanitised_title %> +<% if $remove_container_on_stop { -%> + /usr/bin/<%= $docker_command %> rm <% if $remove_volume_on_stop { %>-v<% } %> <%= $sanitised_title %> +<% } -%> +<% if $after_stop { -%> + <%= $after_stop %> +<% } -%> diff --git a/templates/docker-run-stop.erb b/templates/docker-run-stop.erb deleted file mode 100644 index e204df68..00000000 --- a/templates/docker-run-stop.erb +++ /dev/null @@ -1,10 +0,0 @@ -<% if @before_stop -%> - <%= @before_stop %> -<% end -%> -/usr/bin/<%= @docker_command %> stop --time=<%= @stop_wait_time %> <%= @sanitised_title %> -<% if @remove_container_on_stop -%> - /usr/bin/<%= @docker_command %> rm <% if @remove_volume_on_stop %>-v<% end %> <%= @sanitised_title %> -<% end -%> -<% if @after_stop -%> - <%= @after_stop %> -<% end -%> diff --git a/templates/etc/conf.d/docker.epp b/templates/etc/conf.d/docker.epp new file mode 100644 index 00000000..0fb46595 --- /dev/null +++ b/templates/etc/conf.d/docker.epp @@ -0,0 +1,56 @@ +# This file is managed by Puppet and local changes +# may be overwritten + +DOCKER="/usr/bin/<%= $docker_start_command %>" + +other_args="<% -%> +<% if $root_dir { %><%= $root_dir_flag %> <%= $root_dir %><% } -%> +<% if $tcp_bind { %><% $tcp_bind_array.each |$param| { %> -H <%= $param %><% } %><% } -%> +<% if $tls_enable { %> --tls<% if $tls_verify { %> --tlsverify<% } %> --tlscacert=<%= $tls_cacert %> --tlscert=<%= $tls_cert %> --tlskey=<%= $tls_key %><% } -%> +<% if $socket_bind { %> -H <%= $socket_bind %><% } -%> + --ip-forward=<%= $ip_forward -%> + --iptables=<%= $iptables -%> + --ip-masq=<%= $ip_masq -%> +<% if $icc { %> --icc=<%= $icc %><% } -%> +<% if $fixed_cidr { %> --fixed-cidr <%= $fixed_cidr %><% } -%> +<% if $default_gateway { %> --default-gateway <%= $default_gateway %><% } -%> +<% if $bridge { %> --bridge <%= $bridge %><% } -%> +<% if $log_level { %> -l <%= $log_level %><% } -%> +<% if $log_driver { %> --log-driver <%= $log_driver %><% } -%> +<% if $log_driver { %><% if $log_opt { %><% $log_opt.each |$param| { %> --log-opt <%= $param %><% } %><% } -%><% } -%> +<% if $selinux_enabled { %> --selinux-enabled=<%= $selinux_enabled %><% } -%> +<% if $socket_group { %> -G <%= $socket_group %><% } -%> +<% if $dns { %><% $dns_array.each |$address| { %> --dns <%= $address %><% } %><% } -%> +<% if $dns_search { %><% $dns_search_array.each |$domain| { %> --dns-search <%= $domain %><% } %><% } -%> +<% if $execdriver { %> -e <%= $execdriver %><% } -%> +<% if $storage_driver { %> --storage-driver=<%= $storage_driver %><% } -%> +<% if $storage_driver == 'devicemapper' { -%> + <%- if $dm_basesize { %> --storage-opt dm.basesize=<%= $dm_basesize %><% } -%> + <%- if $dm_fs { %> --storage-opt dm.fs=<%= $dm_fs %><% } -%> + <%- if $dm_mkfsarg { %> --storage-opt "dm.mkfsarg=<%= $dm_mkfsarg %>"<% } -%> + <%- if $dm_mountopt { %> --storage-opt dm.mountopt=<%= $dm_mountopt %><% } -%> + <%- if $dm_blocksize { %> --storage-opt dm.blocksize=<%= $dm_blocksize %><% } -%> + <%- if $dm_loopdatasize { %> --storage-opt dm.loopdatasize=<%= $dm_loopdatasize %><% } -%> + <%- if $dm_loopmetadatasize { %> --storage-opt dm.loopmetadatasize=<%= $dm_loopmetadatasize %><% } -%> + <%- if $dm_thinpooldev { %> --storage-opt dm.thinpooldev=<%= $dm_thinpooldev -%> + <%- }else { -%> + <%- if $dm_datadev { %> --storage-opt dm.datadev=<%= $dm_datadev %><% } -%> + <%- if $dm_metadatadev { %> --storage-opt dm.metadatadev=<%= $dm_metadatadev %><% } -%> + <%- } -%> +<%- if $dm_use_deferred_removal { %> --storage-opt dm.use_deferred_removal=<%= $dm_use_deferred_removal %><% } -%> +<%- if $dm_use_deferred_deletion { %> --storage-opt dm.use_deferred_deletion=<%= $dm_use_deferred_deletion %><% } -%> +<%- if $dm_blkdiscard { %> --storage-opt dm.blkdiscard=<%= $dm_blkdiscard %><% } -%> +<%- if $dm_override_udev_sync_check { %> --storage-opt dm.override_udev_sync_check=<%= $dm_override_udev_sync_check %><% } -%> +<% } elsif $storage_driver == 'overlay2' { -%> + <%- if $overlay2_override_kernel_check { %> --storage-opt overlay2.override_kernel_check=<%= $overlay2_override_kernel_check %><% } -%> +<% } -%> +<% $labels.each |$label| { %> --label <%= $label %><% } -%> +<% if $extra_parameters { %><% $extra_parameters_array.each |$param| { %> <%= $param %><% } %><% } -%> +" +<% if $proxy { %>export http_proxy='<%= $proxy %>' +export https_proxy='<%= $proxy %>'<% } %> +<% if $no_proxy { %>export no_proxy='<%= $no_proxy %>'<% } %> +# This is also a handy place to tweak where Docker's temporary files go. +export TMPDIR="<%= $tmp_dir %>" +<% if $shell_values { %><% $shell_values_array.each |$param| { %> +<%= $param %><% } %><% } -%> diff --git a/templates/etc/conf.d/docker.erb b/templates/etc/conf.d/docker.erb deleted file mode 100644 index ceb82112..00000000 --- a/templates/etc/conf.d/docker.erb +++ /dev/null @@ -1,56 +0,0 @@ -# This file is managed by Puppet and local changes -# may be overwritten - -DOCKER="/usr/bin/<%= @docker_start_command %>" - -other_args="<% -%> -<% if @root_dir %><%= @root_dir_flag %> <%= @root_dir %><% end -%> -<% if @tcp_bind %><% @tcp_bind_array.each do |param| %> -H <%= param %><% end %> <% end -%> -<% if @tls_enable %> --tls<% if @tls_verify -%> --tlsverify<% end -%> --tlscacert=<%= @tls_cacert %> --tlscert=<%= @tls_cert %> --tlskey=<%= @tls_key %><% end -%> -<% if @socket_bind %> -H <%= @socket_bind %><% end -%> - --ip-forward=<%= @ip_forward -%> - --iptables=<%= @iptables -%> - --ip-masq=<%= @ip_masq -%> -<% unless @icc == nil %> --icc=<%= @icc %><% end -%> -<% if @fixed_cidr %> --fixed-cidr <%= @fixed_cidr %><% end -%> -<% if @default_gateway %> --default-gateway <%= @default_gateway %><% end -%> -<% if @bridge %> --bridge <%= @bridge %><% end -%> -<% if @log_level %> -l <%= @log_level %><% end -%> -<% if @log_driver %> --log-driver <%= @log_driver %><% end -%> -<% if @log_driver %><% if @log_opt %><% @log_opt.each do |param| %> --log-opt <%= param %><% end %><% end -%><% end -%> -<% if @selinux_enabled %> --selinux-enabled=<%= @selinux_enabled %><% end -%> -<% if @socket_group %> -G <%= @socket_group %><% end -%> -<% if @dns %><% @dns_array.each do |address| %> --dns <%= address %><% end %><% end -%> -<% if @dns_search %><% @dns_search_array.each do |domain| %> --dns-search <%= domain %><% end %><% end -%> -<% if @execdriver %> -e <%= @execdriver %> <% end -%> -<% if @storage_driver %> --storage-driver=<%= @storage_driver %><% end -%> -<% if @storage_driver == 'devicemapper' -%> - <%- if @dm_basesize %> --storage-opt dm.basesize=<%= @dm_basesize %><% end -%> - <%- if @dm_fs %> --storage-opt dm.fs=<%= @dm_fs %><% end -%> - <%- if @dm_mkfsarg %> --storage-opt "dm.mkfsarg=<%= @dm_mkfsarg %>"<% end -%> - <%- if @dm_mountopt %> --storage-opt dm.mountopt=<%= @dm_mountopt %><% end -%> - <%- if @dm_blocksize %> --storage-opt dm.blocksize=<%= @dm_blocksize %><% end -%> - <%- if @dm_loopdatasize %> --storage-opt dm.loopdatasize=<%= @dm_loopdatasize %><% end -%> - <%- if @dm_loopmetadatasize %> --storage-opt dm.loopmetadatasize=<%= @dm_loopmetadatasize %><% end -%> - <%- if @dm_thinpooldev %> --storage-opt dm.thinpooldev=<%= @dm_thinpooldev -%> - <%- else -%> - <%- if @dm_datadev %> --storage-opt dm.datadev=<%= @dm_datadev %><% end -%> - <%- if @dm_metadatadev %> --storage-opt dm.metadatadev=<%= @dm_metadatadev %><% end -%> - <%- end -%> - <%- if @dm_use_deferred_removal %> --storage-opt dm.use_deferred_removal=<%= @dm_use_deferred_removal %><% end -%> - <%- if @dm_use_deferred_deletion %> --storage-opt dm.use_deferred_deletion=<%= @dm_use_deferred_deletion %><% end -%> - <%- if @dm_blkdiscard %> --storage-opt dm.blkdiscard=<%= @dm_blkdiscard %><% end -%> - <%- if @dm_override_udev_sync_check %> --storage-opt dm.override_udev_sync_check=<%= @dm_override_udev_sync_check %><% end -%> -<% elsif @storage_driver == 'overlay2' -%> - <%- if @overlay2_override_kernel_check %> --storage-opt overlay2.override_kernel_check=<%= @overlay2_override_kernel_check %><% end -%> -<% end -%> -<% @labels.each do |label| %> --label <%= label %><% end -%> -<% if @extra_parameters %><% @extra_parameters_array.each do |param| %> <%= param %><% end %><% end -%> -" -<% if @proxy %>export http_proxy='<%= @proxy %>' -export https_proxy='<%= @proxy %>'<% end %> -<% if @no_proxy %>export no_proxy='<%= @no_proxy %>'<% end %> -# This is also a handy place to tweak where Docker's temporary files go. -export TMPDIR="<%= @tmp_dir %>" -<% if @shell_values %><% @shell_values_array.each do |param| %> -<%= param %><% end %><% end -%> diff --git a/templates/etc/conf.d/docker.gentoo.epp b/templates/etc/conf.d/docker.gentoo.epp new file mode 100644 index 00000000..066f169f --- /dev/null +++ b/templates/etc/conf.d/docker.gentoo.epp @@ -0,0 +1,56 @@ +# This file is managed by Puppet and local changes +# may be overwritten + +DOCKER_BINARY="/usr/bin/<%= $docker_command %>" + +DOCKER_OPTS="<% -%> +<% if $root_dir { %> -g <%= $root_dir %><% } %> +<% if $tcp_bind { %><% $tcp_bind_array.each |$param| { %> -H <%= $param %><% } %><% } %> +<% if $tls_enable { %> --tls<% if $tls_verify { %> --tlsverify<% } %> --tlscacert=<%= $tls_cacert %> --tlscert=<%= $tls_cert %> --tlskey=<%= $tls_key %><% } %> +<% if $socket_bind { %> -H <%= $socket_bind %><% } %> + --ip-forward=<%= $ip_forward -%> + --iptables=<%= $iptables -%> + --ip-masq=<%= $ip_masq -%> +<% if $icc { %> --icc=<%= $icc %><% } %> +<% if $fixed_cidr { %> --fixed-cidr <%= $fixed_cidr %><% } %> +<% if $default_gateway { %> --default-gateway <%= $default_gateway %><% } %> +<% if $bridge { %> --bridge <%= $bridge %><% } %> +<% if $log_level { %> -l <%= $log_level %><% } %> +<% if $log_driver { %> --log-driver <%= $log_driver %><% } %> +<% if $log_driver { %><% if $log_opt { %><% $log_opt.each |$param| { %> --log-opt <%= $param %><% } %><% } %><% } %> +<% if $selinux_enabled { %> --selinux-enabled=<%= $selinux_enabled %><% } %> +<% if $socket_group { %> -G <%= $socket_group %><% } %> +<% if $dns { %><% $dns_array.each |$address| { %> --dns <%= $address %><% } %><% } %> +<% if $dns_search { %><% $dns_search_array.each |$domain| { %> --dns-search <%= $domain %><% } %><% } %> +<% if $execdriver { %> -e <%= $execdriver %><% } %> +<% if $storage_driver { %> --storage-driver=<%= $storage_driver %><% } %> +<% if $storage_driver == 'devicemapper' { -%> + <%- if $dm_basesize { %> --storage-opt dm.basesize=<%= $dm_basesize %><% } %> + <%- if $dm_fs { %> --storage-opt dm.fs=<%= $dm_fs %><% } %> + <%- if $dm_mkfsarg { %> --storage-opt "dm.mkfsarg=<%= $dm_mkfsarg %>"<% } %> + <%- if $dm_mountopt { %> --storage-opt dm.mountopt=<%= $dm_mountopt %><% } %> + <%- if $dm_blocksize { %> --storage-opt dm.blocksize=<%= $dm_blocksize %><% } %> + <%- if $dm_loopdatasize { %> --storage-opt dm.loopdatasize=<%= $dm_loopdatasize %><% } %> + <%- if $dm_loopmetadatasize { %> --storage-opt dm.loopmetadatasize=<%= $dm_loopmetadatasize %><% } %> + <%- if $dm_thinpooldev { %> --storage-opt dm.thinpooldev=<%= $dm_thinpooldev %><% } + else { %> + <%- if $dm_datadev { %> --storage-opt dm.datadev=<%= $dm_datadev %><% } %> + <%- if $dm_metadatadev { %> --storage-opt dm.metadatadev=<%= $dm_metadatadev %><% } %> + <% } %> +<%- if $dm_use_deferred_removal { %> --storage-opt dm.use_deferred_removal=<%= $dm_use_deferred_removal %><% } %> +<%- if $dm_use_deferred_deletion { %> --storage-opt dm.use_deferred_deletion=<%= $dm_use_deferred_deletion %><% } %> +<%- if $dm_blkdiscard { %> --storage-opt dm.blkdiscard=<%= $dm_blkdiscard %><% } %> +<%- if $dm_override_udev_sync_check { %> --storage-opt dm.override_udev_sync_check=<%= $dm_override_udev_sync_check %><% } %> +<% } elsif $storage_driver == 'overlay2' { -%> + <%- if $overlay2_override_kernel_check { %> --storage-opt overlay2.override_kernel_check=<%= $overlay2_override_kernel_check %><% } %> +<% } -%> +<% $labels.each |$label| { %> --label <%= $label %><% } %> +<% if $extra_parameters { %><% $extra_parameters_array.each |$param| { %> <%= $param %><% } %><% } %> +" +<% if $proxy { %>export http_proxy='<%= $proxy %>' +export https_proxy='<%= $proxy %>'<% } -%> +<% if $no_proxy { %>export no_proxy='<%= $no_proxy %>'<% } -%> +# This is also a handy place to tweak where Docker's temporary files go. +export TMPDIR="<%= $tmp_dir %>" +<% if $shell_values { %><% $shell_values_array.each |$param| { %> +<%= $param %><% } %><% } -%> diff --git a/templates/etc/conf.d/docker.gentoo.erb b/templates/etc/conf.d/docker.gentoo.erb deleted file mode 100644 index 3289bc3e..00000000 --- a/templates/etc/conf.d/docker.gentoo.erb +++ /dev/null @@ -1,56 +0,0 @@ -# This file is managed by Puppet and local changes -# may be overwritten - -DOCKER_BINARY="/usr/bin/<%= @docker_command %>" - -DOCKER_OPTS="<% -%> -<% if @root_dir %> -g <%= @root_dir %><% end -%> -<% if @tcp_bind %><% @tcp_bind_array.each do |param| %> -H <%= param %><% end %> <% end -%> -<% if @tls_enable %> --tls<% if @tls_verify -%> --tlsverify<% end -%> --tlscacert=<%= @tls_cacert %> --tlscert=<%= @tls_cert %> --tlskey=<%= @tls_key %><% end -%> -<% if @socket_bind %> -H <%= @socket_bind %><% end -%> - --ip-forward=<%= @ip_forward -%> - --iptables=<%= @iptables -%> - --ip-masq=<%= @ip_masq -%> -<% unless @icc == nil %> --icc=<%= @icc %><% end -%> -<% if @fixed_cidr %> --fixed-cidr <%= @fixed_cidr %><% end -%> -<% if @default_gateway %> --default-gateway <%= @default_gateway %><% end -%> -<% if @bridge %> --bridge <%= @bridge %><% end -%> -<% if @log_level %> -l <%= @log_level %><% end -%> -<% if @log_driver %> --log-driver <%= @log_driver %><% end -%> -<% if @log_driver %><% if @log_opt %><% @log_opt.each do |param| %> --log-opt <%= param %><% end %><% end -%><% end -%> -<% if @selinux_enabled %> --selinux-enabled=<%= @selinux_enabled %><% end -%> -<% if @socket_group %> -G <%= @socket_group %><% end -%> -<% if @dns %><% @dns_array.each do |address| %> --dns <%= address %><% end %><% end -%> -<% if @dns_search %><% @dns_search_array.each do |domain| %> --dns-search <%= domain %><% end %><% end -%> -<% if @execdriver %> -e <%= @execdriver %> <% end -%> -<% if @storage_driver %> --storage-driver=<%= @storage_driver %><% end -%> -<% if @storage_driver == 'devicemapper' -%> - <%- if @dm_basesize %> --storage-opt dm.basesize=<%= @dm_basesize %><% end -%> - <%- if @dm_fs %> --storage-opt dm.fs=<%= @dm_fs %><% end -%> - <%- if @dm_mkfsarg %> --storage-opt "dm.mkfsarg=<%= @dm_mkfsarg %>"<% end -%> - <%- if @dm_mountopt %> --storage-opt dm.mountopt=<%= @dm_mountopt %><% end -%> - <%- if @dm_blocksize %> --storage-opt dm.blocksize=<%= @dm_blocksize %><% end -%> - <%- if @dm_loopdatasize %> --storage-opt dm.loopdatasize=<%= @dm_loopdatasize %><% end -%> - <%- if @dm_loopmetadatasize %> --storage-opt dm.loopmetadatasize=<%= @dm_loopmetadatasize %><% end -%> - <%- if @dm_thinpooldev %> --storage-opt dm.thinpooldev=<%= @dm_thinpooldev -%> - <%- else -%> - <%- if @dm_datadev %> --storage-opt dm.datadev=<%= @dm_datadev %><% end -%> - <%- if @dm_metadatadev %> --storage-opt dm.metadatadev=<%= @dm_metadatadev %><% end -%> - <%- end -%> - <%- if @dm_use_deferred_removal %> --storage-opt dm.use_deferred_removal=<%= @dm_use_deferred_removal %><% end -%> - <%- if @dm_use_deferred_deletion %> --storage-opt dm.use_deferred_deletion=<%= @dm_use_deferred_deletion %><% end -%> - <%- if @dm_blkdiscard %> --storage-opt dm.blkdiscard=<%= @dm_blkdiscard %><% end -%> - <%- if @dm_override_udev_sync_check %> --storage-opt dm.override_udev_sync_check=<%= @dm_override_udev_sync_check %><% end -%> -<% elsif @storage_driver == 'overlay2' -%> - <%- if @overlay2_override_kernel_check %> --storage-opt overlay2.override_kernel_check=<%= @overlay2_override_kernel_check %><% end -%> -<% end -%> -<% @labels.each do |label| %> --label <%= label %><% end -%> -<% if @extra_parameters %><% @extra_parameters_array.each do |param| %> <%= param %><% end %><% end -%> -" -<% if @proxy %>export http_proxy='<%= @proxy %>' -export https_proxy='<%= @proxy %>'<% end %> -<% if @no_proxy %>export no_proxy='<%= @no_proxy %>'<% end %> -# This is also a handy place to tweak where Docker's temporary files go. -export TMPDIR="<%= @tmp_dir %>" -<% if @shell_values %><% @shell_values_array.each do |param| %> -<%= param %><% end %><% end -%> diff --git a/templates/etc/default/docker.epp b/templates/etc/default/docker.epp new file mode 100644 index 00000000..b8c3bf0e --- /dev/null +++ b/templates/etc/default/docker.epp @@ -0,0 +1,70 @@ +# Docker Upstart and SysVinit configuration file +# +# THIS FILE IS MANAGED BY PUPPET. Changes will be overwritten. + +# # Customize location of Docker binary (especially for development testing). +DOCKER="/usr/bin/<%= $docker_command %>" + +# # If you need Docker to use an HTTP proxy, it can also be specified here. +<% if $proxy { -%> +export http_proxy='<%= $proxy %>' +export https_proxy='<%= $proxy %>' +<% } -%> +<% if $no_proxy { -%> +export no_proxy='<%= $no_proxy.convert_to(Array).join(',') %>' +<% } -%> + +# # This is also a handy place to tweak where Docker's temporary files go. +export TMPDIR="<%= $tmp_dir %>" + +# # Use DOCKER_OPTS to modify the daemon startup options. +DOCKER_OPTS="\ +<% if $root_dir { %><%= $root_dir_flag %> <%= $root_dir %><% } -%> +<% if $tcp_bind { %><% $tcp_bind_array.each |$param| { %> -H <%= $param %><% } %><% } -%> +<% if $tls_enable { %> --tls<% if $tls_verify { %> --tlsverify<% } %> --tlscacert=<%= $tls_cacert %> --tlscert=<%= $tls_cert %> --tlskey=<%= $tls_key %><% } -%> +<% if $socket_bind { %> -H <%= $socket_bind %><% } -%> + --ip-forward=<%= $ip_forward -%> + --iptables=<%= $iptables -%> + --ip-masq=<%= $ip_masq -%> +<% if $icc { %> --icc=<%= $icc %><% } -%> +<% if $fixed_cidr { %> --fixed-cidr <%= $fixed_cidr %><% } -%> +<% if $bridge { %> --bridge <%= $bridge %><% } -%> +<% if $default_gateway { %> --default-gateway <%= $default_gateway %><% } -%> +<% if $log_level { %> -l <%= $log_level %><% } -%> +<% if $log_driver { %> --log-driver <%= $log_driver %><% } -%> +<% if $log_driver { %><% if $log_opt { %><% $log_opt.each |$param| { %> --log-opt <%= $param %><% } %><% } -%><% } -%> +<% if $selinux_enabled { %> --selinux-enabled=<%= $selinux_enabled %><% } -%> +<% if $socket_group { %> -G <%= $socket_group %><% } -%> +<% if $dns { %><% $dns_array.each |$address| { %> --dns <%= $address %><% } %><% } -%> +<% if $dns_search { %><% $dns_search_array.each |$domain| { %> --dns-search <%= $domain %><% } %><% } -%> +<% if $execdriver { %> -e <%= $execdriver %><% } -%> +<% if $bip { %> --bip=<%= $bip %><% } -%> +<% if $mtu { %> --mtu=<%= $mtu %><% } -%> +<% if type($registry_mirror, 'generalized') == String { %> --registry-mirror=<%= $registry_mirror %><% } -%> +<% if String(type($registry_mirror, 'generalized')).index('Array') == 0 { %><% $registry_mirror.each |$param| { %> --registry-mirror=<%= $param %><% } %><% } -%> +<% if $storage_driver { %> --storage-driver=<%= $storage_driver %><% } -%> +<% if $storage_driver == 'devicemapper' { -%> + <%- if $dm_basesize { %> --storage-opt dm.basesize=<%= $dm_basesize %><% } -%> + <%- if $dm_fs { %> --storage-opt dm.fs=<%= $dm_fs %><% } -%> + <%- if $dm_mkfsarg { %> --storage-opt "dm.mkfsarg=<%= $dm_mkfsarg %>"<% } -%> + <%- if $dm_mountopt { %> --storage-opt dm.mountopt=<%= $dm_mountopt %><% } -%> + <%- if $dm_blocksize { %> --storage-opt dm.blocksize=<%= $dm_blocksize %><% } -%> + <%- if $dm_loopdatasize { %> --storage-opt dm.loopdatasize=<%= $dm_loopdatasize %><% } -%> + <%- if $dm_loopmetadatasize { %> --storage-opt dm.loopmetadatasize=<%= $dm_loopmetadatasize %><% } -%> + <%- if $dm_thinpooldev { %> --storage-opt dm.thinpooldev=<%= $dm_thinpooldev -%> + <%- }else { -%> + <%- if $dm_datadev { %> --storage-opt dm.datadev=<%= $dm_datadev %><% } -%> + <%- if $dm_metadatadev { %> --storage-opt dm.metadatadev=<%= $dm_metadatadev %><% } -%> + <%- } -%> +<%- if $dm_use_deferred_removal { %> --storage-opt dm.use_deferred_removal=<%= $dm_use_deferred_removal %><% } -%> +<%- if $dm_use_deferred_deletion { %> --storage-opt dm.use_deferred_deletion=<%= $dm_use_deferred_deletion %><% } -%> +<%- if $dm_blkdiscard { %> --storage-opt dm.blkdiscard=<%= $dm_blkdiscard %><% } -%> +<%- if $dm_override_udev_sync_check { %> --storage-opt dm.override_udev_sync_check=<%= $dm_override_udev_sync_check %><% } -%> +<% } elsif $storage_driver == 'overlay2' { -%> + <%- if $overlay2_override_kernel_check { %> --storage-opt overlay2.override_kernel_check=<%= $overlay2_override_kernel_check %><% } -%> +<% } -%> +<% $labels.each |$label| { %> --label <%= $label %><% } -%> +<% if $extra_parameters { %><% $extra_parameters_array.each |$param| { %> <%= $param %><% } %><% } -%> +" +<% if $shell_values { %><% $shell_values_array.each |$param| { %> +<%= $param %><% } %><% } -%> diff --git a/templates/etc/default/docker.erb b/templates/etc/default/docker.erb deleted file mode 100644 index 083b237c..00000000 --- a/templates/etc/default/docker.erb +++ /dev/null @@ -1,70 +0,0 @@ -# Docker Upstart and SysVinit configuration file -# -# THIS FILE IS MANAGED BY PUPPET. Changes will be overwritten. - -# # Customize location of Docker binary (especially for development testing). -DOCKER="/usr/bin/<%= @docker_command %>" - -# # If you need Docker to use an HTTP proxy, it can also be specified here. -<% if @proxy -%> -export http_proxy='<%= @proxy %>' -export https_proxy='<%= @proxy %>' -<% end -%> -<% if @no_proxy -%> -export no_proxy='<%= Array(@no_proxy).join(',') %>' -<% end -%> - -# # This is also a handy place to tweak where Docker's temporary files go. -export TMPDIR="<%= @tmp_dir %>" - -# # Use DOCKER_OPTS to modify the daemon startup options. -DOCKER_OPTS="\ -<% if @root_dir %><%= @root_dir_flag %> <%= @root_dir %><% end -%> -<% if @tcp_bind %><% @tcp_bind_array.each do |param| %> -H <%= param %><% end %> <% end -%> -<% if @tls_enable %> --tls<% if @tls_verify -%> --tlsverify<% end -%> --tlscacert=<%= @tls_cacert %> --tlscert=<%= @tls_cert %> --tlskey=<%= @tls_key %><% end -%> -<% if @socket_bind %> -H <%= @socket_bind %><% end -%> - --ip-forward=<%= @ip_forward -%> - --iptables=<%= @iptables -%> - --ip-masq=<%= @ip_masq -%> -<% unless @icc == nil %> --icc=<%= @icc %><% end -%> -<% if @fixed_cidr %> --fixed-cidr <%= @fixed_cidr %><% end -%> -<% if @bridge %> --bridge <%= @bridge %><% end -%> -<% if @default_gateway %> --default-gateway <%= @default_gateway %><% end -%> -<% if @log_level %> -l <%= @log_level %><% end -%> -<% if @log_driver %> --log-driver <%= @log_driver %><% end -%> -<% if @log_driver %><% if @log_opt %><% @log_opt.each do |param| %> --log-opt <%= param %><% end %><% end -%><% end -%> -<% if @selinux_enabled %> --selinux-enabled=<%= @selinux_enabled %><% end -%> -<% if @socket_group %> -G <%= @socket_group %><% end -%> -<% if @dns %><% @dns_array.each do |address| %> --dns <%= address %><% end %><% end -%> -<% if @dns_search %><% @dns_search_array.each do |domain| %> --dns-search <%= domain %><% end %><% end -%> -<% if @execdriver %> -e <%= @execdriver %> <% end -%> -<% if @bip %> --bip=<%= @bip %> <% end -%> -<% if @mtu %> --mtu=<%= @mtu %> <% end -%> -<% if @registry_mirror.is_a? String %> --registry-mirror=<%= @registry_mirror %><% end -%> -<% if @registry_mirror.is_a? Array %><% @registry_mirror.each do |param| %> --registry-mirror=<%= param %><% end %><% end -%> -<% if @storage_driver %> --storage-driver=<%= @storage_driver %><% end -%> -<% if @storage_driver == 'devicemapper' -%> - <%- if @dm_basesize %> --storage-opt dm.basesize=<%= @dm_basesize %><% end -%> - <%- if @dm_fs %> --storage-opt dm.fs=<%= @dm_fs %><% end -%> - <%- if @dm_mkfsarg %> --storage-opt "dm.mkfsarg=<%= @dm_mkfsarg %>"<% end -%> - <%- if @dm_mountopt %> --storage-opt dm.mountopt=<%= @dm_mountopt %><% end -%> - <%- if @dm_blocksize %> --storage-opt dm.blocksize=<%= @dm_blocksize %><% end -%> - <%- if @dm_loopdatasize %> --storage-opt dm.loopdatasize=<%= @dm_loopdatasize %><% end -%> - <%- if @dm_loopmetadatasize %> --storage-opt dm.loopmetadatasize=<%= @dm_loopmetadatasize %><% end -%> - <%- if @dm_thinpooldev %> --storage-opt dm.thinpooldev=<%= @dm_thinpooldev -%> - <%- else -%> - <%- if @dm_datadev %> --storage-opt dm.datadev=<%= @dm_datadev %><% end -%> - <%- if @dm_metadatadev %> --storage-opt dm.metadatadev=<%= @dm_metadatadev %><% end -%> - <%- end -%> - <%- if @dm_use_deferred_removal %> --storage-opt dm.use_deferred_removal=<%= @dm_use_deferred_removal %><% end -%> - <%- if @dm_use_deferred_deletion %> --storage-opt dm.use_deferred_deletion=<%= @dm_use_deferred_deletion %><% end -%> - <%- if @dm_blkdiscard %> --storage-opt dm.blkdiscard=<%= @dm_blkdiscard %><% end -%> - <%- if @dm_override_udev_sync_check %> --storage-opt dm.override_udev_sync_check=<%= @dm_override_udev_sync_check %><% end -%> -<% elsif @storage_driver == 'overlay2' -%> - <%- if @overlay2_override_kernel_check %> --storage-opt overlay2.override_kernel_check=<%= @overlay2_override_kernel_check %><% end -%> -<% end -%> -<% @labels.each do |label| %> --label <%= label %><% end -%> -<% if @extra_parameters %><% @extra_parameters_array.each do |param| %> <%= param %><% end %><% end -%> -" -<% if @shell_values %><% @shell_values_array.each do |param| %> -<%= param %><% end %><% end %> diff --git a/templates/etc/init.d/docker-run.erb b/templates/etc/init.d/docker-run.epp similarity index 66% rename from templates/etc/init.d/docker-run.erb rename to templates/etc/init.d/docker-run.epp index f7275740..df7aff60 100644 --- a/templates/etc/init.d/docker-run.erb +++ b/templates/etc/init.d/docker-run.epp @@ -1,12 +1,12 @@ <%- - @required_start = ["$network"] + - @sanitised_after_array.map{ |s| "#{@service_prefix}#{s}"} + - @sanitised_depends_array.map{ |s| "#{@service_prefix}#{s}"} + - @depend_services_array + $required_start = ["$network"] + + $sanitised_after_array.map |$s| { "${service_prefix}${s}"} + + $sanitised_depends_array.map |$s| { "${service_prefix}${s}"} + + $depend_services_array - @required_stop = ["$network"] + - @sanitised_depends_array.map{ |d| "#{@service_prefix}#{d}"} + - @depend_services_array + $required_stop = ["$network"] + + $sanitised_depends_array.map |$d| { "${service_prefix}${d}"} + + $depend_services_array -%> #!/bin/sh # @@ -15,21 +15,21 @@ # # /etc/rc.d/init.d/ # -# Daemon for <%= @title %> +# Daemon for <%= $title %> # # chkconfig: 2345 97 15 -# description: Docker container for <%= @title %> +# description: Docker container for <%= $title %> ### BEGIN INIT INFO -# Provides: <%= @service_prefix %><%= @sanitised_title %> -# Required-Start: <%= @required_start.uniq.join(" ") %> -# Required-Stop: <%= @required_stop.uniq.join(" ") %> +# Provides: <%= $service_prefix %><%= $sanitised_title %> +# Required-Start: <%= $required_start.unique.join(" ") %> +# Required-Stop: <%= $required_stop.unique.join(" ") %> # Should-Start: # Should-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 -# Short-Description: start and stop docker container for <%= @title %> -# Description: Docker container for <%= @title %> +# Short-Description: start and stop docker container for <%= $title %> +# Description: Docker container for <%= $title %> ### END INIT INFO if [ -e /etc/init.d/functions ]; then @@ -56,8 +56,8 @@ else fi export HOME=/root/ -docker="/usr/bin/<%= @docker_command %>" -prog="<%= @service_prefix %><%= @sanitised_title %>" +docker="/usr/bin/<%= $docker_command %>" +prog="<%= $service_prefix %><%= $sanitised_title %>" if [ -d /var/lock/subsys ]; then lockfile="/var/lock/subsys/$prog" else @@ -67,14 +67,14 @@ fi start() { [ -x $docker ] || exit 5 - if [ "true" = "$($docker inspect --format='{{.State.Running}}' <%= @sanitised_title %> 2>/dev/null)" ]; then + if [ "true" = "$($docker inspect --format='{{.State.Running}}' <%= $sanitised_title %> 2>/dev/null)" ]; then failure - printf "Container <%= @sanitised_title %> is still running.\n" + printf "Container <%= $sanitised_title %> is still running.\n" exit 7 fi printf "Starting $prog:\t" - <%= @docker_run_inline_start %> + <%= $docker_run_inline_start %> retval=$? echo @@ -87,7 +87,7 @@ start() { stop() { echo -n "Stopping $prog: " - <%= @docker_run_inline_stop %> + <%= $docker_run_inline_stop %> return $? } @@ -114,7 +114,7 @@ case "$1" in stop ;; status) - if [ "true" = "$($docker inspect --format='{{.State.Running}}' <%= @sanitised_title %> 2>/dev/null)" ]; then + if [ "true" = "$($docker inspect --format='{{.State.Running}}' <%= $sanitised_title %> 2>/dev/null)" ]; then echo $prog is running exit 0 else diff --git a/templates/etc/sysconfig/docker-storage-setup.epp b/templates/etc/sysconfig/docker-storage-setup.epp new file mode 100644 index 00000000..d339fde2 --- /dev/null +++ b/templates/etc/sysconfig/docker-storage-setup.epp @@ -0,0 +1,19 @@ +# This file is managed by Puppet and local changes +# may be overwritten + +# Edit this file to override any configuration options specified in +# /usr/lib/docker-storage-setup/docker-storage-setup. +# +# For more details refer to "man docker-storage-setup" + +<% if $storage_driver { %>STORAGE_DRIVER=<%= $storage_driver %><% } %> +<% if $storage_devs { %>DEVS="<%= $storage_devs %>"<% } %> +<% if $storage_vg { %>VG=<%= $storage_vg %><% } %> +<% if $storage_root_size { %>ROOT_SIZE=<%= $storage_root_size %><% } %> +<% if $storage_data_size { %>DATA_SIZE=<%= $storage_data_size %><% } %> +<% if $storage_min_data_size { %>MIN_DATA_SIZE=<%= $storage_min_data_size %><% } %> +<% if $storage_chunk_size { %>CHUNK_SIZE=<%= $storage_chunk_size %><% } %> +<% if $storage_growpart { %>GROWPART=<%= $storage_growpart %><% } %> +<% if $storage_auto_extend_pool { %>AUTO_EXTEND_POOL=<%= $storage_auto_extend_pool %><% } %> +<% if $storage_pool_autoextend_threshold { %>POOL_AUTOEXTEND_THRESHOLD=<%= $storage_pool_autoextend_threshold %><% } %> +<% if $storage_pool_autoextend_percent { %>POOL_AUTOEXTEND_PERCENT=<%= $storage_pool_autoextend_percent %><% } %> diff --git a/templates/etc/sysconfig/docker-storage-setup.erb b/templates/etc/sysconfig/docker-storage-setup.erb deleted file mode 100644 index 5f8ea142..00000000 --- a/templates/etc/sysconfig/docker-storage-setup.erb +++ /dev/null @@ -1,30 +0,0 @@ -# This file is managed by Puppet and local changes -# may be overwritten - -# Edit this file to override any configuration options specified in -# /usr/lib/docker-storage-setup/docker-storage-setup. -# -# For more details refer to "man docker-storage-setup" - -<% if @storage_driver %>STORAGE_DRIVER=<%= @storage_driver %> -<% end -%> -<% if @storage_devs %>DEVS="<%= @storage_devs %>" -<% end -%> -<% if @storage_vg %>VG=<%= @storage_vg %> -<% end -%> -<% if @storage_root_size %>ROOT_SIZE=<%= @storage_root_size %> -<% end -%> -<% if @storage_data_size %>DATA_SIZE=<%= @storage_data_size %> -<% end -%> -<% if @storage_min_data_size %>MIN_DATA_SIZE=<%= @storage_min_data_size %> -<% end -%> -<% if @storage_chunk_size %>CHUNK_SIZE=<%= @storage_chunk_size %> -<% end -%> -<% if @storage_growpart %>GROWPART=<%= @storage_growpart %> -<% end -%> -<% if @storage_auto_extend_pool %>AUTO_EXTEND_POOL=<%= @storage_auto_extend_pool %> -<% end -%> -<% if @storage_pool_autoextend_threshold %>POOL_AUTOEXTEND_THRESHOLD=<%= @storage_pool_autoextend_threshold %> -<% end -%> -<% if @storage_pool_autoextend_percent %>POOL_AUTOEXTEND_PERCENT=<%= @storage_pool_autoextend_percent %> -<% end -%> diff --git a/templates/etc/sysconfig/docker-storage.epp b/templates/etc/sysconfig/docker-storage.epp new file mode 100644 index 00000000..75b8c930 --- /dev/null +++ b/templates/etc/sysconfig/docker-storage.epp @@ -0,0 +1,39 @@ +# This file is managed by Puppet and local changes +# may be overwritten + +# This file may be automatically generated by an installation program. + +# By default, Docker uses a loopback-mounted sparse file in +# /var/lib/docker. The loopback makes it slower, and there are some +# restrictive defaults, such as 100GB max storage. + +# If your installation did not set a custom storage for Docker, you +# may do it below. + +# Example: Use a custom pair of raw logical volumes (one for metadata, +# one for data). +# DOCKER_STORAGE_OPTIONS = --storage-opt dm.metadatadev=/dev/mylogvol/my-docker-metadata --storage-opt dm.datadev=/dev/mylogvol/my-docker-data + +DOCKER_STORAGE_OPTIONS="<% -%> +<% if $storage_driver { %> --storage-driver=<%= $storage_driver %><% } -%> +<% if $storage_driver == 'devicemapper' { -%> + <%- if $dm_basesize { %> --storage-opt dm.basesize=<%= $dm_basesize %><% } -%> + <%- if $dm_fs { %> --storage-opt dm.fs=<%= $dm_fs %><% } -%> + <%- if $dm_mkfsarg { %> --storage-opt "dm.mkfsarg=<%= $dm_mkfsarg %>"<% } -%> + <%- if $dm_mountopt { %> --storage-opt dm.mountopt=<%= $dm_mountopt %><% } -%> + <%- if $dm_blocksize { %> --storage-opt dm.blocksize=<%= $dm_blocksize %><% } -%> + <%- if $dm_loopdatasize { %> --storage-opt dm.loopdatasize=<%= $dm_loopdatasize %><% } -%> + <%- if $dm_loopmetadatasize { %> --storage-opt dm.loopmetadatasize=<%= $dm_loopmetadatasize %><% } -%> + <%- if $dm_thinpooldev { %> --storage-opt dm.thinpooldev=<%= $dm_thinpooldev -%> + <%- }else { -%> + <%- if $dm_datadev { %> --storage-opt dm.datadev=<%= $dm_datadev %><% } -%> + <%- if $dm_metadatadev { %> --storage-opt dm.metadatadev=<%= $dm_metadatadev %><% } -%> + <%- } -%> +<%- if $dm_use_deferred_removal { %> --storage-opt dm.use_deferred_removal=<%= $dm_use_deferred_removal %><% } -%> +<%- if $dm_use_deferred_deletion { %> --storage-opt dm.use_deferred_deletion=<%= $dm_use_deferred_deletion %><% } -%> +<%- if $dm_blkdiscard { %> --storage-opt dm.blkdiscard=<%= $dm_blkdiscard %><% } -%> +<%- if $dm_override_udev_sync_check { %> --storage-opt dm.override_udev_sync_check=<%= $dm_override_udev_sync_check %><% } -%> +<% } elsif $storage_driver == 'overlay2' { -%> + <%- if $overlay2_override_kernel_check { %> --storage-opt overlay2.override_kernel_check=<%= $overlay2_override_kernel_check %><% } -%> +<% } -%> +" diff --git a/templates/etc/sysconfig/docker-storage.erb b/templates/etc/sysconfig/docker-storage.erb deleted file mode 100644 index c0c4a4d3..00000000 --- a/templates/etc/sysconfig/docker-storage.erb +++ /dev/null @@ -1,39 +0,0 @@ -# This file is managed by Puppet and local changes -# may be overwritten - -# This file may be automatically generated by an installation program. - -# By default, Docker uses a loopback-mounted sparse file in -# /var/lib/docker. The loopback makes it slower, and there are some -# restrictive defaults, such as 100GB max storage. - -# If your installation did not set a custom storage for Docker, you -# may do it below. - -# Example: Use a custom pair of raw logical volumes (one for metadata, -# one for data). -# DOCKER_STORAGE_OPTIONS = --storage-opt dm.metadatadev=/dev/mylogvol/my-docker-metadata --storage-opt dm.datadev=/dev/mylogvol/my-docker-data - -DOCKER_STORAGE_OPTIONS="<% -%> -<% if @storage_driver %> --storage-driver <%= @storage_driver %><% end -%> -<% if @storage_driver == 'devicemapper' -%> - <%- if @dm_basesize %> --storage-opt dm.basesize=<%= @dm_basesize %><% end -%> - <%- if @dm_fs %> --storage-opt dm.fs=<%= @dm_fs %><% end -%> - <%- if @dm_mkfsarg %> --storage-opt "dm.mkfsarg=<%= @dm_mkfsarg %>"<% end -%> - <%- if @dm_mountopt %> --storage-opt dm.mountopt=<%= @dm_mountopt %><% end -%> - <%- if @dm_blocksize %> --storage-opt dm.blocksize=<%= @dm_blocksize %><% end -%> - <%- if @dm_loopdatasize %> --storage-opt dm.loopdatasize=<%= @dm_loopdatasize %><% end -%> - <%- if @dm_loopmetadatasize %> --storage-opt dm.loopmetadatasize=<%= @dm_loopmetadatasize %><% end -%> - <%- if @dm_thinpooldev %> --storage-opt dm.thinpooldev=<%= @dm_thinpooldev -%> - <%- else -%> - <%- if @dm_datadev %> --storage-opt dm.datadev=<%= @dm_datadev %><% end -%> - <%- if @dm_metadatadev %> --storage-opt dm.metadatadev=<%= @dm_metadatadev %><% end -%> - <%- end -%> - <%- if @dm_use_deferred_removal %> --storage-opt dm.use_deferred_removal=<%= @dm_use_deferred_removal %><% end -%> - <%- if @dm_use_deferred_deletion %> --storage-opt dm.use_deferred_deletion=<%= @dm_use_deferred_deletion %><% end -%> - <%- if @dm_blkdiscard %> --storage-opt dm.blkdiscard=<%= @dm_blkdiscard %><% end -%> - <%- if @dm_override_udev_sync_check %> --storage-opt dm.override_udev_sync_check=<%= @dm_override_udev_sync_check %><% end -%> -<% elsif @storage_driver == 'overlay2' -%> - <%- if @overlay2_override_kernel_check %> --storage-opt overlay2.override_kernel_check=<%= @overlay2_override_kernel_check %><% end -%> -<% end -%> -" diff --git a/templates/etc/sysconfig/docker.epp b/templates/etc/sysconfig/docker.epp new file mode 100644 index 00000000..74ad0875 --- /dev/null +++ b/templates/etc/sysconfig/docker.epp @@ -0,0 +1,40 @@ +# This file is managed by Puppet and local changes +# may be overwritten + +DOCKER="/usr/bin/<%= $docker_command %>" + +other_args="<% -%> +<% if $root_dir { %><%= $root_dir_flag %> <%= $root_dir %><% } -%> +<% if $tcp_bind { %><% $tcp_bind_array.each |$param| { %> -H <%= $param %><% } %><% } -%> +<% if $tls_enable { %> --tls<% if $tls_verify { %> --tlsverify<% } %> --tlscacert=<%= $tls_cacert %> --tlscert=<%= $tls_cert %> --tlskey=<%= $tls_key %><% } -%> +<% if $socket_bind { %> -H <%= $socket_bind %><% } -%> + --ip-forward=<%= $ip_forward -%> + --iptables=<%= $iptables -%> + --ip-masq=<%= $ip_masq -%> +<% if $icc { %> --icc=<%= $icc %><% } -%> +<% if $fixed_cidr { %> --fixed-cidr <%= $fixed_cidr %><% } -%> +<% if $bridge { %> --bridge <%= $bridge %><% } -%> +<% if $default_gateway { %> --default-gateway <%= $default_gateway %><% } -%> +<% if $ipv6 { %> --ipv6<% } -%> +<% if $ipv6_cidr { %> --fixed-cidr-v6 <%= $ipv6_cidr %><% } -%> +<% if $default_gateway_ipv6 { %> --default-gateway-v6 <%= $default_gateway_ipv6 %><% } -%> +<% if $log_level { %> -l <%= $log_level %><% } -%> +<% if $log_driver { %> --log-driver <%= $log_driver %><% } -%> +<% if $log_driver { %><% if $log_opt { %><% $log_opt.each |$param| { %> --log-opt <%= $param %><% } %><% } -%><% } -%> +<% if $selinux_enabled { %> --selinux-enabled=<%= $selinux_enabled %><% } -%> +<% if $socket_group { %> -G <%= $socket_group %><% } -%> +<% if $dns { %><% $dns_array.each |$address| { %> --dns <%= $address %><% } %><% } -%> +<% if $dns_search { %><% $dns_search_array.each |$domain| { %> --dns-search <%= $domain %><% } %><% } -%> +<% if $execdriver { %> -e <%= $execdriver %><% } -%> +<% if $bip { %> --bip=<%= $bip %><% } -%> +<% if $mtu { %> --mtu=<%= $mtu %><% } -%> +<% $labels.each |$label| { %> --label <%= $label %><% } -%> +<% if $extra_parameters { %><% $extra_parameters_array.each |$param| { %> <%= $param %><% } %><% } -%>" + +<% if $proxy { %>export http_proxy='<%= $proxy %>' +export https_proxy='<%= $proxy %>'<% } %> +<% if $no_proxy { %>export no_proxy='<%= $no_proxy %>'<% } %> +# This is also a handy place to tweak where Docker's temporary files go. +export TMPDIR="<%= $tmp_dir %>" +<% if $shell_values { %><% $shell_values_array.each |$param| { %> +<%= $param %><% } %><% } -%> diff --git a/templates/etc/sysconfig/docker.erb b/templates/etc/sysconfig/docker.erb deleted file mode 100644 index 22d9565f..00000000 --- a/templates/etc/sysconfig/docker.erb +++ /dev/null @@ -1,40 +0,0 @@ -# This file is managed by Puppet and local changes -# may be overwritten - -DOCKER="/usr/bin/<%= @docker_command %>" - -other_args="<% -%> -<% if @root_dir %><%= @root_dir_flag %> <%= @root_dir %><% end -%> -<% if @tcp_bind %><% @tcp_bind_array.each do |param| %> -H <%= param %><% end %> <% end -%> -<% if @tls_enable %> --tls<% if @tls_verify -%> --tlsverify<% end -%> --tlscacert=<%= @tls_cacert %> --tlscert=<%= @tls_cert %> --tlskey=<%= @tls_key %><% end -%> -<% if @socket_bind %> -H <%= @socket_bind %><% end -%> - --ip-forward=<%= @ip_forward -%> - --iptables=<%= @iptables -%> - --ip-masq=<%= @ip_masq -%> -<% unless @icc == nil %> --icc=<%= @icc %><% end -%> -<% if @fixed_cidr %> --fixed-cidr <%= @fixed_cidr %><% end -%> -<% if @bridge %> --bridge <%= @bridge %><% end -%> -<% if @default_gateway %> --default-gateway <%= @default_gateway %><% end -%> -<% if @ipv6 %> --ipv6<% end -%> -<% if @ipv6_cidr %> --fixed-cidr-v6 <%= @ipv6_cidr %><% end -%> -<% if @default_gateway_ipv6 %> --default-gateway-v6 <%= @default_gateway_ipv6 %><% end -%> -<% if @log_level %> -l <%= @log_level %><% end -%> -<% if @log_driver %> --log-driver <%= @log_driver %><% end -%> -<% if @log_driver %><% if @log_opt %><% @log_opt.each do |param| %> --log-opt <%= param %><% end %><% end -%><% end -%> -<% if @selinux_enabled %> --selinux-enabled=<%= @selinux_enabled %><% end -%> -<% if @socket_group %> -G <%= @socket_group %><% end -%> -<% if @dns %><% @dns_array.each do |address| %> --dns <%= address %><% end %><% end -%> -<% if @dns_search %><% @dns_search_array.each do |domain| %> --dns-search <%= domain %><% end %><% end -%> -<% if @execdriver %> -e <%= @execdriver %> <% end -%> -<% if @bip %> --bip=<%= @bip %> <% end -%> -<% if @mtu %> --mtu=<%= @mtu %> <% end -%> -<% @labels.each do |label| %> --label <%= label %><% end -%> -<% if @extra_parameters %><% @extra_parameters_array.each do |param| %> <%= param %><% end %><% end -%>" - -<% if @proxy %>export http_proxy='<%= @proxy %>' -export https_proxy='<%= @proxy %>'<% end %> -<% if @no_proxy %>export no_proxy='<%= @no_proxy %>'<% end %> -# This is also a handy place to tweak where Docker's temporary files go. -export TMPDIR="<%= @tmp_dir %>" -<% if @shell_values %><% @shell_values_array.each do |param| %> -<%= param %><% end %><% end -%> diff --git a/templates/etc/sysconfig/docker.systemd.epp b/templates/etc/sysconfig/docker.systemd.epp new file mode 100644 index 00000000..56b09d36 --- /dev/null +++ b/templates/etc/sysconfig/docker.systemd.epp @@ -0,0 +1,38 @@ +# This file is managed by Puppet and local changes +# may be overwritten + +OPTIONS="<% if $root_dir { %><%= $root_dir_flag %> <%= $root_dir %><% } -%> +<% if $tcp_bind { %><% $tcp_bind_array.each |$param| { %> -H <%= $param %><% } %><% } -%> +<% if $tls_enable { %> --tls<% if $tls_verify { %> --tlsverify<% } %> --tlscacert=<%= $tls_cacert %> --tlscert=<%= $tls_cert %> --tlskey=<%= $tls_key %><% } -%> +<% if $socket_bind { %> -H <%= $socket_bind %><% } -%> + --ip-forward=<%= $ip_forward -%> + --iptables=<%= $iptables -%> + --ip-masq=<%= $ip_masq -%> +<% if $icc { %> --icc=<%= $icc %><% } -%> +<% if type($registry_mirror, 'generalized') == String { %> --registry-mirror=<%= $registry_mirror %><% } -%> +<% if String(type($registry_mirror, 'generalized')).index('Array') == 0 { %><% $registry_mirror.each |$param| { %> --registry-mirror=<%= $param %><% } %><% } -%> +<% if $fixed_cidr { %> --fixed-cidr <%= $fixed_cidr %><% } -%> +<% if $default_gateway { %> --default-gateway <%= $default_gateway %><% } -%> +<% if $ipv6 { %> --ipv6<% } -%> +<% if $ipv6_cidr { %> --fixed-cidr-v6 <%= $ipv6_cidr %><% } -%> +<% if $default_gateway_ipv6 { %> --default-gateway-v6 <%= $default_gateway_ipv6 %><% } -%> +<% if $bridge { %> --bridge <%= $bridge %><% } -%> +<% if $log_level { %> -l <%= $log_level %><% } -%> +<% if $log_driver { %> --log-driver <%= $log_driver %><% } -%> +<% if $log_driver { %><% if $log_opt { %><% $log_opt.each |$param| { %> --log-opt <%= $param %><% } %><% } -%><% } -%> +<% if $selinux_enabled { %> --selinux-enabled=<%= $selinux_enabled %><% } -%> +<% if $socket_group { %> -G <%= $socket_group %><% } -%> +<% if $dns { %><% $dns_array.each |$address| { %> --dns <%= $address %><% } %><% } -%> +<% if $dns_search { %><% $dns_search_array.each |$domain| { %> --dns-search <%= $domain %><% } %><% } -%> +<% if $execdriver { %> -e <%= $execdriver %><% } -%> +<% if $bip { %> --bip=<%= $bip %><% } -%> +<% if $mtu { %> --mtu=<%= $mtu %><% } -%> +<% if $labels { %><% $labels_array.each |$label| { %> --label <%= $label %><% } %><% } -%> +<% if $extra_parameters { %><% $extra_parameters_array.each |$param| { %> <%= $param %><% } %><% } -%>" + +<% if $proxy { %>http_proxy='<%= $proxy %>' + https_proxy='<%= $proxy %>'<% } %> +<% if $no_proxy { %>no_proxy='<%= $no_proxy %>'<% } %> +# This is also a handy place to tweak where Docker's temporary files go. +<% if $tmp_dir_config { %>TMPDIR="<%= $tmp_dir %>"<% }else { %># TMPDIR="<%= $tmp_dir %>"<% } %> +<% if $shell_values { %><% $shell_values_array.each |$param| { %> <%= $param %><% } %><% } -%> diff --git a/templates/etc/sysconfig/docker.systemd.erb b/templates/etc/sysconfig/docker.systemd.erb deleted file mode 100644 index 42198ef4..00000000 --- a/templates/etc/sysconfig/docker.systemd.erb +++ /dev/null @@ -1,38 +0,0 @@ -# This file is managed by Puppet and local changes -# may be overwritten - -OPTIONS="<% if @root_dir %><%= @root_dir_flag %> <%= @root_dir %><% end -%> -<% if @tcp_bind %><% @tcp_bind_array.each do |param| %> -H <%= param %><% end %> <% end -%> -<% if @tls_enable %> --tls<% if @tls_verify -%> --tlsverify<% end -%> --tlscacert=<%= @tls_cacert %> --tlscert=<%= @tls_cert %> --tlskey=<%= @tls_key %><% end -%> -<% if @socket_bind %> -H <%= @socket_bind %><% end -%> - --ip-forward=<%= @ip_forward -%> - --iptables=<%= @iptables -%> - --ip-masq=<%= @ip_masq -%> -<% unless @icc == nil %> --icc=<%= @icc %><% end -%> -<% if @registry_mirror.is_a? String %> --registry-mirror=<%= @registry_mirror %><% end -%> -<% if @registry_mirror.is_a? Array %><% @registry_mirror.each do |param| %> --registry-mirror=<%= param %><% end %><% end -%> -<% if @fixed_cidr %> --fixed-cidr <%= @fixed_cidr %><% end -%> -<% if @default_gateway %> --default-gateway <%= @default_gateway %><% end -%> -<% if @ipv6 %> --ipv6<% end -%> -<% if @ipv6_cidr %> --fixed-cidr-v6 <%= @ipv6_cidr %><% end -%> -<% if @default_gateway_ipv6 %> --default-gateway-v6 <%= @default_gateway_ipv6 %><% end -%> -<% if @bridge %> --bridge <%= @bridge %><% end -%> -<% if @log_level %> -l <%= @log_level %><% end -%> -<% if @log_driver %> --log-driver <%= @log_driver %><% end -%> -<% if @log_driver %><% if @log_opt %><% @log_opt.each do |param| %> --log-opt <%= param %><% end %><% end -%><% end -%> -<% if @selinux_enabled %> --selinux-enabled=<%= @selinux_enabled %><% end -%> -<% if @socket_group %> -G <%= @socket_group %><% end -%> -<% if @dns %><% @dns_array.each do |address| %> --dns <%= address %><% end %><% end -%> -<% if @dns_search %><% @dns_search_array.each do |domain| %> --dns-search <%= domain %><% end %><% end -%> -<% if @execdriver %> -e <%= @execdriver %> <% end -%> -<% if @bip %> --bip=<%= @bip %> <% end -%> -<% if @mtu %> --mtu=<%= @mtu %> <% end -%> -<% if @labels %><% @labels_array.each do |label| %> --label <%= label %><% end %><% end -%> -<% if @extra_parameters %><% @extra_parameters_array.each do |param| %> <%= param %><% end %><% end -%>" - -<% if @proxy %>http_proxy='<%= @proxy %>' - https_proxy='<%= @proxy %>'<% end %> -<% if @no_proxy %>no_proxy='<%= @no_proxy %>'<% end %> -# This is also a handy place to tweak where Docker's temporary files go. -<% if @tmp_dir_config %>TMPDIR="<%= @tmp_dir %>"<% else %># TMPDIR="<%= @tmp_dir %>"<% end %> -<% if @shell_values %><% @shell_values_array.each do |param| %> <%= param %><% end %><% end -%> diff --git a/templates/etc/systemd/system/docker-run.epp b/templates/etc/systemd/system/docker-run.epp new file mode 100644 index 00000000..92990cbb --- /dev/null +++ b/templates/etc/systemd/system/docker-run.epp @@ -0,0 +1,63 @@ +<%- + $depend_services = $depend_services_array.map |$s| { if $s =~ /\.[a-z]+$/ { $s }else { "${s}.service" } } + $after = $sanitised_after_array.map |$s| { "${service_prefix}${s}.service" } + + $sanitised_depends_array.map |$s| { "${service_prefix}${s}.service"} + + $depend_services + $wants = $sanitised_after_array.map |$a| { "${service_prefix}${a}.service" } + $requires = $sanitised_depends_array.map |$d| { "${service_prefix}${d}.service" } + + $depend_services +-%> +# This file is managed by Puppet and local changes +# may be overwritten + +[Unit] +Description=Daemon for <%= $title %> +After=<%= $after.unique.join(" ") %> +Wants=<%= $wants.unique.join(" ") %> +Requires=<%= $requires.unique.join(" ") %> +<%- if $have_systemd_v230 { -%> +StartLimitIntervalSec=20 +StartLimitBurst=3 +<% } -%> +<%- if $extra_systemd_parameters['Unit'] { -%> + <%- $extra_systemd_parameters['Unit'].each |$key, $value| { %> +<%= $key %>=<%= $value %> + <%- } -%> +<% } -%> + +[Service] +Restart=<%= $systemd_restart %> +<%- unless $have_systemd_v230 { -%> +StartLimitInterval=20 +StartLimitBurst=3 +<% } -%> +TimeoutStartSec=0 +RestartSec=5 +Environment="HOME=/root" +<%- if $_syslog_identifier { -%> +SyslogIdentifier=<%= $_syslog_identifier %> +<% } -%> +<%- if $syslog_facility { -%> +SyslogFacility=<%= $syslog_facility %> +<% } -%> +ExecStart=/usr/local/bin/docker-run-<%= $sanitised_title %>-start.sh +ExecStop=-/usr/local/bin/docker-run-<%= $sanitised_title %>-stop.sh +<%- if $remain_after_exit { %> +RemainAfterExit=<%= $remain_after_exit %> +<% } -%> +<%- if $extra_systemd_parameters['Service'] { -%> + <%- $extra_systemd_parameters['Service'].each |$key, $value| { -%> +<%= $key %>=<%= $value %> + <%- } -%> +<% } -%> + +[Install] +WantedBy=multi-user.target +<%- if $service_name { -%> +WantedBy=<%= $service_name %>.service +<% } -%> +<%- if $extra_systemd_parameters['Install'] { -%> + <%- $extra_systemd_parameters['Install'].each |$key, $value| { -%> +<%= $key %>=<%= $value %> + <%- } -%> +<% } -%> diff --git a/templates/etc/systemd/system/docker-run.erb b/templates/etc/systemd/system/docker-run.erb deleted file mode 100644 index 916063e2..00000000 --- a/templates/etc/systemd/system/docker-run.erb +++ /dev/null @@ -1,63 +0,0 @@ -<%- - depend_services = @depend_services_array.map{|s| s =~ /\.[a-z]+$/ ? s : "#{s}.service"} - @after = @sanitised_after_array.map{ |s| "#{@service_prefix}#{s}.service"} + - @sanitised_depends_array.map{ |s| "#{@service_prefix}#{s}.service"} + - depend_services - @wants = @sanitised_after_array.map{ |a| "#{@service_prefix}#{a}.service"} - @requires = @sanitised_depends_array.map{ |d| "#{@service_prefix}#{d}.service"} + - depend_services --%> -# This file is managed by Puppet and local changes -# may be overwritten - -[Unit] -Description=Daemon for <%= @title %> -After=<%= @after.uniq.join(" ") %> -Wants=<%= @wants.uniq.join(" ") %> -Requires=<%= @requires.uniq.join(" ") %> -<%- if @have_systemd_v230 -%> -StartLimitIntervalSec=20 -StartLimitBurst=3 -<%- end -%> -<%- if @extra_systemd_parameters['Unit'] -%> -<%- @extra_systemd_parameters['Unit'].each do |key,value| -%> -<%= key %>=<%= value %> -<%- end -%> -<%- end -%> - -[Service] -Restart=<%= @systemd_restart %> -<%- unless @have_systemd_v230 -%> -StartLimitInterval=20 -StartLimitBurst=3 -<%- end -%> -TimeoutStartSec=0 -RestartSec=5 -Environment="HOME=/root" -<%- if @_syslog_identifier -%> -SyslogIdentifier=<%= @_syslog_identifier %> -<%- end -%> -<%- if @syslog_facility -%> -SyslogFacility=<%= @syslog_facility %> -<%- end -%> -ExecStart=/usr/local/bin/docker-run-<%= @sanitised_title %>-start.sh -ExecStop=-/usr/local/bin/docker-run-<%= @sanitised_title %>-stop.sh -<%- if @remain_after_exit %> -RemainAfterExit=<%= @remain_after_exit %> -<%- end -%> -<%- if @extra_systemd_parameters['Service'] -%> -<%- @extra_systemd_parameters['Service'].each do |key,value| -%> -<%= key %>=<%= value %> -<%- end -%> -<%- end -%> - -[Install] -WantedBy=multi-user.target -<%- if @service_name -%> -WantedBy=<%= @service_name %>.service -<%- end -%> -<%- if @extra_systemd_parameters['Install'] -%> -<%- @extra_systemd_parameters['Install'].each do |key,value| -%> -<%= key %>=<%= value %> -<%- end -%> -<%- end -%> diff --git a/templates/etc/systemd/system/docker.service.d/service-overrides-debian.conf.erb b/templates/etc/systemd/system/docker.service.d/service-overrides-debian.conf.epp similarity index 50% rename from templates/etc/systemd/system/docker.service.d/service-overrides-debian.conf.erb rename to templates/etc/systemd/system/docker.service.d/service-overrides-debian.conf.epp index d7463095..c921cc43 100644 --- a/templates/etc/systemd/system/docker.service.d/service-overrides-debian.conf.erb +++ b/templates/etc/systemd/system/docker.service.d/service-overrides-debian.conf.epp @@ -1,11 +1,11 @@ -<% if @service_after_override -%> +<% if $service_after_override { -%> [Unit] -After=<%= @service_after_override %> +After=<%= $service_after_override %> +<% } -%> -<% end -%> [Service] EnvironmentFile=-/etc/default/docker EnvironmentFile=-/etc/default/docker-storage ExecStart= -ExecStart=/usr/bin/<%= @docker_start_command %> $OPTIONS \ +ExecStart=/usr/bin/<%= $docker_start_command %> $OPTIONS \ $DOCKER_STORAGE_OPTIONS diff --git a/templates/etc/systemd/system/docker.service.d/service-overrides-rhel.conf.erb b/templates/etc/systemd/system/docker.service.d/service-overrides-rhel.conf.epp similarity index 50% rename from templates/etc/systemd/system/docker.service.d/service-overrides-rhel.conf.erb rename to templates/etc/systemd/system/docker.service.d/service-overrides-rhel.conf.epp index 2313e93c..4bf078a4 100644 --- a/templates/etc/systemd/system/docker.service.d/service-overrides-rhel.conf.erb +++ b/templates/etc/systemd/system/docker.service.d/service-overrides-rhel.conf.epp @@ -1,16 +1,16 @@ -<% if @service_after_override -%> +<% if $service_after_override { -%> [Unit] -After=<%= @service_after_override %> +After=<%= $service_after_override %> +<% } -%> -<% end -%> [Service] EnvironmentFile=-/etc/sysconfig/docker EnvironmentFile=-/etc/sysconfig/docker-storage EnvironmentFile=-/etc/sysconfig/docker-network -<% if @daemon_environment_files %><% @daemon_environment_files.each do |param| %>EnvironmentFile=-<%= param %> -<% end %><% end -%> +<% if $daemon_environment_files { %><% $daemon_environment_files.each |$param| { %>EnvironmentFile=-<%= $param %> +<% } %><% } -%> ExecStart= -ExecStart=/usr/bin/<%= @docker_start_command %> $OPTIONS \ +ExecStart=/usr/bin/<%= $docker_start_command %> $OPTIONS \ $DOCKER_STORAGE_OPTIONS \ $DOCKER_NETWORK_OPTIONS \ $BLOCK_REGISTRY \ diff --git a/templates/etc/systemd/system/docker.socket.d/socket-overrides.conf.epp b/templates/etc/systemd/system/docker.socket.d/socket-overrides.conf.epp new file mode 100644 index 00000000..e13040e2 --- /dev/null +++ b/templates/etc/systemd/system/docker.socket.d/socket-overrides.conf.epp @@ -0,0 +1,2 @@ +[Socket] +SocketGroup=<%= $socket_group %> diff --git a/templates/etc/systemd/system/docker.socket.d/socket-overrides.conf.erb b/templates/etc/systemd/system/docker.socket.d/socket-overrides.conf.erb deleted file mode 100644 index d6663a3b..00000000 --- a/templates/etc/systemd/system/docker.socket.d/socket-overrides.conf.erb +++ /dev/null @@ -1,2 +0,0 @@ -[Socket] -SocketGroup=<%= @socket_group %> diff --git a/templates/update_docker_image.sh.erb b/templates/update_docker_image.sh.epp similarity index 93% rename from templates/update_docker_image.sh.erb rename to templates/update_docker_image.sh.epp index 577e5f94..04e01abc 100644 --- a/templates/update_docker_image.sh.erb +++ b/templates/update_docker_image.sh.epp @@ -8,7 +8,7 @@ DOCKER_IMAGE=$1 BEFORE=$(docker inspect --type image --format='{{.Id}}' ${DOCKER_IMAGE} 2>/dev/null) -<%= @docker_command -%> pull ${DOCKER_IMAGE} +<%= $docker_command %> pull ${DOCKER_IMAGE} AFTER=$(docker inspect --type image --format='{{.Id}}' ${DOCKER_IMAGE} 2>/dev/null) if [[ -z $AFTER ]]; then diff --git a/templates/windows/check_docker.ps1.erb b/templates/windows/check_docker.ps1.epp similarity index 85% rename from templates/windows/check_docker.ps1.erb rename to templates/windows/check_docker.ps1.epp index d86552be..3f3813f9 100644 --- a/templates/windows/check_docker.ps1.erb +++ b/templates/windows/check_docker.ps1.epp @@ -2,7 +2,7 @@ $dockerProviderName="DockerProvider" Write-Information "Checking Docker package." -$package=Get-Package <%= @docker_ee_package_name %> -ProviderName $dockerProviderName -ErrorAction Ignore +$package=Get-Package <%= $docker_ee_package_name %> -ProviderName $dockerProviderName -ErrorAction Ignore if ($package -ne $null) { Exit 1 } @@ -16,4 +16,4 @@ if (Test-Path -Path "$env:ProgramFiles\docker") { exit 1 } -exit 0 \ No newline at end of file +exit 0 diff --git a/templates/windows/check_docker_url.ps1.erb b/templates/windows/check_docker_url.ps1.epp similarity index 86% rename from templates/windows/check_docker_url.ps1.erb rename to templates/windows/check_docker_url.ps1.epp index 196e1c69..bb7180aa 100644 --- a/templates/windows/check_docker_url.ps1.erb +++ b/templates/windows/check_docker_url.ps1.epp @@ -3,7 +3,7 @@ $dockerLocation = Join-Path $env:TEMP "docker.zip" if ((test-path $dockerLocation)) { $localModified = (Get-Item $dockerLocation).LastWriteTime - $webRequest = [System.Net.HttpWebRequest]::Create("<%= @docker_download_url %>"); + $webRequest = [System.Net.HttpWebRequest]::Create("<%= $docker_download_url %>"); $webRequest.Method = "HEAD"; $webResponse = $webRequest.GetResponse() $remoteLastModified = ($webResponse.LastModified) -as [DateTime] @@ -19,4 +19,4 @@ if ((test-path $dockerLocation)) } } -exit 1 \ No newline at end of file +exit 1 diff --git a/templates/windows/check_powershell_provider.ps1.erb b/templates/windows/check_powershell_provider.ps1.epp similarity index 77% rename from templates/windows/check_powershell_provider.ps1.erb rename to templates/windows/check_powershell_provider.ps1.epp index 039ecb1d..3473aaf9 100644 --- a/templates/windows/check_powershell_provider.ps1.erb +++ b/templates/windows/check_powershell_provider.ps1.epp @@ -9,14 +9,13 @@ If ($module -eq $null) { Exit 1 } -<% if @nuget_package_provider_version -%> +<% if $nuget_package_provider_version { -%> Write-Information "Checking Package provider version" -if ($module.Version.ToString() -ne "<%= @nuget_package_provider_version %>" ) { +if ($module.Version.ToString() -ne "<%= $nuget_package_provider_version %>" ) { Write-Error "Incorrect Microsoft Nuget provider version installed" Exit 1 } -<% end -%> - +<% } -%> Write-Information "Checking Docker Provider" $provider = Get-Module -ListAvailable -Name $dockerProviderName -ErrorAction SilentlyContinue @@ -25,25 +24,25 @@ If ($provider -eq $null) { Exit 1 } -<% if @docker_msft_provider_version -%> +<% if $docker_msft_provider_version { -%> Write-Information "Checking Docker provider version" -if ($provider.Version.ToString() -ne "<%= @docker_msft_provider_version %>" ) { +if ($provider.Version.ToString() -ne "<%= $docker_msft_provider_version %>" ) { Write-Error "Incorrect Microsoft Docker Provider version installed." Exit 1 } -<% end -%> +<% } -%> Write-Information "Checking Docker package." -$package=Get-Package <%= @docker_ee_package_name %> -ProviderName $dockerProviderName -ErrorAction SilentlyContinue +$package=Get-Package <%= $docker_ee_package_name %> -ProviderName $dockerProviderName -ErrorAction SilentlyContinue If ($package -eq $null) { Write-Error "Docker package is not installed." Exit 1 } -<% if @version -%> +<% if $version { -%> Write-Information "Checking Docker package version" -if ($package.Version.ToString() -notmatch "<%= @version %>"){ +if ($package.Version.ToString() -notmatch "<%= $version %>"){ Write-Error "Incorrect Docker package version installed." Exit 1 } -<% end %> +<% } %> diff --git a/templates/windows/config/daemon.json.epp b/templates/windows/config/daemon.json.epp new file mode 100644 index 00000000..a269d9f0 --- /dev/null +++ b/templates/windows/config/daemon.json.epp @@ -0,0 +1,23 @@ +{ + <% if $dns { %> "dns": <%= $dns_array.to_json %>,<% } -%> + <% if $dns_search { %> "dns-search": <%= $dns_search_array.to_json %>,<% } -%> + <% if $log_driver { %> "log-driver": "<%= $log_driver %>", <% } -%> + <% if $mtu { %> "mtu": <%= $mtu %>,<% } -%> + <% if $tcp_bind { %> "hosts": <%= $tcp_bind_array.to_json %>,<% } -%> + <% if $log_level { %> "log-level": "<%= $log_level %>",<% } -%> + <% if $tls_enable { %> "tlsverify": true, + "tlscacert": "<%= $tls_cacert %>", + "tlscert": "<%= $tls_cert %>", + "tlskey": "<%= $tls_key %>", + <% } -%> + <% if $socket_group { %>"group": "<%= $socket_group %>",<% } -%> + <% if $bridge { %>"bridge": "<%= $bridge %>",<% } -%> + <% if $fixed_cidr { %>"fixed-cidr": "<%= $fixed_cidr %>",<% } -%> + <% if type($registry_mirror, 'generalized') == String { %>"registry-mirrors": ["<%= $registry_mirror %>"], <% } -%> + <% if String(type($registry_mirror, 'generalized')).index('Array') == 0 { %>"registry-mirrors": ["<%= $registry_mirror.join('", "') %>"], <% } -%> + <% if $extra_parameters { %><% $extra_parameters_array.each |$param| { %> + <%= $param %> ,<% } %> + <% } -%> + <% if $root_dir { %>"data-root": "<%= $root_dir %>",<% } -%> + "labels": <%= $labels_array.to_json %> +} diff --git a/templates/windows/config/daemon.json.erb b/templates/windows/config/daemon.json.erb deleted file mode 100644 index d19f4e9b..00000000 --- a/templates/windows/config/daemon.json.erb +++ /dev/null @@ -1,23 +0,0 @@ -{ - <% if @dns %> "dns": <%= @dns_array.to_json %>,<% end -%> - <% if @dns_search %> "dns-search": <%= @dns_search_array.to_json %>,<% end -%> - <% if @log_driver %> "log-driver": "<%= @log_driver %>", <% end -%> - <% if @mtu %> "mtu": <%= @mtu %>, <% end -%> - <% if @tcp_bind %> "hosts": <%= @tcp_bind_array.to_json %>, <% end -%> - <% if @log_level %> "log-level": "<%= @log_level %>", <% end -%> - <% if @tls_enable %> "tlsverify": true, - "tlscacert": "<%= @tls_cacert %>", - "tlscert": "<%= @tls_cert %>", - "tlskey": "<%= @tls_key %>", - <% end -%> - <% if @socket_group %>"group": "<%= @socket_group %>",<% end -%> - <% if @bridge %>"bridge": "<%= @bridge %>",<% end -%> - <% if @fixed_cidr %>"fixed-cidr": "<%= @fixed_cidr %>",<% end -%> - <% if @registry_mirror.is_a? String %>"registry-mirrors": ["<%= @registry_mirror %>"], <% end -%> - <% if @registry_mirror.is_a? Array %>"registry-mirrors": ["<%= @registry_mirror.join('", "') %>"], <% end -%> - <% if @extra_parameters %><% @extra_parameters_array.each do |param| %> - <%= param %> ,<% end %> - <% end -%> - <% if @root_dir %>"data-root": "<%= @root_dir %>",<% end -%> - "labels": <%= @labels_array.to_json %> -} diff --git a/templates/windows/download_docker.ps1.erb b/templates/windows/download_docker.ps1.epp similarity index 98% rename from templates/windows/download_docker.ps1.erb rename to templates/windows/download_docker.ps1.epp index 29401a08..b8e2f752 100644 --- a/templates/windows/download_docker.ps1.erb +++ b/templates/windows/download_docker.ps1.epp @@ -1,7 +1,7 @@ [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $dockerLocation = Join-Path $env:TEMP "docker.zip" -Invoke-webrequest -UseBasicparsing -Outfile $dockerLocation "<%= @docker_download_url %>" +Invoke-webrequest -UseBasicparsing -Outfile $dockerLocation "<%= $docker_download_url %>" $cleanInstall = $false @@ -37,4 +37,4 @@ if ($cleanInstall) { # Register the Docker daemon as a service. dockerd --register-service -} \ No newline at end of file +} diff --git a/templates/windows/download_docker_compose.ps1.erb b/templates/windows/download_docker_compose.ps1.epp similarity index 74% rename from templates/windows/download_docker_compose.ps1.erb rename to templates/windows/download_docker_compose.ps1.epp index 1b003e3f..d87e9e48 100644 --- a/templates/windows/download_docker_compose.ps1.erb +++ b/templates/windows/download_docker_compose.ps1.epp @@ -1,9 +1,9 @@ try { $WebClient = New-Object System.Net.WebClient -<%if @proxy %> -$uri = New-Object Uri("<%= @proxy %>") +<%if $proxy { %> +$uri = New-Object Uri("<%= $proxy %>") if ($uri.UserInfo -eq $null) { - $WebProxy = New-Object System.Net.WebProxy("<%= @proxy %>",$true) + $WebProxy = New-Object System.Net.WebProxy("<%= $proxy %>",$true) $WebClient.Proxy = $WebProxy } else { @@ -13,11 +13,11 @@ else { $WebClient.Proxy = $WebProxy $WebClient.Proxy.Credentials = New-Object System.Net.NetworkCredential($user, $password) } -<% end %> +<% } %> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - $WebClient.DownloadFile("<%= @docker_compose_url %>","<%= @docker_compose_location_versioned %>") + $WebClient.DownloadFile("<%= $docker_compose_url %>","<%= $docker_compose_location_versioned %>") } catch { exit 1 } -exit 0 \ No newline at end of file +exit 0 diff --git a/templates/windows/download_docker_machine.ps1.erb b/templates/windows/download_docker_machine.ps1.epp similarity index 74% rename from templates/windows/download_docker_machine.ps1.erb rename to templates/windows/download_docker_machine.ps1.epp index 229dd6b9..ab278fb4 100644 --- a/templates/windows/download_docker_machine.ps1.erb +++ b/templates/windows/download_docker_machine.ps1.epp @@ -1,9 +1,9 @@ try { $WebClient = New-Object System.Net.WebClient -<%if @proxy %> -$uri = New-Object Uri("<%= @proxy %>") +<%if $proxy { %> +$uri = New-Object Uri("<%= $proxy %>") if ($uri.UserInfo -eq $null) { - $WebProxy = New-Object System.Net.WebProxy("<%= @proxy %>",$true) + $WebProxy = New-Object System.Net.WebProxy("<%= $proxy %>",$true) $WebClient.Proxy = $WebProxy } else { @@ -13,11 +13,11 @@ else { $WebClient.Proxy = $WebProxy $WebClient.Proxy.Credentials = New-Object System.Net.NetworkCredential($user, $password) } -<% end %> +<% } %> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - $WebClient.DownloadFile("<%= @docker_machine_url %>","<%= @docker_machine_location_versioned %>") + $WebClient.DownloadFile("<%= $docker_machine_url %>","<%= $docker_machine_location_versioned %>") } catch { exit 1 } -exit 0 \ No newline at end of file +exit 0 diff --git a/templates/windows/install_powershell_provider.ps1.erb b/templates/windows/install_powershell_provider.ps1.epp similarity index 67% rename from templates/windows/install_powershell_provider.ps1.erb rename to templates/windows/install_powershell_provider.ps1.epp index e4e984b8..0def528a 100644 --- a/templates/windows/install_powershell_provider.ps1.erb +++ b/templates/windows/install_powershell_provider.ps1.epp @@ -3,7 +3,7 @@ $dockerProviderName="DockerProvider" Write-Information "Installing Package Provider" -$module = Install-PackageProvider NuGet -Force <%= "-RequiredVersion #{@nuget_package_provider_version}" if @nuget_package_provider_version %> +$module = Install-PackageProvider NuGet -Force <% if $nuget_package_provider_version { %><%= "-RequiredVersion ${nuget_package_provider_version}" %><% } %> If ($module -eq $null) { Write-Error "Failed to install NuGet Package Provider" @@ -11,7 +11,7 @@ If ($module -eq $null) { } Write-Information "Installing Docker Provider" -Install-Module $dockerProviderName -Force <%= "-RequiredVersion #{@docker_msft_provider_version}" if @docker_msft_provider_version %> +Install-Module $dockerProviderName -Force <% if $docker_msft_provider_version { %><%= "-RequiredVersion ${docker_msft_provider_version}" %><% } %> $provider = Get-Module -ListAvailable -Name $dockerProviderName If ($provider -eq $null) { @@ -20,7 +20,7 @@ If ($provider -eq $null) { } Write-Information "Installing Docker Package" -$package=Install-Package Docker -ProviderName $dockerProviderName -Force <%= "-RequiredVersion #{@version}" if @version %> +$package=Install-Package Docker -ProviderName $dockerProviderName -Force <% if $version { %><%= "-RequiredVersion ${version}" %><% } %> If ($package -eq $null) { Write-Error "Failed to install Docker Package" diff --git a/templates/windows/remove_docker.ps1.erb b/templates/windows/remove_docker.ps1.epp similarity index 88% rename from templates/windows/remove_docker.ps1.erb rename to templates/windows/remove_docker.ps1.epp index 76c23295..006c4042 100644 --- a/templates/windows/remove_docker.ps1.erb +++ b/templates/windows/remove_docker.ps1.epp @@ -1,13 +1,13 @@ # this file install the Windows Docker package using the DockerProvider powershell provider $dockerProviderName="DockerProvider" -$package=Get-Package <%= @docker_ee_package_name %> -ProviderName $dockerProviderName -ErrorAction Ignore +$package=Get-Package <%= $docker_ee_package_name %> -ProviderName $dockerProviderName -ErrorAction Ignore If ($package -ne $null) { Write-Information "Uninstalling Docker Package" - $package=Uninstall-Package <%= @docker_ee_package_name %> -ProviderName $dockerProviderName -Force - <% if @version -%> - -RequiredVersion <%= @version %> - <% end -%> + $package=Uninstall-Package <%= $docker_ee_package_name %> -ProviderName $dockerProviderName -Force + <% if $version { -%> + -RequiredVersion <%= $version %> + <% } -%> If ($package -eq $null) { Write-Error "Failed to uninstall Docker Package" Exit 1 @@ -45,4 +45,4 @@ if ($service -ne $null) { if (Test-Path -Path "$env:ProgramFiles\docker") { Remove-Item "$env:ProgramFiles\docker" -Recurse -Force -} \ No newline at end of file +} diff --git a/templates/windows/update_docker_image.ps1.erb b/templates/windows/update_docker_image.ps1.epp similarity index 79% rename from templates/windows/update_docker_image.ps1.erb rename to templates/windows/update_docker_image.ps1.epp index 36ba6edf..eaeffecc 100644 --- a/templates/windows/update_docker_image.ps1.erb +++ b/templates/windows/update_docker_image.ps1.epp @@ -10,11 +10,11 @@ param ) Write-Information "Before - Looking for image" -$before=$(& <%= @docker_command %> inspect --type image --format='{{.Id}}' ${DockerImage} 2>$null) +$before=$(& <%= $docker_command %> inspect --type image --format='{{.Id}}' ${DockerImage} 2>$null) Write-Information "Pulling image" -& <%= @docker_command %> pull ${DockerImage} +& <%= $docker_command %> pull ${DockerImage} Write-Information "Inspecting image" -$after=$(& <%= @docker_command %> inspect --type image --format='{{.Id}}' ${DockerImage} 2>$null) +$after=$(& <%= $docker_command %> inspect --type image --format='{{.Id}}' ${DockerImage} 2>$null) If (!$after) { Write-Information "Docker image ${DockerImage} failed to pull!" Exit 3