-
Notifications
You must be signed in to change notification settings - Fork 316
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
Conversation
docker::run is a typeBreaking changes to this file WILL impact these 8 modules (exact match):Breaking changes to this file MAY impact these 22 modules (near match):
docker::service is a classthat may have no external impact to Forge modules. This module is declared in 6 of 579 indexed public
|
@chelnak @shoddyguard @marrajo-afk @jhaezebr has anyone been able to test and verify the expected fix with this pull request? It looks good to me though I would like some peer review please. |
Hey! It's community day today so I'll add it to my list. It would speed up my repro if you could provide a really basic manifest! |
@chelnak I think the following should do. Expected outcomes after 1 puppet run:
class test {
file { '/usr/local/share/tmp_docker':
ensure => directory
}
class { 'docker':
log_driver => 'journald',
}
$compose = "compose_test:
image: ubuntu:14.04
command: /bin/sh -c 'while true; do echo hello world; sleep 1; done'
"
file { '/tmp/compose.yml':
content => $compose
}
class { 'docker::compose':
ensure => present,
}
docker_compose {'test':
ensure => present,
compose_files => [
'/tmp/compose.yml'
],
tmpdir => '/usr/local/share/tmp_docker',
scale => {
compose_test => 3
},
}
docker_network { 'test-network':
ensure => present,
subnet => '192.168.1.0/24',
gateway => '192.168.1.1',
ip_range => '192.168.1.4/32',
}
docker_volume { 'test-volume':
ensure => present,
}
} 1st & 2nd [root@testhost ~]# puppet agent -t
Info: Using environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Info: Applying configuration version '1653903396'
Notice: /Stage[main]/Roles::Test2/File[/usr/local/share/tmp_docker]/ensure: created
Notice: /Stage[main]/Docker::Repos/Yumrepo[docker]/ensure: created
Info: Yumrepo[docker](provider=inifile): changing mode of /etc/yum.repos.d/docker.repo from 600 to 644
Notice: /Stage[main]/Docker::Install/Package[docker]/ensure: created
Notice: /Stage[main]/Docker::Service/File[/etc/sysconfig/docker-storage-setup]/ensure: defined content as '{md5}506aef96bd8f918482f6ccb3ebbee4b7'
Info: /Stage[main]/Docker::Service/File[/etc/sysconfig/docker-storage-setup]: Scheduling refresh of Service[docker]
Notice: /Stage[main]/Docker::Service/File[/etc/systemd/system/docker.service.d]/ensure: created
Notice: /Stage[main]/Docker::Service/File[/etc/systemd/system/docker.service.d/service-overrides.conf]/ensure: defined content as '{md5}8ccfdfe9d23fcdb2903d34490d268d61'
Info: /Stage[main]/Docker::Service/File[/etc/systemd/system/docker.service.d/service-overrides.conf]: Scheduling refresh of Exec[docker-systemd-reload-before-service]
Notice: /Stage[main]/Docker::Service/Exec[docker-systemd-reload-before-service]: Triggered 'refresh' from 1 event
Info: /Stage[main]/Docker::Service/Exec[docker-systemd-reload-before-service]: Scheduling refresh of Service[docker]
Notice: /Stage[main]/Docker::Service/File[/etc/sysconfig/docker-storage]/ensure: defined content as '{md5}0f427b02d0882d0df4de752f77402f3e'
Info: /Stage[main]/Docker::Service/File[/etc/sysconfig/docker-storage]: Scheduling refresh of Service[docker]
Notice: /Stage[main]/Docker::Service/File[/etc/sysconfig/docker]/ensure: defined content as '{md5}9b10f52d78ad3d59be03d9eeae8e2a37'
Info: /Stage[main]/Docker::Service/File[/etc/sysconfig/docker]: Scheduling refresh of Service[docker]
Notice: /Stage[main]/Docker::Service/Service[docker]/ensure: ensure changed 'stopped' to 'running'
Info: /Stage[main]/Docker::Service/Service[docker]: Unscheduling refresh on Service[docker]
Notice: /Stage[main]/Roles::Test2/File[/tmp/compose.yml]/ensure: defined content as '{md5}b73aff62bed17c8751e93314cefdfc4c'
Notice: /Stage[main]/Docker::Compose/Exec[Install Docker Compose 1.29.2]/returns: executed successfully
Notice: /Stage[main]/Docker::Compose/File[/usr/local/bin/docker-compose-1.29.2]/mode: mode changed '0600' to '0755'
Notice: /Stage[main]/Docker::Compose/File[/usr/local/bin/docker-compose-1.29.2]/seluser: seluser changed 'unconfined_u' to 'system_u'
Notice: /Stage[main]/Docker::Compose/File[/usr/local/bin/docker-compose-1.29.2]/seltype: seltype changed 'bin_t' to 'container_runtime_exec_t'
Notice: /Stage[main]/Docker::Compose/File[/usr/local/bin/docker-compose]/ensure: created
Info: Checking for compose project test
Info: Running compose project test
Info: Scaling compose project test: compose_test=3
Notice: /Stage[main]/Roles::Test2/Docker_compose[test]/ensure: created
Info: Checking if docker network test-network exists
Info: Creating docker network test-network
Notice: /Stage[main]/Roles::Test2/Docker_network[test-network]/ensure: created
Info: Checking if docker volume test-volume exists
Info: Creating docker volume test-volume
Notice: /Stage[main]/Roles::Test2/Docker_volume[test-volume]/ensure: created
Notice: Applied catalog in 96.55 seconds
[root@testhost ~]# puppet agent -t
Info: Using environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Info: Applying configuration version '1653903565'
Info: Checking for compose project test
Info: Checking for compose service compose_test ubuntu:14.04
Info: Checking if docker network test-network exists
Info: Checking if docker volume test-volume exists
Notice: Applied catalog in 1.57 seconds [root@testhost]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
180ccf088e64 ubuntu:14.04 "/bin/sh -c 'while t…" 4 minutes ago Up 4 minutes test_compose_test_2
17f325314b04 ubuntu:14.04 "/bin/sh -c 'while t…" 4 minutes ago Up 4 minutes test_compose_test_3
72575909884d ubuntu:14.04 "/bin/sh -c 'while t…" 4 minutes ago Up 4 minutes test_compose_test_1 [root@testhost ~]# docker network ls
NETWORK ID NAME DRIVER SCOPE
e17e6523c7d1 bridge bridge local
e22d31e057e6 host host local
e8220c3084d8 none null local
5f491b3be3b2 test-network bridge local
[root@testhost ~]# docker volume ls
DRIVER VOLUME NAME
local test-volume |
Pulled this module into my Dev environment and it worked perfectly (Ubuntu 18.04 & 20.04). |
These changes appear to fix the issue where the docker and docker-compose binaries are not found on first run, by removing the early realizing of those resources before they actually exist.
A further issue with selinux context being reset on container
.system
files,service-overrides.conf
andsocket-overrides.conf
is also fixed by setting the seltype upon creating these files. This also prevents containers being restarted as a result.Despite the removal of
commands
in the provider files, thehas_command
appears to be sufficient to allow the binaries to be located at runtime and after first installation. TheHOME: '/root'
environment parameter has also been removed from the providers without perceived side-effect.I have tested these changes to the desired effect, however welcome others to test and verify please.