Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docker-compose, network and volumes not applying on 1st run, fix other idempotency #833

Merged
merged 8 commits into from
May 30, 2022
10 changes: 2 additions & 8 deletions lib/puppet/provider/docker_compose/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,10 @@
desc 'Support for Puppet running Docker Compose'

mk_resource_methods
commands dockercompose: 'docker-compose'
commands dockercmd: 'docker'

has_command(:docker, command(:dockercmd)) do
environment(HOME: '/root')
end
has_command(:docker, 'docker')

has_command(:docker_compose, command(:dockercompose)) do
environment(HOME: '/root')
end
has_command(:dockercompose, 'docker-compose')

def set_tmpdir
return unless resource[:tmpdir]
Expand Down
5 changes: 1 addition & 4 deletions lib/puppet/provider/docker_network/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
desc 'Support for Docker Networking'

mk_resource_methods
commands dockercmd: 'docker'

has_command(:docker, command(:dockercmd)) do
environment(HOME: '/root')
end
has_command(:docker, 'docker')

def network_conf
flags = ['network', 'create']
Expand Down
5 changes: 1 addition & 4 deletions lib/puppet/provider/docker_stack/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
desc 'Support for Puppet running Docker Stacks'

mk_resource_methods
commands dockercmd: 'docker'

has_command(:docker, command(:dockercmd)) do
environment(HOME: '/root')
end
has_command(:docker, 'docker')

def exists?
Puppet.info("Checking for stack #{name}")
Expand Down
5 changes: 1 addition & 4 deletions lib/puppet/provider/docker_volume/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
desc 'Support for Docker Volumes'

mk_resource_methods
commands dockercmd: 'docker'

has_command(:docker, command(:dockercmd)) do
environment(HOME: '/root')
end
has_command(:docker, 'docker')

def volume_conf
flags = ['volume', 'create']
Expand Down
1 change: 1 addition & 0 deletions manifests/compose.pp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
file { $docker_compose_location_versioned:
owner => $file_owner,
mode => '0755',
seltype => 'container_runtime_exec_t',
require => Exec["Install Docker Compose ${version}"],
}

Expand Down
4 changes: 2 additions & 2 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@

if ($facts['os']['family'] == 'windows') {
$compose_install_path = "${::docker_program_files_path}/Docker"
$compose_version = '1.21.2'
$compose_version = '1.29.2'
$docker_ee_package_name = 'Docker'
$machine_install_path = "${::docker_program_files_path}/Docker"
$tls_cacert = "${::docker_program_data_path}/docker/certs.d/ca.pem"
$tls_cert = "${::docker_program_data_path}/docker/certs.d/server-cert.pem"
$tls_key = "${::docker_program_data_path}/docker/certs.d/server-key.pem"
} else {
$compose_install_path = '/usr/local/bin'
$compose_version = '1.21.2'
$compose_version = '1.29.2'
$docker_ee_package_name = 'docker-ee'
$machine_install_path = '/usr/local/bin'
$tls_cacert = '/etc/docker/tls/ca.pem'
Expand Down
3 changes: 3 additions & 0 deletions manifests/run.pp
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@
file { $startscript:
ensure => file,
content => epp($startstop_template, { 'script' => $docker_run_inline_start }),
seltype => 'container_runtime_exec_t',
owner => 'root',
group => $docker_group,
mode => '0770',
Expand All @@ -581,6 +582,7 @@
file { $stopscript:
ensure => file,
content => epp($startstop_template, { 'script' => $docker_run_inline_stop }),
seltype => 'container_runtime_exec_t',
owner => 'root',
group => $docker_group,
mode => '0770',
Expand All @@ -590,6 +592,7 @@
file { $initscript:
ensure => file,
content => template($init_template),
seltype => 'container_unit_file_t',
owner => 'root',
group => $docker_group,
mode => $mode,
Expand Down
2 changes: 2 additions & 0 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@
file { '/etc/systemd/system/docker.service.d/service-overrides.conf':
ensure => file,
content => template($service_overrides_template),
seltype => 'container_unit_file_t',
notify => Exec['docker-systemd-reload-before-service'],
before => $_manage_service,
}
Expand All @@ -333,6 +334,7 @@
file { '/etc/systemd/system/docker.socket.d/socket-overrides.conf':
ensure => file,
content => template($socket_overrides_template),
seltype => 'container_unit_file_t',
notify => Exec['docker-systemd-reload-before-service'],
before => $_manage_service,
}
Expand Down