Monday, March 24, 2014

Puppet file recurse

to purge or not to purge?
to recurse or not to recurse?
I have a bunch of files in a mymodule/files/myfiles folder inside the puppet module mymodule. I need to copy them to a target folder. I don't want to specify the INDIVIDUAL files, so I want to use the "recurse" option.

This will do absolutely NOTHING:

  file { '/opt/oracle/fmw11_1_1_5/wlserver_10.3/common/wlst/modules/' :
    source  => "puppet:///modules/mymodule/myfiles/",
  }


This will change mode to ALL files under /opt/oracle/fmw11_1_1_5/wlserver_10.3/common/wlst/modules/ (including subdirectories), but will NOT remove them:

  file { '/opt/oracle/fmw11_1_1_5/wlserver_10.3/common/wlst/modules/' :
    source  => "puppet:///modules/mymodule/myfiles/",
    recurse => true
  }


This will remove any file which is not in the source, but subdirectories will remain:

  file { '/opt/oracle/fmw11_1_1_5/wlserver_10.3/common/wlst/modules/' :
    source  => "puppet:///modules/mymodule/myfiles/",
    recurse => true,
    purge => true,
  }


This is the least-impacting: it will not change existing files, and will just copy the files in source:
  file { '/opt/oracle/fmw11_1_1_5/wlserver_10.3/common/wlst/modules/' :
    source  => "puppet:///modules/mymodule/myfiles/",
    recurse => remote
  }




No comments: