diff --git a/.fixtures.yml b/.fixtures.yml index 6f87802..07423f6 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,16 +1,15 @@ fixtures: forge_modules: stdlib: 'puppetlabs-stdlib' apt: 'puppetlabs-apt' - translate: 'puppetlabs-translate' powershell: 'puppetlabs-powershell' reboot: 'puppetlabs-reboot' repositories: facts: 'git://github.com/puppetlabs/puppetlabs-facts.git' puppet_agent: 'git://github.com/puppetlabs/puppetlabs-puppet_agent.git' provision: 'git://github.com/puppetlabs/provision.git' yumrepo_core: repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git puppet_version: ">= 6.0.0" symlinks: docker: "#{source_dir}" diff --git a/manifests/image.pp b/manifests/image.pp index 15f8d95..b48781e 100644 --- a/manifests/image.pp +++ b/manifests/image.pp @@ -1,182 +1,182 @@ # @summary # Module to install an up-to-date version of a Docker image # from the registry # # @param ensure # Whether you want the image present or absent. # # @param image # If you want the name of the image to be different from the # name of the puppet resource you can pass a value here. # # @param image_tag # If you want a specific tag of the image to be installed # # @param image_digest # If you want a specific content digest of the image to be installed # # @param docker_file # If you want to add a docker image from specific docker file # # @param docker_tar # If you want to load a docker image from specific docker tar # # @param force # # @param docker_dir # define docker::image( Optional[Enum[present,absent,latest]] $ensure = 'present', Optional[Pattern[/^[\S]*$/]] $image = $title, Optional[String] $image_tag = undef, Optional[String] $image_digest = undef, Optional[Boolean] $force = false, Optional[String] $docker_file = undef, Optional[String] $docker_dir = undef, Optional[String] $docker_tar = undef, ) { include docker::params $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_path = "${::docker_user_temp_path}/update_docker_image.ps1" $exec_environment = "PATH=${::docker_program_files_path}/Docker/" $exec_timeout = 3000 $update_docker_image_owner = undef $exec_path = [ "${::docker_program_files_path}/Docker/", ] $exec_provider = 'powershell' } else { $update_docker_image_template = 'docker/update_docker_image.sh.erb' $update_docker_image_path = '/usr/local/bin/update_docker_image.sh' $update_docker_image_owner = 'root' $exec_environment = 'HOME=/root' $exec_path = [ '/bin', '/usr/bin', ] $exec_timeout = 0 $exec_provider = undef } # Wrapper used to ensure images are up to date ensure_resource('file', $update_docker_image_path, { ensure => $docker::params::ensure, owner => $update_docker_image_owner, group => $update_docker_image_owner, mode => '0555', content => template($update_docker_image_template), } ) if ($docker_file) and ($docker_tar) { - fail(translate('docker::image must not have both $docker_file and $docker_tar set')) + fail('docker::image must not have both $docker_file and $docker_tar set') } if ($docker_dir) and ($docker_tar) { - fail(translate('docker::image must not have both $docker_dir and $docker_tar set')) + fail('docker::image must not have both $docker_dir and $docker_tar set') } if ($image_digest) and ($docker_file) { - fail(translate('docker::image must not have both $image_digest and $docker_file set')) + fail('docker::image must not have both $image_digest and $docker_file set') } if ($image_digest) and ($docker_dir) { - fail(translate('docker::image must not have both $image_digest and $docker_dir set')) + fail('docker::image must not have both $image_digest and $docker_dir set') } if ($image_digest) and ($docker_tar) { - fail(translate('docker::image must not have both $image_digest and $docker_tar set')) + fail('docker::image must not have both $image_digest and $docker_tar set') } if $force { $image_force = '-f ' } else { $image_force = '' } if $image_tag { $image_arg = "${image}:${image_tag}" $image_remove = "${docker_command} rmi ${image_force}${image}:${image_tag}" $image_find = "${docker_command} images -q ${image}:${image_tag}" } elsif $image_digest { $image_arg = "${image}@${image_digest}" $image_remove = "${docker_command} rmi ${image_force}${image}:${image_digest}" $image_find = "${docker_command} images -q ${image}@${image_digest}" } else { $image_arg = $image $image_remove = "${docker_command} rmi ${image_force}${image}" $image_find = "${docker_command} images -q ${image}" } if $facts['os']['family'] == 'windows' { $_image_find = "If (-not (${image_find}) ) { Exit 1 }" } else { $_image_find = "${image_find} | grep ." } if ($docker_dir) and ($docker_file) { $image_install = "${docker_command} build -t ${image_arg} -f ${docker_file} ${docker_dir}" } elsif $docker_dir { $image_install = "${docker_command} build -t ${image_arg} ${docker_dir}" } elsif $docker_file { if $facts['os']['family'] == windows { $image_install = "Get-Content ${docker_file} -Raw | ${docker_command} build -t ${image_arg} -" } else { $image_install = "${docker_command} build -t ${image_arg} - < ${docker_file}" } } elsif $docker_tar { $image_install = "${docker_command} load -i ${docker_tar}" } else { if $facts['os']['family'] == 'windows' { $image_install = "& ${update_docker_image_path} -DockerImage ${image_arg}" } else { $image_install = "${update_docker_image_path} ${image_arg}" } } if $ensure == 'absent' { exec { $image_remove: path => $exec_path, environment => $exec_environment, onlyif => $_image_find, provider => $exec_provider, timeout => $exec_timeout, logoutput => true, } } elsif $ensure == 'latest' or $image_tag == 'latest' { notify { "Check if image ${image_arg} is in-sync": noop => false, } ~> exec { $image_install: environment => $exec_environment, path => $exec_path, timeout => $exec_timeout, returns => ['0', '2'], require => File[$update_docker_image_path], provider => $exec_provider, logoutput => true, } ~> exec { "echo 'Update of ${image_arg} complete'": environment => $exec_environment, path => $exec_path, timeout => $exec_timeout, require => File[$update_docker_image_path], provider => $exec_provider, logoutput => true, refreshonly => true, } } elsif $ensure == 'present' { exec { $image_install: unless => $_image_find, environment => $exec_environment, path => $exec_path, timeout => $exec_timeout, returns => ['0', '2'], require => File[$update_docker_image_path], provider => $exec_provider, logoutput => true, } } Docker::Image <| title == $title |> } diff --git a/manifests/init.pp b/manifests/init.pp index 074a186..0e66008 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,668 +1,668 @@ # @summary # Module to install an up-to-date version of Docker from package. # # @param version # The package version to install, used to set the package name. # # @param ensure # Passed to the docker package. # # @param prerequired_packages # An array of additional packages that need to be installed to support docker. # # @param dependent_packages # An array of packages installed by the docker-ce package v 18.09 and later. # Used when uninstalling to ensure containers cannot be run on the system. # # @param tcp_bind # The tcp socket to bind to in the format # tcp://127.0.0.1:4243 # # @param tls_enable # Enable TLS. # # @param tls_verify # Use TLS and verify the remote # # @param tls_cacert # Path to TLS CA certificate # # @param tls_cert # Path to TLS certificate file # # @param tls_key # Path to TLS key file # # @param ip_forward # Enables IP forwarding on the Docker host. # # @param iptables # Enable Docker's addition of iptables rules. # # @param ip_masq # Enable IP masquerading for bridge's IP range. # # @param icc # Enable or disable Docker's unrestricted inter-container and Docker daemon host communication. # (Requires iptables=true to disable) # # @param bip # Specify docker's network bridge IP, in CIDR notation. # # @param mtu # Docker network MTU. # # @param bridge # Attach containers to a pre-existing network bridge # use 'none' to disable container networking # # @param fixed_cidr # IPv4 subnet for fixed IPs # 10.20.0.0/16 # # @param default_gateway # IPv4 address of the container default gateway; # this address must be part of the bridge subnet # (which is defined by bridge) # # @param ipv6 # Enables ipv6 support for the docker daemon # # @param ipv6_cidr # IPv6 subnet for fixed IPs # # @param default_gateway_ipv6 # IPv6 address of the container default gateway: # # @param socket_bind # The unix socket to bind to. # # @param log_level # Set the logging level # Valid values: debug, info, warn, error, fatal # # @param log_driver # Set the log driver. # Docker default is json-file. # Valid values: none, json-file, syslog, journald, gelf, fluentd # Valid values description: # none : Disables any logging for the container. # docker logs won't be available with this driver. # json-file: Default logging driver for Docker. # Writes JSON messages to file. # syslog : Syslog logging driver for Docker. # Writes log messages to syslog. # journald : Journald logging driver for Docker. # Writes log messages to journald. # gelf : Graylog Extended Log Format (GELF) logging driver for Docker. # Writes log messages to a GELF endpoint: Graylog or Logstash. # fluentd : Fluentd logging driver for Docker. # Writes log messages to fluentd (forward input). # splunk : Splunk logging driver for Docker. # Writes log messages to Splunk (HTTP Event Collector). # awslogs : AWS Cloudwatch Logs logging driver for Docker. # Write log messages to Cloudwatch API # # @param log_opt # Set the log driver specific options # Valid values per log driver: # none : undef # json-file: # max-size=[0-9+][k|m|g] # max-file=[0-9+] # syslog : # syslog-address=[tcp|udp]://host:port # syslog-address=unix://path # syslog-facility=daemon|kern|user|mail|auth| # syslog|lpr|news|uucp|cron| # authpriv|ftp| # local0|local1|local2|local3| # local4|local5|local6|local7 # syslog-tag="some_tag" # journald : undef # gelf : # gelf-address=udp://host:port # gelf-tag="some_tag" # fluentd : # fluentd-address=host:port # fluentd-tag={{.ID}} - short container id (12 characters)| # {{.FullID}} - full container id # {{.Name}} - container name # splunk : # splunk-token= # splunk-url=https://your_splunk_instance:8088 # awslogs : # awslogs-group= # awslogs-stream= # awslogs-create-group=true|false # awslogs-datetime-format= - strftime expression # awslogs-multiline-pattern=multiline start pattern using a regular expression # tag={{.ID}} - short container id (12 characters)| # {{.FullID}} - full container id # {{.Name}} - container name # # @param selinux_enabled # Enable selinux support. Default is false. SELinux does not presently # support the BTRFS storage driver. # # @param use_upstream_package_source # Whether or not to use the upstream package source. # If you run your own package mirror, you may set this # to false. # # @param pin_upstream_package_source # Pin upstream package source; this option currently only has any effect on # apt-based distributions. Set to false to remove pinning on the upstream # package repository. See also "apt_source_pin_level". # # @param apt_source_pin_level # What level to pin our source package repository to; this only is relevent # if you're on an apt-based system (Debian, Ubuntu, etc) and # $use_upstream_package_source is set to true. Set this to false to disable # pinning, and undef to ensure the apt preferences file apt::source uses to # define pins is removed. # # @param service_state # Whether you want to docker daemon to start up # # @param service_enable # Whether you want to docker daemon to start up at boot # # @param manage_service # Specify whether the service should be managed. # # @param root_dir # Custom root directory for containers # # @param dns # Custom dns server address # # @param dns_search # Custom dns search domains # # @param socket_group # Group ownership of the unix control socket. # # @param extra_parameters # Any extra parameters that should be passed to the docker daemon. # # @param shell_values # Array of shell values to pass into init script config files # # @param proxy # Will set the http_proxy and https_proxy env variables in /etc/sysconfig/docker (redhat/centos) or /etc/default/docker (debian) # # @param no_proxy # Will set the no_proxy variable in /etc/sysconfig/docker (redhat/centos) or /etc/default/docker (debian) # # @param storage_driver # Specify a storage driver to use # Valid values: aufs, devicemapper, btrfs, overlay, overlay2, vfs, zfs # # @param dm_basesize # The size to use when creating the base device, which limits the size of images and containers. # # @param dm_fs # The filesystem to use for the base image (xfs or ext4) # # @param dm_mkfsarg # Specifies extra mkfs arguments to be used when creating the base device. # # @param dm_mountopt # Specifies extra mount options used when mounting the thin devices. # # @param dm_blocksize # A custom blocksize to use for the thin pool. # Default blocksize is 64K. # Warning: _DO NOT_ change this parameter after the lvm devices have been initialized. # # @param dm_loopdatasize # Specifies the size to use when creating the loopback file for the "data" device which is used for the thin pool # # @param dm_loopmetadatasize # Specifies the size to use when creating the loopback file for the "metadata" device which is used for the thin pool # # @param dm_datadev # (deprecated - dm_thinpooldev should be used going forward) # A custom blockdevice to use for data for the thin pool. # # @param dm_metadatadev # (deprecated - dm_thinpooldev should be used going forward) # A custom blockdevice to use for metadata for the thin pool. # # @param dm_thinpooldev # Specifies a custom block storage device to use for the thin pool. # # @param dm_use_deferred_removal # Enables use of deferred device removal if libdm and the kernel driver support the mechanism. # # @param dm_use_deferred_deletion # Enables use of deferred device deletion if libdm and the kernel driver support the mechanism. # # @param dm_blkdiscard # Enables or disables the use of blkdiscard when removing devicemapper devices. # # @param dm_override_udev_sync_check # By default, the devicemapper backend attempts to synchronize with the udev # device manager for the Linux kernel. This option allows disabling that # synchronization, to continue even though the configuration may be buggy. # # @param overlay2_override_kernel_check # Overrides the Linux kernel version check allowing using overlay2 with kernel < 4.0. # # @param manage_package # Won't install or define the docker package, useful if you want to use your own package # # @param service_name # Specify custom service name # # @param docker_users # Specify an array of users to add to the docker group # # @param docker_group # Specify a string for the docker group # # @param daemon_environment_files # Specify additional environment files to add to the # service-overrides.conf # # @param repo_opt # Specify a string to pass as repository options (RedHat only) # # @param storage_devs # A quoted, space-separated list of devices to be used. # # @param storage_vg # The volume group to use for docker storage. # # @param storage_root_size # The size to which the root filesystem should be grown. # # @param storage_data_size # The desired size for the docker data LV # # @param storage_min_data_size # The minimum size of data volume otherwise pool creation fails # # @param storage_chunk_size # Controls the chunk size/block size of thin pool. # # @param storage_growpart # Enable resizing partition table backing root volume group. # # @param storage_auto_extend_pool # Enable/disable automatic pool extension using lvm # # @param storage_pool_autoextend_threshold # Auto pool extension threshold (in % of pool size) # # @param storage_pool_autoextend_percent # Extend the pool by specified percentage when threshold is hit. # # @param tmp_dir_config # Whether to set the TMPDIR value in the systemd config file # Default: true (set the value); false will comment out the line. # Note: false is backwards compatible prior to PR #58 # # @param tmp_dir # Sets the tmp dir for Docker (path) # # @param registry_mirror # Sets the prefered container registry mirror. # # @param nuget_package_provider_version # The version of the NuGet Package provider # # @param docker_msft_provider_version # The version of the Microsoft Docker Provider Module # # @param docker_ce_start_command # @param docker_ce_package_name # @param docker_ce_source_location # @param docker_ce_key_source # @param docker_ce_key_id # @param docker_ce_release # @param docker_package_location # @param docker_package_key_source # @param docker_package_key_check_source # @param docker_package_key_id # @param docker_package_release # @param docker_engine_start_command # @param docker_engine_package_name # @param docker_ce_channel # @param docker_ee # @param docker_ee_package_name # @param docker_ee_source_location # @param docker_ee_key_source # @param docker_ee_key_id # @param docker_ee_repos # @param docker_ee_release # @param package_release # @param labels # @param execdriver # @param package_source # @param os_lc # @param storage_config # @param storage_config_template # @param storage_setup_file # @param service_provider # @param service_config # @param service_config_template # @param service_overrides_template # @param socket_overrides_template # @param socket_override # @param service_after_override # @param service_hasstatus # @param service_hasrestart # @param acknowledge_unsupported_os # class docker( Optional[String] $version = $docker::params::version, String $ensure = $docker::params::ensure, Variant[Array[String], Hash] $prerequired_packages = $docker::params::prerequired_packages, Array $dependent_packages = $docker::params::dependent_packages, String $docker_ce_start_command = $docker::params::docker_ce_start_command, Optional[String] $docker_ce_package_name = $docker::params::docker_ce_package_name, Optional[String] $docker_ce_source_location = $docker::params::package_ce_source_location, Optional[String] $docker_ce_key_source = $docker::params::package_ce_key_source, Optional[String] $docker_ce_key_id = $docker::params::package_ce_key_id, Optional[String] $docker_ce_release = $docker::params::package_ce_release, Optional[String] $docker_package_location = $docker::params::package_source_location, Optional[String] $docker_package_key_source = $docker::params::package_key_source, Optional[Boolean] $docker_package_key_check_source = $docker::params::package_key_check_source, Optional[String] $docker_package_key_id = $docker::params::package_key_id, Optional[String] $docker_package_release = $docker::params::package_release, String $docker_engine_start_command = $docker::params::docker_engine_start_command, String $docker_engine_package_name = $docker::params::docker_engine_package_name, String $docker_ce_channel = $docker::params::docker_ce_channel, Optional[Boolean] $docker_ee = $docker::params::docker_ee, Optional[String] $docker_ee_package_name = $docker::params::package_ee_package_name, Optional[String] $docker_ee_source_location = $docker::params::package_ee_source_location, Optional[String] $docker_ee_key_source = $docker::params::package_ee_key_source, Optional[String] $docker_ee_key_id = $docker::params::package_ee_key_id, Optional[String] $docker_ee_repos = $docker::params::package_ee_repos, Optional[String] $docker_ee_release = $docker::params::package_ee_release, Optional[Variant[String,Array[String]]] $tcp_bind = $docker::params::tcp_bind, Boolean $tls_enable = $docker::params::tls_enable, Boolean $tls_verify = $docker::params::tls_verify, Optional[String] $tls_cacert = $docker::params::tls_cacert, Optional[String] $tls_cert = $docker::params::tls_cert, Optional[String] $tls_key = $docker::params::tls_key, Boolean $ip_forward = $docker::params::ip_forward, Boolean $ip_masq = $docker::params::ip_masq, Optional[Boolean] $ipv6 = $docker::params::ipv6, Optional[String] $ipv6_cidr = $docker::params::ipv6_cidr, Optional[String] $default_gateway_ipv6 = $docker::params::default_gateway_ipv6, Optional[String] $bip = $docker::params::bip, Optional[String] $mtu = $docker::params::mtu, Boolean $iptables = $docker::params::iptables, Optional[Boolean] $icc = $docker::params::icc, String $socket_bind = $docker::params::socket_bind, Optional[String] $fixed_cidr = $docker::params::fixed_cidr, Optional[String] $bridge = $docker::params::bridge, Optional[String] $default_gateway = $docker::params::default_gateway, Optional[String] $log_level = $docker::params::log_level, Optional[String] $log_driver = $docker::params::log_driver, Array $log_opt = $docker::params::log_opt, Optional[Boolean] $selinux_enabled = $docker::params::selinux_enabled, Optional[Boolean] $use_upstream_package_source = $docker::params::use_upstream_package_source, Optional[Boolean] $pin_upstream_package_source = $docker::params::pin_upstream_package_source, Optional[Integer] $apt_source_pin_level = $docker::params::apt_source_pin_level, Optional[String] $package_release = $docker::params::package_release, String $service_state = $docker::params::service_state, Boolean $service_enable = $docker::params::service_enable, Boolean $manage_service = $docker::params::manage_service, Optional[String] $root_dir = $docker::params::root_dir, Optional[Boolean] $tmp_dir_config = $docker::params::tmp_dir_config, Optional[String] $tmp_dir = $docker::params::tmp_dir, Optional[Variant[String,Array]] $dns = $docker::params::dns, Optional[Variant[String,Array]] $dns_search = $docker::params::dns_search, Optional[Variant[String,Boolean]] $socket_group = $docker::params::socket_group, Array $labels = $docker::params::labels, Optional[Variant[String,Array]] $extra_parameters = undef, Optional[Variant[String,Array]] $shell_values = undef, Optional[String] $proxy = $docker::params::proxy, Optional[String] $no_proxy = $docker::params::no_proxy, Optional[String] $storage_driver = $docker::params::storage_driver, Optional[String] $dm_basesize = $docker::params::dm_basesize, Optional[String] $dm_fs = $docker::params::dm_fs, Optional[String] $dm_mkfsarg = $docker::params::dm_mkfsarg, Optional[String] $dm_mountopt = $docker::params::dm_mountopt, Optional[String] $dm_blocksize = $docker::params::dm_blocksize, Optional[String] $dm_loopdatasize = $docker::params::dm_loopdatasize, Optional[String] $dm_loopmetadatasize = $docker::params::dm_loopmetadatasize, Optional[String] $dm_datadev = $docker::params::dm_datadev, Optional[String] $dm_metadatadev = $docker::params::dm_metadatadev, Optional[String] $dm_thinpooldev = $docker::params::dm_thinpooldev, Optional[Boolean] $dm_use_deferred_removal = $docker::params::dm_use_deferred_removal, Optional[Boolean] $dm_use_deferred_deletion = $docker::params::dm_use_deferred_deletion, Optional[Boolean] $dm_blkdiscard = $docker::params::dm_blkdiscard, Optional[Boolean] $dm_override_udev_sync_check = $docker::params::dm_override_udev_sync_check, Boolean $overlay2_override_kernel_check = $docker::params::overlay2_override_kernel_check, Optional[String] $execdriver = $docker::params::execdriver, Boolean $manage_package = $docker::params::manage_package, Optional[String] $package_source = $docker::params::package_source, Optional[String] $service_name = $docker::params::service_name, Array $docker_users = [], String $docker_group = $docker::params::docker_group, Array $daemon_environment_files = [], Optional[Variant[String,Hash]] $repo_opt = $docker::params::repo_opt, Optional[String] $os_lc = $docker::params::os_lc, Optional[String] $storage_devs = $docker::params::storage_devs, Optional[String] $storage_vg = $docker::params::storage_vg, Optional[String] $storage_root_size = $docker::params::storage_root_size, Optional[String] $storage_data_size = $docker::params::storage_data_size, Optional[String] $storage_min_data_size = $docker::params::storage_min_data_size, Optional[String] $storage_chunk_size = $docker::params::storage_chunk_size, Optional[Boolean] $storage_growpart = $docker::params::storage_growpart, Optional[String] $storage_auto_extend_pool = $docker::params::storage_auto_extend_pool, Optional[String] $storage_pool_autoextend_threshold = $docker::params::storage_pool_autoextend_threshold, Optional[String] $storage_pool_autoextend_percent = $docker::params::storage_pool_autoextend_percent, Optional[Variant[String,Boolean]] $storage_config = $docker::params::storage_config, Optional[String] $storage_config_template = $docker::params::storage_config_template, Optional[String] $storage_setup_file = $docker::params::storage_setup_file, Optional[String] $service_provider = $docker::params::service_provider, Optional[Variant[String,Boolean]] $service_config = $docker::params::service_config, Optional[String] $service_config_template = $docker::params::service_config_template, Optional[Variant[String,Boolean]] $service_overrides_template = $docker::params::service_overrides_template, Optional[Variant[String,Boolean]] $socket_overrides_template = $docker::params::socket_overrides_template, Optional[Boolean] $socket_override = $docker::params::socket_override, Optional[Variant[String,Boolean]] $service_after_override = $docker::params::service_after_override, Optional[Boolean] $service_hasstatus = $docker::params::service_hasstatus, Optional[Boolean] $service_hasrestart = $docker::params::service_hasrestart, Optional[Variant[String,Array]] $registry_mirror = $docker::params::registry_mirror, Boolean $acknowledge_unsupported_os = false, # Windows specific parameters Optional[String] $docker_msft_provider_version = $docker::params::docker_msft_provider_version, Optional[String] $nuget_package_provider_version = $docker::params::nuget_package_provider_version, Boolean $have_systemd_v230 = $docker::params::have_systemd_v230, ) inherits docker::params { if $facts['os']['family'] and ! $acknowledge_unsupported_os { assert_type(Pattern[/^(Debian|RedHat|windows)$/], $facts['os']['family']) |$a, $b| { - fail(translate('This module only works on Debian, Red Hat or Windows based systems.')) + fail('This module only works on Debian, Red Hat or Windows based systems.') } } if ($facts['os']['family'] == 'RedHat') and (versioncmp($facts['os']['release']['major'], '7') < 0) { - fail(translate('This module only works on Red Hat based systems version 7 and higher.')) + fail('This module only works on Red Hat based systems version 7 and higher.') } if ($default_gateway) and (!$bridge) { - fail(translate('You must provide the $bridge parameter.')) + fail('You must provide the $bridge parameter.') } if $log_level { assert_type(Pattern[/^(debug|info|warn|error|fatal)$/], $log_level) |$a, $b| { - fail(translate('log_level must be one of debug, info, warn, error or fatal')) + fail('log_level must be one of debug, info, warn, error or fatal') } } if $log_driver { if $facts['os']['family'] == 'windows' { assert_type(Pattern[/^(none|json-file|syslog|gelf|fluentd|splunk|awslogs|etwlogs)$/], $log_driver) |$a, $b| { - fail(translate('log_driver must be one of none, json-file, syslog, gelf, fluentd, splunk, awslogs or etwlogs')) + fail('log_driver must be one of none, json-file, syslog, gelf, fluentd, splunk, awslogs or etwlogs') } } else { assert_type(Pattern[/^(none|json-file|syslog|journald|gelf|fluentd|splunk|awslogs)$/], $log_driver) |$a, $b| { - fail(translate('log_driver must be one of none, json-file, syslog, journald, gelf, fluentd, splunk or awslogs')) + fail('log_driver must be one of none, json-file, syslog, journald, gelf, fluentd, splunk or awslogs') } } } if $storage_driver { if $facts['os']['family'] == 'windows' { assert_type(Pattern[/^(windowsfilter)$/], $storage_driver) |$a, $b| { - fail(translate('Valid values for storage_driver on windows are windowsfilter')) + fail('Valid values for storage_driver on windows are windowsfilter') } } else { assert_type(Pattern[/^(aufs|devicemapper|btrfs|overlay|overlay2|vfs|zfs)$/], $storage_driver) |$a, $b| { - fail(translate('Valid values for storage_driver are aufs, devicemapper, btrfs, overlay, overlay2, vfs, zfs.')) + fail('Valid values for storage_driver are aufs, devicemapper, btrfs, overlay, overlay2, vfs, zfs.') } } } if ($bridge) and ($facts['os']['family'] == 'windows') { assert_type(Pattern[/^(none|nat|transparent|overlay|l2bridge|l2tunnel)$/], $bridge) |$a, $b| { - fail(translate('bridge must be one of none, nat, transparent, overlay, l2bridge or l2tunnel on Windows.')) + fail('bridge must be one of none, nat, transparent, overlay, l2bridge or l2tunnel on Windows.') } } if $dm_fs { assert_type(Pattern[/^(ext4|xfs)$/], $dm_fs) |$a, $b| { - fail(translate('Only ext4 and xfs are supported currently for dm_fs.')) + fail('Only ext4 and xfs are supported currently for dm_fs.') } } if ($dm_loopdatasize or $dm_loopmetadatasize) and ($dm_datadev or $dm_metadatadev) { - fail(translate('You should provide parameters only for loop lvm or direct lvm, not both.')) + fail('You should provide parameters only for loop lvm or direct lvm, not both.') } if ($dm_datadev or $dm_metadatadev) and $dm_thinpooldev { - fail(translate('You can use the $dm_thinpooldev parameter, or the $dm_datadev and $dm_metadatadev parameter pair, but you cannot use both.')) # lint:ignore:140chars + fail('You can use the $dm_thinpooldev parameter, or the $dm_datadev and $dm_metadatadev parameter pair, but you cannot use both.') # lint:ignore:140chars } if ($dm_datadev or $dm_metadatadev) { notice('The $dm_datadev and $dm_metadatadev parameter pair are deprecated. The $dm_thinpooldev parameter should be used instead.') } if ($dm_datadev and !$dm_metadatadev) or (!$dm_datadev and $dm_metadatadev) { - fail(translate('You need to provide both $dm_datadev and $dm_metadatadev parameters for direct lvm.')) + fail('You need to provide both $dm_datadev and $dm_metadatadev parameters for direct lvm.') } if ($dm_basesize or $dm_fs or $dm_mkfsarg or $dm_mountopt or $dm_blocksize or $dm_loopdatasize or $dm_loopmetadatasize or $dm_datadev or $dm_metadatadev) and ($storage_driver != 'devicemapper') { - fail(translate('Values for dm_ variables will be ignored unless storage_driver is set to devicemapper.')) + fail('Values for dm_ variables will be ignored unless storage_driver is set to devicemapper.') } if($tls_enable) { if(! $tcp_bind) { - fail(translate('You need to provide tcp bind parameter for TLS.')) + fail('You need to provide tcp bind parameter for TLS.') } } if ($version == undef) or ($version !~ /^(17[.][0-1][0-9][.][0-1](~|-|\.)ce|1.\d+)/) { if ($docker_ee) { $package_location = $docker::docker_ee_source_location $package_key_source = $docker::docker_ee_key_source $package_key_check_source = true $package_key = $docker::docker_ee_key_id $package_repos = $docker::docker_ee_repos $release = $docker::docker_ee_release $docker_start_command = $docker::docker_ee_start_command $docker_package_name = $docker::docker_ee_package_name } else { case $facts['os']['family'] { 'Debian' : { $package_location = $docker_ce_source_location $package_key_source = $docker_ce_key_source $package_key = $docker_ce_key_id $package_repos = $docker_ce_channel $release = $docker_ce_release } 'RedHat' : { $package_location = $docker_ce_source_location $package_key_source = $docker_ce_key_source $package_key_check_source = true } 'windows': { - fail(translate('This module only work for Docker Enterprise Edition on Windows.')) + fail('This module only work for Docker Enterprise Edition on Windows.') } default: { $package_location = $docker_package_location $package_key_source = $docker_package_key_source $package_key_check_source = $docker_package_key_check_source } } $docker_start_command = $docker_ce_start_command $docker_package_name = $docker_ce_package_name } } else { case $facts['os']['family'] { 'Debian': { $package_location = $docker_package_location $package_key_source = $docker_package_key_source $package_key_check_source = $docker_package_key_check_source $package_key = $docker_package_key_id $package_repos = 'main' $release = $docker_package_release } 'RedHat': { $package_location = $docker_package_location $package_key_source = $docker_package_key_source $package_key_check_source = $docker_package_key_check_source } default: { $package_location = $docker_package_location $package_key_source = $docker_package_key_source $package_key_check_source = $docker_package_key_check_source } } $docker_start_command = $docker_engine_start_command $docker_package_name = $docker_engine_package_name } if ($version != undef) and ($version =~ /^(17[.]0[0-4]|1.\d+)/) { $root_dir_flag = '-g' } else { $root_dir_flag = '--data-root' } if $ensure != 'absent' { contain docker::repos contain docker::install contain docker::config contain docker::service create_resources( 'docker::registry', lookup("${module_name}::registries", Hash, 'deep', {}), ) create_resources( 'docker::image', lookup("${module_name}::images", Hash, 'deep', {}), ) create_resources( 'docker::run', lookup("${module_name}::runs", Hash, 'deep', {}), ) Class['docker::repos'] -> Class['docker::install'] -> Class['docker::config'] -> Class['docker::service'] -> Docker::Registry <||> -> Docker::Image <||> -> Docker::Run <||> } else { contain 'docker::repos' contain 'docker::install' Class['docker::repos'] -> Class['docker::install'] } } diff --git a/manifests/install.pp b/manifests/install.pp index d0e849d..967955d 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -1,134 +1,134 @@ # @summary # Module to install an up-to-date version of Docker from a package repository. # Only for Debian, Red Hat and Windows # # @param version # The package version to install, used to set the package name. # # @param nuget_package_provider_version # The version of the NuGet Package provider # # @param docker_msft_provider_version # The version of the Microsoft Docker Provider Module # # @param docker_ee_package_name # The name of the Docker Enterprise Edition package # # @param docker_download_url # # @param dependent_packages # class docker::install( $version = $docker::version, $nuget_package_provider_version = $docker::nuget_package_provider_version, $docker_msft_provider_version = $docker::docker_msft_provider_version, $docker_ee_package_name = $docker::docker_ee_package_name, $docker_download_url = $docker::package_location, $dependent_packages = $docker::dependent_packages, ) { $docker_start_command = $docker::docker_start_command if $facts['os']['family'] and ! $docker::acknowledge_unsupported_os { assert_type(Pattern[/^(Debian|RedHat|windows)$/], $facts['os']['family']) |$a, $b| { - fail(translate('This module only works on Debian, RedHat or Windows.')) + fail('This module only works on Debian, RedHat or Windows.') } } if $docker::version and $docker::ensure != 'absent' { $ensure = $docker::version } else { $ensure = $docker::ensure } if $docker::manage_package { if empty($docker::repo_opt) { $docker_hash = {} } else { $docker_hash = { 'install_options' => $docker::repo_opt } } if $docker::package_source { case $facts['os']['family'] { 'Debian' : { $pk_provider = 'dpkg' } 'RedHat' : { $pk_provider = 'yum' } 'windows' : { - fail(translate('Custom package source is currently not implemented on windows.')) + fail('Custom package source is currently not implemented on windows.') } default : { $pk_provider = undef } } case $docker::package_source { /docker-engine/ : { ensure_resource('package', 'docker', merge($docker_hash, { ensure => $ensure, provider => $pk_provider, source => $docker::package_source, name => $docker::docker_engine_package_name, })) } /docker-ce/ : { ensure_resource('package', 'docker', merge($docker_hash, { ensure => $ensure, provider => $pk_provider, source => $docker::package_source, name => $docker::docker_ce_package_name, })) } default : {} } } else { if $facts['os']['family'] != 'windows' { ensure_resource('package', 'docker', merge($docker_hash, { ensure => $ensure, name => $docker::docker_package_name, })) if $ensure == 'absent' { ensure_resource('package', $dependent_packages, { ensure => $ensure, }) } } else { if $ensure == 'absent' { exec { 'remove-docker-package': command => template('docker/windows/remove_docker.ps1.erb'), provider => powershell, unless => template('docker/windows/check_docker.ps1.erb'), logoutput => true, } } else { if $docker::package_location { exec { 'install-docker-package': command => template('docker/windows/download_docker.ps1.erb'), provider => powershell, unless => template('docker/windows/check_docker_url.ps1.erb'), logoutput => true, notify => Exec['service-restart-on-failure'], } } else { exec { 'install-docker-package': command => template('docker/windows/install_powershell_provider.ps1.erb'), provider => powershell, unless => template('docker/windows/check_powershell_provider.ps1.erb'), logoutput => true, notify => Exec['service-restart-on-failure'], } } exec { 'service-restart-on-failure': command => 'SC.exe failure Docker reset= 432000 actions= restart/30000/restart/60000/restart/60000', refreshonly => true, logoutput => true, provider => powershell, } } } } } } diff --git a/manifests/plugin.pp b/manifests/plugin.pp index 3b55bf0..0b5a815 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -1,131 +1,131 @@ # @summary # A define that manages a docker plugin # # @param plugin_name # This ensures whether the plugin is installed or not. # Note that the default behaviour of docker plugin # requires a plugin be disabled before it can be removed # # @param plugin_name # The name of the docker plugin # # @param enabled # A setting to enable or disable an installed plugin. # # @param timeout # The number of seconds to wait when enabling a plugin # # @param plugin_alias # An alternative name to use for an installed plugin # # @param disable_on_install # Alters the default behaviour of enabling a plugin upon install # # @param disable_content_trust # Skip image verification # # @param grant_all_permissions # Grant all permissions necessary to run the plugin # # @param force_remove # Force the removal of an active plugin # # @param settings # Any additional settings to pass to the plugin during install # # @param ensure # # @param grant_all_permissions # define docker::plugin( Optional[Enum[present,absent]] $ensure = 'present', String $plugin_name = $title, Optional[Boolean] $enabled = true, Optional[String] $timeout = undef, Optional[String] $plugin_alias = undef, Optional[Boolean] $disable_on_install = false, Optional[Boolean] $disable_content_trust = true, Optional[Boolean] $grant_all_permissions = true, Optional[Boolean] $force_remove = true, Optional[Array] $settings = [], ) { include docker::params $docker_command = "${docker::params::docker_command} plugin" if ($facts['os']['family'] == 'windows') { - fail(translate('Feature not implemented on windows.')) + fail('Feature not implemented on windows.') } if $ensure == 'present' { $docker_plugin_install_flags = docker_plugin_install_flags( { plugin_name => $plugin_name, plugin_alias => $plugin_alias, disable_on_install => $disable_on_install, disable_content_trust => $disable_content_trust, grant_all_permissions => $grant_all_permissions, settings => $settings, } ) $exec_install = "${docker_command} install ${docker_plugin_install_flags}" $unless_install = "${docker_command} ls --format='{{.PluginReference}}' | grep -w ${plugin_name}" exec { "plugin install ${plugin_name}": command => $exec_install, environment => 'HOME=/root', path => ['/bin', '/usr/bin'], timeout => 0, unless => $unless_install, } } elsif $ensure == 'absent' { $docker_plugin_remove_flags = docker_plugin_remove_flags( { plugin_name => $plugin_name, force_remove => $force_remove, } ) $exec_rm = "${docker_command} rm ${docker_plugin_remove_flags}" $onlyif_rm = "${docker_command} ls --format='{{.PluginReference}}' | grep -w ${plugin_name}" exec { "plugin remove ${plugin_name}": command => $exec_rm, environment => 'HOME=/root', path => ['/bin', '/usr/bin'], timeout => 0, onlyif => $onlyif_rm, } } if $enabled { $docker_plugin_enable_flags = docker_plugin_enable_flags( { plugin_name => $plugin_name, plugin_alias => $plugin_alias, timeout => $timeout, } ) $exec_enable = "${docker_command} enable ${docker_plugin_enable_flags}" $onlyif_enable = "${docker_command} ls -f enabled=false --format='{{.PluginReference}}' | grep -w ${plugin_name}" exec { "plugin enable ${plugin_name}": command => $exec_enable, environment => 'HOME=/root', path => ['/bin', '/usr/bin'], timeout => 0, onlyif => $onlyif_enable, } } elsif $enabled == false { exec { "disable ${plugin_name}": command => "${docker_command} disable ${plugin_name}", environment => 'HOME=/root', path => [ '/bin', '/usr/bin', ], timeout => 0, unless => "${docker_command} ls -f enabled=false --format='{{.PluginReference}}' | grep -w ${plugin_name}", } } } diff --git a/manifests/run.pp b/manifests/run.pp index 4e3725b..3c0c67e 100644 --- a/manifests/run.pp +++ b/manifests/run.pp @@ -1,690 +1,690 @@ # @summary # A define which manages a running docker container. # # @param restart # Sets a restart policy on the docker run. # Note: If set, puppet will NOT setup an init script to manage, instead # it will do a raw docker run command using a CID file to track the container # ID. # # If you want a normal named container with an init script and a restart policy # you must use the extra_parameters feature and pass it in like this: # # extra_parameters => ['--restart=always'] # # However, if your system is using sytemd this restart policy will be # ineffective because the ExecStop commands will run which will cause # docker to stop restarting it. In this case you should use the # systemd_restart option to specify the policy you want. # # This will allow the docker container to be restarted if it dies, without # puppet help. # # @param verify_digest # (optional) Make sure, that the image has not modified. Compares the digest # checksum before starting the docker image. # To get the digest of an image, run the following command: # docker image inspect <> --format='{{index .RepoDigests 0}} # # @param service_prefix # (optional) The name to prefix the startup script with and the Puppet # service resource title with. Default: 'docker-' # # @param restart_service # (optional) Whether or not to restart the service if the the generated init # script changes. Default: true # # @param restart_service_on_docker_refresh # Whether or not to restart the service if the docker service is restarted. # Only has effect if the docker_service parameter is set. # Default: true # # @param manage_service # (optional) Whether or not to create a puppet Service resource for the init # script. Disabling this may be useful if integrating with existing modules. # Default: true # # @param docker_service # (optional) If (and how) the Docker service itself is managed by Puppet # true -> Service['docker'] # false -> no Service dependency # anything else -> Service[docker_service] # Default: false # # @param health_check_cmd # (optional) Specifies the command to execute to check that the container is healthy using the docker health check functionality. # Default: undef # # @param health_check_interval # (optional) Specifies the interval that the health check command will execute in seconds. # Default: undef # # @param restart_on_unhealthy # (optional) Checks the health status of Docker container and if it is unhealthy the service will be restarted. # The health_check_cmd parameter must be set to true to use this functionality. # Default: undef # # @param net # # The docker network to attach to a container. # Can be a String or Array (if using multiple networks) # Default: bridge # # @param extra_parameters # An array of additional command line arguments to pass to the `docker run` # command. Useful for adding additional new or experimental options that the # module does not yet support. # # @param systemd_restart # (optional) If the container is to be managed by a systemd unit file set the # Restart option on the unit file. Can be any valid value for this systemd # configuration. Most commonly used are on-failure or always. # Default: on-failure # # @param custom_unless # (optional) Specify an additional unless for the Docker run command when using restart. # Default: undef # # @param after_create # (optional) Specifies the command to execute after container is created but before it is started. # Default: undef # # @param remain_after_exit # (optional) If the container is to be managed by a systemd unit file set the # RemainAfterExit option on the unit file. Can be any valid value for this systemd # configuration. # Default: Not included in unit file # # @param prepare_service_only # (optional) Prepare the service and enable it as usual but do not run it right away. # Useful when building VM images using masterless Puppet and then letting the Docker images # to be downloaded when a new VM is created. # Default: false # # @param image # # @param ensure # # @param command # # @param memory_limit # # @param cpuset # # @param ports # # @param labels # # @param expose # # @param volumes # # @param links # # @param use_name # # @param running # # @param volumes_from # # @param username # # @param hostname # # @param env # # @param env_file # # @param dns # # @param dns_search # # @param lxc_conf # # @param service_provider # # @param disable_network # # @param privileged # # @param detach # # @param extra_systemd_parameters # # @param pull_on_start # # @param after # # @param after_service # # @param depends # # @param depend_services # # @param tty # # @param socket_connect # # @param hostentries # # @param before_start # # @param before_stop # # @param after_start # # @param after_stop # # @param remove_container_on_start # # @param remove_container_on_stop # # @param remove_volume_on_start # # @param remove_volume_on_stop # # @param stop_wait_time # # @param syslog_identifier # # @param read_only # define docker::run( Optional[Pattern[/^[\S]*$/]] $image, Optional[Enum[present,absent]] $ensure = 'present', Optional[String] $verify_digest = undef, Optional[String] $command = undef, Optional[Pattern[/^[\d]*(b|k|m|g)$/]] $memory_limit = '0b', Variant[String,Array,Undef] $cpuset = [], Variant[String,Array,Undef] $ports = [], Variant[String,Array,Undef] $labels = [], Variant[String,Array,Undef] $expose = [], Variant[String,Array,Undef] $volumes = [], Variant[String,Array,Undef] $links = [], Optional[Boolean] $use_name = false, Optional[Boolean] $running = true, Optional[Variant[String,Array]] $volumes_from = [], Variant[String,Array,Undef] $net = undef, Variant[String,Boolean] $username = false, Variant[String,Boolean] $hostname = false, Optional[Variant[String,Array]] $env = [], Optional[Variant[String,Array]] $env_file = [], Optional[Variant[String,Array]] $dns = [], Optional[Variant[String,Array]] $dns_search = [], Optional[Variant[String,Array]] $lxc_conf = [], Optional[String] $service_prefix = 'docker-', Optional[String] $service_provider = undef, Optional[Boolean] $restart_service = true, Optional[Boolean] $restart_service_on_docker_refresh = true, Optional[Boolean] $manage_service = true, Variant[String,Boolean] $docker_service = false, Optional[Boolean] $disable_network = false, Optional[Boolean] $privileged = false, Optional[Boolean] $detach = undef, Optional[Variant[String,Array[String]]] $extra_parameters = undef, Optional[String] $systemd_restart = 'on-failure', Optional[Variant[String,Hash]] $extra_systemd_parameters = {}, Optional[Boolean] $pull_on_start = false, Optional[Variant[String,Array]] $after = [], Optional[Variant[String,Array]] $after_service = [], Optional[Variant[String,Array]] $depends = [], Optional[Variant[String,Array]] $depend_services = ['docker.service'], Optional[Boolean] $tty = false, Optional[Variant[String,Array]] $socket_connect = [], Optional[Variant[String,Array]] $hostentries = [], Optional[String] $restart = undef, Variant[String,Boolean] $before_start = false, Variant[String,Boolean] $before_stop = false, Variant[String,Boolean] $after_start = false, Variant[String,Boolean] $after_stop = false, Optional[String] $after_create = undef, Optional[Boolean] $remove_container_on_start = true, Optional[Boolean] $remove_container_on_stop = true, Optional[Boolean] $remove_volume_on_start = false, Optional[Boolean] $remove_volume_on_stop = false, Optional[Integer] $stop_wait_time = 0, Optional[String] $syslog_identifier = undef, Optional[Boolean] $read_only = false, Optional[String] $health_check_cmd = undef, Optional[Boolean] $restart_on_unhealthy = false, Optional[Integer] $health_check_interval = undef, Optional[Variant[String,Array]] $custom_unless = [], Optional[String] $remain_after_exit = undef, Optional[Boolean] $prepare_service_only = false, ) { include docker::params if ($socket_connect != []) { $sockopts = join(any2array($socket_connect), ',') $docker_command = "${docker::params::docker_command} -H ${sockopts}" } else { $docker_command = $docker::params::docker_command } $service_name = $docker::service_name $docker_group = $docker::docker_group if $restart { assert_type(Pattern[/^(no|always|unless-stopped|on-failure)|^on-failure:[\d]+$/], $restart) } if ($remove_volume_on_start and !$remove_container_on_start) { - fail(translate("In order to remove the volume on start for ${title} you need to also remove the container")) + fail("In order to remove the volume on start for ${title} you need to also remove the container") } if ($remove_volume_on_stop and !$remove_container_on_stop) { - fail(translate("In order to remove the volume on stop for ${title} you need to also remove the container")) + fail("In order to remove the volume on stop for ${title} you need to also remove the container") } if $use_name { notify { "docker use_name warning: ${title}": message => 'The use_name parameter is no-longer required and will be removed in a future release', withpath => true, } } if $systemd_restart { assert_type(Pattern[/^(no|always|on-success|on-failure|on-abnormal|on-abort|on-watchdog)$/], $systemd_restart) } $service_provider_real = $service_provider ? { undef => $docker::params::service_provider, default => $service_provider, } if $detach == undef { $valid_detach = $service_provider_real ? { 'systemd' => false, default => $docker::params::detach_service_in_init, } } else { $valid_detach = $detach } $extra_parameters_array = any2array($extra_parameters) $after_array = any2array($after) $depends_array = any2array($depends) $depend_services_array = any2array($depend_services) $docker_run_flags = docker_run_flags( { cpuset => any2array($cpuset), disable_network => $disable_network, dns => any2array($dns), dns_search => any2array($dns_search), env => any2array($env), env_file => any2array($env_file), expose => any2array($expose), extra_params => any2array($extra_parameters), hostentries => any2array($hostentries), hostname => $hostname, links => any2array($links), lxc_conf => any2array($lxc_conf), memory_limit => $memory_limit, net => $net, ports => any2array($ports), labels => any2array($labels), privileged => $privileged, socket_connect => any2array($socket_connect), tty => $tty, username => $username, volumes => any2array($volumes), volumes_from => any2array($volumes_from), read_only => $read_only, health_check_cmd => $health_check_cmd, restart_on_unhealthy => $restart_on_unhealthy, health_check_interval => $health_check_interval, osfamily => $facts['os']['family'], } ) $sanitised_title = docker::sanitised_name($title) if empty($depends_array) { $sanitised_depends_array = [] } else { $sanitised_depends_array = docker::sanitised_name($depends_array) } if empty($after_array) { $sanitised_after_array = [] } else { $sanitised_after_array = docker::sanitised_name($after_array) } if $facts['os']['family'] == 'windows' { $exec_environment = "PATH=${::docker_program_files_path}/Docker/;${::docker_systemroot}/System32/" $exec_timeout = 3000 $exec_path = ["${::docker_program_files_path}/Docker/"] $exec_provider = 'powershell' $cidfile = "${::docker_user_temp_path}/${service_prefix}${sanitised_title}.cid" $restart_check = "${docker_command} inspect ${sanitised_title} -f '{{ if eq \\\"unhealthy\\\" .State.Health.Status }} {{ .Name }}{{ end }}' | findstr ${sanitised_title}" # lint:ignore:140chars $container_running_check = "\$state = ${docker_command} inspect ${sanitised_title} -f \"{{ .State.Running }}\"; if (\$state -ieq \"true\") { Exit 0 } else { Exit 1 }" # lint:ignore:140chars } else { $exec_environment = 'HOME=/root' $exec_path = ['/bin', '/usr/bin'] $exec_timeout = 0 $exec_provider = undef $cidfile = "/var/run/${service_prefix}${sanitised_title}.cid" $restart_check = "${docker_command} inspect ${sanitised_title} -f '{{ if eq \"unhealthy\" .State.Health.Status }} {{ .Name }}{{ end }}' | grep ${sanitised_title}" # lint:ignore:140chars $container_running_check = "${docker_command} inspect ${sanitised_title} -f \"{{ .State.Running }}\" | grep true" # lint:ignore:140chars } if $restart_on_unhealthy { exec { "Restart unhealthy container ${title} with docker": command => "${docker_command} restart ${sanitised_title}", onlyif => $restart_check, environment => $exec_environment, path => $exec_path, provider => $exec_provider, timeout => $exec_timeout, } } if $restart { if $ensure == 'absent' { exec { "stop ${title} with docker": command => "${docker_command} stop --time=${stop_wait_time} ${sanitised_title}", onlyif => "${docker_command} inspect ${sanitised_title}", environment => $exec_environment, path => $exec_path, provider => $exec_provider, timeout => $exec_timeout, } exec { "remove ${title} with docker": command => "${docker_command} rm -v ${sanitised_title}", onlyif => "${docker_command} inspect ${sanitised_title}", environment => $exec_environment, path => $exec_path, provider => $exec_provider, timeout => $exec_timeout, } file { $cidfile: ensure => absent, } } else { $run_with_docker_command = [ "${docker_command} run -d ${docker_run_flags}", "--name ${sanitised_title} --cidfile=${cidfile}", "--restart=\"${restart}\" ${image} ${command}", ] $inspect = [ "${docker_command} inspect ${sanitised_title}", ] if $custom_unless { $exec_unless = concat($custom_unless, $inspect) } else { $exec_unless = $inspect } if versioncmp($facts['puppetversion'], '6') < 0 { exec { "run ${title} with docker": command => join($run_with_docker_command, ' '), unless => $exec_unless, environment => $exec_environment, path => $exec_path, provider => $exec_provider, timeout => $exec_timeout, } if $running == false { exec { "stop ${title} with docker": command => "${docker_command} stop --time=${stop_wait_time} ${sanitised_title}", onlyif => $container_running_check, environment => $exec_environment, path => $exec_path, provider => $exec_provider, timeout => $exec_timeout, } } else { exec { "start ${title} with docker": command => "${docker_command} start ${sanitised_title}", unless => $container_running_check, environment => $exec_environment, path => $exec_path, provider => $exec_provider, timeout => $exec_timeout, } } } else { $docker_params_changed_args = { sanitised_title => $sanitised_title, osfamily => $facts['os']['family'], command => join($run_with_docker_command, ' '), cidfile => $cidfile, image => $image, volumes => $volumes, ports => $ports, stop_wait_time => $stop_wait_time, container_running => $running, # logfile_path => ($facts['os']['family'] == 'windows') ? { # true => ::docker_user_temp_path, # default => '/tmp', # }, } $detect_changes = Deferred('docker_params_changed', [$docker_params_changed_args]) notify { 'docker_params_changed': message => $detect_changes, } } } } else { $docker_run_inline_start = template('docker/docker-run-start.erb') $docker_run_inline_stop = template('docker/docker-run-stop.erb') case $service_provider_real { 'systemd': { $initscript = "/etc/systemd/system/${service_prefix}${sanitised_title}.service" $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' $mode = '0644' $hasstatus = true } 'upstart': { $initscript = "/etc/init.d/${service_prefix}${sanitised_title}" $init_template = 'docker/etc/init.d/docker-run.erb' $mode = '0750' $startscript = undef $stopscript = undef $startstop_template = undef $hasstatus = true } default: { if $facts['os']['family'] != 'windows' { - fail(translate('Docker needs a Debian or RedHat based system.')) + fail('Docker needs a Debian or RedHat based system.') } elsif $ensure == 'present' { - fail(translate('Restart parameter is required for Windows')) + fail('Restart parameter is required for Windows') } $hasstatus = $::docker::params::service_hasstatus } } if $syslog_identifier { $_syslog_identifier = $syslog_identifier } else { $_syslog_identifier = "${service_prefix}${sanitised_title}" } if $ensure == 'absent' { if $facts['os']['family'] == 'windows'{ exec { "stop container ${service_prefix}${sanitised_title}": command => "${docker_command} stop --time=${stop_wait_time} ${sanitised_title}", onlyif => "${docker_command} inspect ${sanitised_title}", environment => $exec_environment, path => $exec_path, provider => $exec_provider, timeout => $exec_timeout, notify => Exec["remove container ${service_prefix}${sanitised_title}"], } } else { service { "${service_prefix}${sanitised_title}": ensure => false, enable => false, hasstatus => $hasstatus, provider => $service_provider_real, notify => Exec["remove container ${service_prefix}${sanitised_title}"], } } exec { "remove container ${service_prefix}${sanitised_title}": command => "${docker_command} rm -v ${sanitised_title}", onlyif => "${docker_command} inspect ${sanitised_title}", environment => $exec_environment, path => $exec_path, refreshonly => true, provider => $exec_provider, timeout => $exec_timeout, } if $facts['os']['family'] != 'windows' { file { "/etc/systemd/system/${service_prefix}${sanitised_title}.service": ensure => absent, } if ($startscript) { file { $startscript: ensure => absent, } } if ($stopscript) { file { $stopscript: ensure => absent, } } } else { file { $cidfile: ensure => absent, } } } else { if ($startscript) { file { $startscript: ensure => file, content => epp($startstop_template, {'script' => $docker_run_inline_start}), owner => 'root', group => $docker_group, mode => '0770', } } if ($stopscript) { file { $stopscript: ensure => file, content => epp($startstop_template, {'script' => $docker_run_inline_stop}), owner => 'root', group => $docker_group, mode => '0770', } } file { $initscript: ensure => file, content => template($init_template), owner => 'root', group => $docker_group, mode => $mode, } if $manage_service { if $running == false { service { "${service_prefix}${sanitised_title}": ensure => $running, enable => false, hasstatus => $hasstatus, require => File[$initscript], } } else { # Transition help from moving from CID based container detection to # Name-based container detection. See #222 for context. # This code should be considered temporary until most people have # transitioned. - 2015-04-15 if $initscript == "/etc/init.d/${service_prefix}${sanitised_title}" { # This exec sequence will ensure the old-style CID container is stopped # before we replace the init script with the new-style. $transition_onlyif = [ "/usr/bin/test -f /var/run/docker-${sanitised_title}.cid &&", "/usr/bin/test -f /etc/init.d/${service_prefix}${sanitised_title}", ] exec { "/bin/sh /etc/init.d/${service_prefix}${sanitised_title} stop": onlyif => join($transition_onlyif, ' '), require => [], } -> file { "/var/run/${service_prefix}${sanitised_title}.cid": ensure => absent, } -> File[$initscript] } service { "${service_prefix}${sanitised_title}": ensure => $running and !$prepare_service_only, enable => true, provider => $service_provider_real, hasstatus => $hasstatus, require => File[$initscript], } } if $docker_service { if $docker_service == true { Service['docker'] -> Service["${service_prefix}${sanitised_title}"] if $restart_service_on_docker_refresh == true { Service['docker'] ~> Service["${service_prefix}${sanitised_title}"] } } else { Service[$docker_service] -> Service["${service_prefix}${sanitised_title}"] if $restart_service_on_docker_refresh == true { Service[$docker_service] ~> Service["${service_prefix}${sanitised_title}"] } } } } if $service_provider_real == 'systemd' and !$prepare_service_only { exec { "docker-${sanitised_title}-systemd-reload": path => ['/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/'], command => 'systemctl daemon-reload', refreshonly => true, require => [ File[$initscript], File[$startscript], File[$stopscript], ], subscribe => [ File[$initscript], File[$startscript], File[$stopscript], ], } Exec["docker-${sanitised_title}-systemd-reload"] -> Service <| title == "${service_prefix}${sanitised_title}" |> } if $restart_service { if $startscript or $stopscript { [ File[$initscript], File[$startscript], File[$stopscript], ] ~> Service <| title == "${service_prefix}${sanitised_title}" |> } else { [ File[$initscript], ] ~> Service <| title == "${service_prefix}${sanitised_title}" |> } } else { if $startscript or $stopscript { [ File[$initscript], File[$startscript], File[$stopscript], ] -> Service <| title == "${service_prefix}${sanitised_title}" |> } else { [ File[$initscript], ] -> Service <| title == "${service_prefix}${sanitised_title}" |> } } } } } diff --git a/manifests/service.pp b/manifests/service.pp index fc5b9fc..c03be61 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -1,410 +1,410 @@ # @summary manage the docker service daemon # # @param tcp_bind # Which tcp port, if any, to bind the docker service to. # # @param ip_forward # This flag interacts with the IP forwarding setting on # your host system's kernel # # @param iptables # Enable Docker's addition of iptables rules # # @param ip_masq # Enable IP masquerading for bridge's IP range. # # @param socket_bind # Which local unix socket to bind the docker service to. # # @param socket_group # Which local unix socket to bind the docker service to. # # @param root_dir # Specify a non-standard root directory for docker. # # @param extra_parameters # Plain additional parameters to pass to the docker daemon # # @param shell_values # Array of shell values to pass into init script config files # # @param manage_service # Specify whether the service should be managed. # Valid values are 'true', 'false'. # Defaults to 'true'. # # @param docker_command # # @param docker_start_command # # @param service_name # # @param icc # # @param bridge # # @param fixed_cidr # # @param default_gateway # # @param ipv6 # # @param ipv6_cidr # # @param default_gateway_ipv6 # # @param log_level # # @param log_driver # # @param log_opt # # @param selinux_enabled # # @param labels # # @param dns # # @param dns_search # # @param service_state # # @param service_enable # # @param proxy # # @param no_proxy # # @param execdriver # # @param bip # # @param mtu # # @param storage_driver # # @param dm_basesize # # @param dm_fs # # @param dm_mkfsarg # # @param dm_mountopt # # @param dm_blocksize # # @param dm_loopdatasize # # @param dm_loopmetadatasize # # @param dm_datadev # # @param dm_metadatadev # # @param tmp_dir_config # # @param tmp_dir # # @param dm_thinpooldev # # @param dm_use_deferred_removal # # @param dm_use_deferred_deletion # # @param dm_blkdiscard # # @param dm_override_udev_sync_check # # @param overlay2_override_kernel_check # # @param storage_devs # # @param storage_vg # # @param storage_root_size # # @param storage_data_size # # @param storage_min_data_size # # @param storage_chunk_size # # @param storage_growpart # # @param storage_auto_extend_pool # # @param storage_pool_autoextend_threshold # # @param storage_pool_autoextend_percent # # @param storage_config # # @param storage_config_template # # @param storage_setup_file # # @param service_provider # # @param service_config # # @param service_config_template # # @param service_overrides_template # # @param socket_overrides_template # # @param socket_override # # @param service_after_override # # @param service_hasstatus # # @param service_hasrestart # # @param daemon_environment_files # # @param tls_enable # # @param tls_verify # # @param tls_cacert # # @param tls_cert # # @param tls_key # # @param registry_mirror # # @param root_dir_flag # class docker::service ( $docker_command = $docker::docker_command, $docker_start_command = $docker::docker_start_command, $service_name = $docker::service_name, $tcp_bind = $docker::tcp_bind, $ip_forward = $docker::ip_forward, $iptables = $docker::iptables, $ip_masq = $docker::ip_masq, $icc = $docker::icc, $bridge = $docker::bridge, $fixed_cidr = $docker::fixed_cidr, $default_gateway = $docker::default_gateway, $ipv6 = $docker::ipv6, $ipv6_cidr = $docker::ipv6_cidr, $default_gateway_ipv6 = $docker::default_gateway_ipv6, $socket_bind = $docker::socket_bind, $log_level = $docker::log_level, $log_driver = $docker::log_driver, $log_opt = $docker::log_opt, $selinux_enabled = $docker::selinux_enabled, $socket_group = $docker::socket_group, $labels = $docker::labels, $dns = $docker::dns, $dns_search = $docker::dns_search, $service_state = $docker::service_state, $service_enable = $docker::service_enable, $manage_service = $docker::manage_service, $root_dir = $docker::root_dir, $extra_parameters = $docker::extra_parameters, $shell_values = $docker::shell_values, $proxy = $docker::proxy, $no_proxy = $docker::no_proxy, $execdriver = $docker::execdriver, $bip = $docker::bip, $mtu = $docker::mtu, $storage_driver = $docker::storage_driver, $dm_basesize = $docker::dm_basesize, $dm_fs = $docker::dm_fs, $dm_mkfsarg = $docker::dm_mkfsarg, $dm_mountopt = $docker::dm_mountopt, $dm_blocksize = $docker::dm_blocksize, $dm_loopdatasize = $docker::dm_loopdatasize, $dm_loopmetadatasize = $docker::dm_loopmetadatasize, $dm_datadev = $docker::dm_datadev, $dm_metadatadev = $docker::dm_metadatadev, $tmp_dir_config = $docker::tmp_dir_config, $tmp_dir = $docker::tmp_dir, $dm_thinpooldev = $docker::dm_thinpooldev, $dm_use_deferred_removal = $docker::dm_use_deferred_removal, $dm_use_deferred_deletion = $docker::dm_use_deferred_deletion, $dm_blkdiscard = $docker::dm_blkdiscard, $dm_override_udev_sync_check = $docker::dm_override_udev_sync_check, $overlay2_override_kernel_check = $docker::overlay2_override_kernel_check, $storage_devs = $docker::storage_devs, $storage_vg = $docker::storage_vg, $storage_root_size = $docker::storage_root_size, $storage_data_size = $docker::storage_data_size, $storage_min_data_size = $docker::storage_min_data_size, $storage_chunk_size = $docker::storage_chunk_size, $storage_growpart = $docker::storage_growpart, $storage_auto_extend_pool = $docker::storage_auto_extend_pool, $storage_pool_autoextend_threshold = $docker::storage_pool_autoextend_threshold, $storage_pool_autoextend_percent = $docker::storage_pool_autoextend_percent, $storage_config = $docker::storage_config, $storage_config_template = $docker::storage_config_template, $storage_setup_file = $docker::storage_setup_file, $service_provider = $docker::service_provider, $service_config = $docker::service_config, $service_config_template = $docker::service_config_template, $service_overrides_template = $docker::service_overrides_template, $socket_overrides_template = $docker::socket_overrides_template, $socket_override = $docker::socket_override, $service_after_override = $docker::service_after_override, $service_hasstatus = $docker::service_hasstatus, $service_hasrestart = $docker::service_hasrestart, $daemon_environment_files = $docker::daemon_environment_files, $tls_enable = $docker::tls_enable, $tls_verify = $docker::tls_verify, $tls_cacert = $docker::tls_cacert, $tls_cert = $docker::tls_cert, $tls_key = $docker::tls_key, $registry_mirror = $docker::registry_mirror, $root_dir_flag = $docker::root_dir_flag, ) { unless $facts['os']['family'] =~ /(Debian|RedHat|windows)/ or $::docker::acknowledge_unsupported_os { - fail(translate('The docker::service class needs a Debian, Redhat or Windows based system.')) + fail('The docker::service class needs a Debian, Redhat or Windows based system.') } $dns_array = any2array($dns) $dns_search_array = any2array($dns_search) $labels_array = any2array($labels) $extra_parameters_array = any2array($extra_parameters) $shell_values_array = any2array($shell_values) $tcp_bind_array = any2array($tcp_bind) if $service_config != undef { $_service_config = $service_config } else { if $facts['os']['family'] == 'Debian' { $_service_config = "/etc/default/${service_name}" } else { $_service_config = undef } } $_manage_service = $manage_service ? { true => Service['docker'], default => [], } if $facts['os']['family'] == 'RedHat' { file { $storage_setup_file: ensure => file, force => true, content => template('docker/etc/sysconfig/docker-storage-setup.erb'), before => $_manage_service, notify => $_manage_service, } } if $facts['os']['family'] == 'windows' { $dirs = [ "${::docker_program_data_path}/docker/", "${::docker_program_data_path}/docker/config/", ] $dirs.each |$dir| { file { $dir: ensure => directory, } } } case $service_provider { 'systemd': { file { '/etc/systemd/system/docker.service.d': ensure => 'directory', } if $service_overrides_template { file { '/etc/systemd/system/docker.service.d/service-overrides.conf': ensure => file, content => template($service_overrides_template), notify => Exec['docker-systemd-reload-before-service'], before => $_manage_service, } } if $socket_override { file { '/etc/systemd/system/docker.socket.d': ensure => 'directory', } file { '/etc/systemd/system/docker.socket.d/socket-overrides.conf': ensure => file, content => template($socket_overrides_template), notify => Exec['docker-systemd-reload-before-service'], before => $_manage_service, } } exec { 'docker-systemd-reload-before-service': path => [ '/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/', ], command => 'systemctl daemon-reload > /dev/null', notify => $_manage_service, refreshonly => true, } } 'upstart': { file { '/etc/init.d/docker': ensure => 'link', target => '/lib/init/upstart-job', force => true, notify => $_manage_service, } } default: {} } #workaround for docker 1.13 on RedHat 7 if $facts['docker_server_version']{ if $facts['os']['family'] == 'RedHat' and $facts['docker_server_version'] =~ /1\.13.+/{ $_skip_storage_config = true } else { $_skip_storage_config = false } } else { $_skip_storage_config = false } if $storage_config { unless $_skip_storage_config { file { $storage_config: ensure => file, force => true, #force rewrite storage configuration content => template($storage_config_template), notify => $_manage_service, } } } if $_service_config { file { $_service_config: ensure => file, force => true, content => template($service_config_template), notify => $_manage_service, } } if $manage_service { if $facts['os']['family'] == 'windows' { reboot { 'pending_reboot': when => 'pending', onlyif => 'component_based_servicing', timeout => 1, } } if ! defined(Service['docker']) { service { 'docker': ensure => $service_state, name => $service_name, enable => $service_enable, hasstatus => $service_hasstatus, hasrestart => $service_hasrestart, provider => $service_provider, } } } } diff --git a/manifests/services.pp b/manifests/services.pp index 26f19d4..6b8f8f3 100644 --- a/manifests/services.pp +++ b/manifests/services.pp @@ -1,208 +1,208 @@ # @summary define that managers a Docker services # # @param ensure # This ensures that the service is present or not. # # @param image # The Docker image to spwan the service from. # # @param detach # Exit immediately instead of waiting for the service to converge (default true) # # @param env # Set environment variables # # @param label # Service labels. # This used as metdata to configure constraints etc. # # @param publish # Publish port(s) as node ports. # # @param replicas # Number of tasks (containers per service) # # @param tty # Allocate a pseudo-TTY # # @param user # Username or UID (format: [:]) # # @param workdir # Working directory inside the container # # @param extra_params # Allows you to pass any other flag that the Docker service create supports. # This must be passed as an array. See docker service create --help for all options # # @param update # This changes the docker command to # docker service update, you must pass a service name with this option # # @param scale # This changes the docker command to # docker service scale, this can only be used with service name and # replicas # # @param host_socket # This will allow the service to connect to the host linux socket. # # @param registry_mirror # This will allow the service to set a registry mirror. # # @param mounts # Allows attaching filesystem mounts to the service (specified as an array) # # @param networks # Allows attaching the service to networks (specified as an array) # # @param command # Command to run on the container # # @param create # # @param service_name # define docker::services( Optional[Enum[present,absent]] $ensure = 'present', Optional[Boolean] $create = true, Optional[Boolean] $update = false, Optional[Boolean] $scale = false, Optional[Boolean] $detach = true, Optional[Boolean] $tty = false, Optional[Array] $env = [], Optional[Array] $label = [], Optional[Array] $extra_params = [], Optional[Variant[String,Array]] $image = undef, Optional[Variant[String,Array]] $service_name = undef, Optional[Variant[String,Array]] $publish = undef, Optional[Variant[String,Array]] $replicas = undef, Optional[Variant[String,Array]] $user = undef, Optional[Variant[String,Array]] $workdir = undef, Optional[Variant[String,Array]] $host_socket = undef, Optional[Variant[String,Array]] $registry_mirror = undef, Optional[Variant[String,Array]] $mounts = undef, Optional[Array] $networks = undef, Optional[Variant[String,Array]] $command = undef, ) { include docker::params $docker_command = "${docker::params::docker_command} service" if $ensure == 'absent' { if $update { - fail(translate('When removing a service you can not update it.')) + fail('When removing a service you can not update it.') } if $scale { - fail(translate('When removing a service you can not update it.')) + fail('When removing a service you can not update it.') } } if $facts['os']['family'] == 'windows' { $exec_environment = "PATH=${::docker_program_files_path}/Docker/;${::docker_systemroot}/System32/" $exec_path = [ "${::docker_program_files_path}/Docker/", ] $exec_provider = 'powershell' $exec_timeout = 3000 } else { $exec_environment = 'HOME=/root' $exec_path = [ '/bin', '/usr/bin', ] $exec_provider = undef $exec_timeout = 0 } if $create { $docker_service_create_flags = docker_service_flags( { detach => $detach, env => any2array($env), service_name => $service_name, label => any2array($label), publish => $publish, replicas => $replicas, tty => $tty, user => $user, workdir => $workdir, extra_params => any2array($extra_params), image => $image, host_socket => $host_socket, registry_mirror => $registry_mirror, mounts => $mounts, networks => $networks, command => $command, } ) $exec_create = "${docker_command} create --name ${docker_service_create_flags}" $unless_create = "docker service ps ${service_name}" exec { "${title} docker service create": command => $exec_create, environment => $exec_environment, path => $exec_path, timeout => $exec_timeout, provider => $exec_provider, unless => $unless_create, } } if $update { $docker_service_flags = docker_service_flags( { detach => $detach, env => any2array($env), service_name => $service_name, label => any2array($label), publish => $publish, replicas => $replicas, tty => $tty, user => $user, workdir => $workdir, extra_params => any2array($extra_params), image => $image, host_socket => $host_socket, registry_mirror => $registry_mirror, } ) $exec_update = "${docker_command} update ${docker_service_flags}" exec { "${title} docker service update": command => $exec_update, environment => $exec_environment, path => $exec_path, provider => $exec_provider, timeout => $exec_timeout, } } if $scale { $docker_service_flags = docker_service_flags( { service_name => $service_name, replicas => $replicas, extra_params => any2array($extra_params), } ) $exec_scale = "${docker_command} scale ${service_name}=${replicas}" exec { "${title} docker service scale": command => $exec_scale, environment => $exec_environment, path => $exec_path, timeout => $exec_timeout, provider => $exec_provider, } } if $ensure == 'absent' { exec { "${title} docker service remove": command => "docker service rm ${service_name}", onlyif => "docker service ps ${service_name}", path => $exec_path, provider => $exec_provider, timeout => $exec_timeout, } } } diff --git a/metadata.json b/metadata.json index 1699b9b..033c058 100644 --- a/metadata.json +++ b/metadata.json @@ -1,73 +1,69 @@ { "name": "puppetlabs-docker", "version": "4.0.0", "author": "puppetlabs", "summary": "Module for installing and managing docker", "license": "Apache-2.0", "source": "git://github.com/puppetlabs/puppetlabs-docker", "project_page": "https://github.com/puppetlabs/puppetlabs-docker", "issues_url": "https://github.com/puppetlabs/puppetlabs-docker/issues", "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": ">= 4.24.0 < 8.0.0" }, { "name": "puppetlabs/apt", "version_requirement": ">= 4.4.1 < 9.0.0" }, - { - "name": "puppetlabs/translate", - "version_requirement": ">= 0.0.1 < 3.0.0" - }, { "name": "puppetlabs/powershell", "version_requirement": ">= 2.1.4 < 6.0.0" }, { "name": "puppetlabs/reboot", "version_requirement": ">=2.0.0 < 5.0.0" } ], "operatingsystem_support": [ { "operatingsystem": "CentOS", "operatingsystemrelease": [ "7" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "14.04", "16.04", "18.04", "20.04" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "8", "9", "10" ] }, { "operatingsystem": "Windows", "operatingsystemrelease": [ "2016", "2019" ] } ], "requirements": [ { "name": "puppet", "version_requirement": ">= 6.0.0 < 8.0.0" } ], "pdk-version": "1.18.1", "template-url": "https://github.com/puppetlabs/pdk-templates.git#main", "template-ref": "heads/main-0-g44cc7ed" } diff --git a/spec/helper/get_values_init.rb b/spec/helper/get_values_init.rb index 42e75a0..2b6422c 100644 --- a/spec/helper/get_values_init.rb +++ b/spec/helper/get_values_init.rb @@ -1,77 +1,77 @@ # frozen_string_literal: true def get_values_init(_params, _facts) if _params['version'] == :undef || _params['version'] !~ %r{^(17[.][0-1][0-9][.][0-1](~|-|\.)ce|1.\d+)} if _params['docker_ee'] package_location = _params['docker_ee_source_location'] package_key_source = _params['docker_ee_key_source'] package_key_check_source = true package_key = _params['docker_ee_key_id'] package_repos = _params['docker_ee_repos'] release = _params['docker_ee_release'] docker_start_command = _params['docker_ee_start_command'] docker_package_name = _params['docker_ee_package_name'] else case _facts[:os]['family'] when 'Debian' package_location = _params['docker_ce_source_location'] package_key_source = _params['docker_ce_key_source'] package_key = _params['docker_ce_key_id'] package_repos = _params['docker_ce_channel'] release = _params['docker_ce_release'] when 'RedHat' package_location = _params['docker_ce_source_location'] package_key_source = _params['docker_ce_key_source'] package_key_check_source = true # when 'windows' - # fail(translate('This module only work for Docker Enterprise Edition on Windows.')) + # fail('This module only work for Docker Enterprise Edition on Windows.') else package_location = _params['docker_package_location'] package_key_source = _params['docker_package_key_source'] package_key_check_source = _params['docker_package_key_check_source'] end docker_start_command = _params['docker_ce_start_command'] docker_package_name = _params['docker_ce_package_name'] end else case _facts[:os]['family'] when 'Debian' package_location = _params['docker_package_location'] package_key_source = _params['docker_package_key_source'] package_key_check_source = _params['docker_package_key_check_source'] package_key = _params['docker_package_key_id'] package_repos = 'main' release = _params['docker_package_release'] when 'RedHat' package_location = _params['docker_package_location'] package_key_source = _params['docker_package_key_source'] package_key_check_source = _params['docker_package_key_check_source'] else package_location = _params['docker_package_location'] package_key_source = _params['docker_package_key_source'] package_key_check_source = _params['docker_package_key_check_source'] end docker_start_command = _params['docker_engine_start_command'] docker_package_name = _params['docker_engine_package_name'] end root_dir_flag = if _params['version'] != :undef && _params['version'] =~ %r{^(17[.]0[0-4]|1.\d+)} '-g' else '--data-root' end { 'docker_package_name' => docker_package_name, 'docker_start_command' => docker_start_command, 'package_key' => package_key, 'package_key_check_source' => package_key_check_source, 'package_key_source' => package_key_source, 'package_location' => package_location, 'package_repos' => package_repos, 'release' => release, 'root_dir_flag' => root_dir_flag, } end