puppetlabs-docker icon indicating copy to clipboard operation
puppetlabs-docker copied to clipboard

Rebuild config.json, if not present

Open maltewhiite opened this issue 3 years ago • 1 comments

If I delete /root/.docker/config.json then it isn't rebuilt by docker::registry.

~~I suggest adding a creates => '/root/.docker/config.json', to the exec.~~

https://github.com/puppetlabs/puppetlabs-docker/blob/f7df65a9c2eff754e798ff6c21f22e260662ffc8/manifests/registry.pp#L150

I am using version 4.2.1 of the module.

Removing file, then running puppet.
[:~/.docker]# ll
total 4
-rw-------. 1 root root 413 Jun 13 12:34 config.json
[:~/.docker]# mv config.json config.json_backup
[:~/.docker]# ll
total 4
-rw-------. 1 root root 413 Jun 13 12:34 config.json_backup
[:~/.docker]# puppet agent -t
Info: Using environment 'test'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Info: Caching catalog for 
Info: Applying configuration version '1655125098'
Info: Checking if docker volume gitlab-runner-config exists
Notice: Applied catalog in 9.65 seconds
[:~/.docker]# ll
total 4
-rw-------. 1 root root 413 Jun 13 12:34 config.json_backup
[:~/.docker]# 

This is the puppet code we use to set up connection to our private docker registry.

  # Use our private Docker Registry
  docker::registry { $docker_registry:
    server   => $docker_registry,
    username => $repository_username,
    password => $repository_password,
    require  => Class['docker'],
  }
code comments for "creates"

creates

A file to look for before running the command. The command will only run if the file doesn’t exist.

This parameter doesn’t cause Puppet to create a file; it is only useful if the command itself creates a file.

exec { 'tar -xf /Volumes/nfs02/important.tar':
   cwd     => '/var/tmp',
   creates => '/var/tmp/myfile',
   path    => ['/usr/bin', '/usr/sbin',],
 }

In this example, myfile is assumed to be a file inside important.tar. If it is ever deleted, the exec will bring it back by re-extracting the tarball. If important.tar does not actually contain myfile, the exec will keep running every time Puppet runs.

maltewhiite avatar Jun 13 '22 12:06 maltewhiite

Apparently there is made a "receipt" file. And this exec is "refreshonly" so just adding the "creates" doesn't fix it, sadly.

I however still think this issue is relevant. The core of it is "If someone or something deletes "config.json", then puppet doesn't rebuild it."

maltewhiite avatar Jun 13 '22 13:06 maltewhiite

Hello! 👋

This issue has been open for a while and has had no recent activity. We've labelled it with attention-needed so that we can get a clear view of which issues need our attention.

If you are waiting on a response from us we will try and address your comments on a future Community Day.

Alternatively, if it is no longer relevant to you please close the issue with a comment.

github-actions[bot] avatar Sep 19 '22 02:09 github-actions[bot]