puppet can not auto update files under one dircetory when one of these files was deleted

30 views
Skip to first unread message

paul zhao

unread,
Jan 21, 2016, 5:03:24 AM1/21/16
to Puppet Users
In Centos 6.5, I use puppet 3.8.2. I found an question, for example:

 in pupept-server machine, there has diretory A,  and a.conf in A, b.conf in A,
then in puppet-agent, after synchronized(puppet agent -t), there also has diretory A, a.conf in A, b.conf in A
next, in pupept-server, I deleted ../A/b.conf,
then in puppet-agent, after synchronized(puppet agent -t), there also has diretory A, a.conf in A and b.conf in A, 

Why in puppet-agent, ../A/b.conf still existed?

Lowe Schmidt

unread,
Jan 21, 2016, 5:59:54 AM1/21/16
to puppet...@googlegroups.com
Puppet does not remove files on agent systems if the puppet server does not have them anymore.

What you probably want to do is set the "ensure => absent" on the file resource in your puppet code. 
This will ensure that the file is deleted on the puppet agent machine.

--
Lowe Schmidt | +46 723 867 157

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/3d8d5d0a-be60-4223-9031-6655b6a68f8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jcbollinger

unread,
Jan 21, 2016, 9:36:49 AM1/21/16
to Puppet Users


You did not present the relevant manifests with which you are managing these files, and much hinges on the details of those.

From your description, I speculate that you are managing the whole thing via a single recursive File resource, something like this:

    file { '/some/parent/A':
     
ensure  => 'directory',
      source  
=> 'puppet:///modules/mymodule/A',
      owner  
=> 'root',
     
group   => 'root',
      mode    
=> '0644',
      recurse
=> true
   
}

With that particular declaration, Puppet will manage directory /some/parent/A, and it will additionally manage one File for each for each file in the directory tree rooted in directory A of the modules files directory.  That declaration will not cause any other files to be managed, but if you want to additionally ensure that the managed directory contains only managed files (whether managed via that File resource or another) then you can specify that by adding a 'purge' attribute:

      purge   => true,

This is covered by the type reference.


John

Reply all
Reply to author
Forward
0 new messages