Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-896

Copy body cannot purge empty directories

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.5.3
    • Component/s: Promise type: files
    • Labels:
      None

      Description

      Considering this policy. I'd like to purge copy destination directory to be exactly the same as source directory.

      <pre>
      body common control
      {
      bundlesequence =>

      { "testsync" }

      ;
      inputs =>

      { "/var/cfengine/inputs/libraries/cfengine_stdlib.cf" }

      ;
      }

      bundle agent testsync
      {
      files:
      cfengine::
      "/tmp/testdir/."
      create => "true",
      copy_from => sync_dcp_nopreserve("/var/cfengine/masterfiles","$(sys.policy_hub)"),
      perms => mog("444","root","root"),
      depth_search => recurse("inf"),
      action => immediate;
      }

      body copy_from sync_dcp_nopreserve(from,server)
      {
      servers =>

      { "$(server)" }

      ;
      source => "$(from)";
      purge => "true";
      preserve => "false";
      type_check => "false";
      compare => "digest";
      }
      </pre>

      CFEngine works fine on root empty directories, but not on on hierarchical empty directories.

      <pre>
      root@d710i386:~# cf-agent -f /tmp/testsync.cf -K
      root@d710i386:~# ls /tmp/testdir/
      cfe_internal cf_promises_validated Changelog controls def.cf lib libraries promises.cf services sketches update update.cf

      root@d710i386:~# mkdir /tmp/testdir/xxx /tmp/testdir/zzz
      root@d710i386:~# ls /tmp/testdir/
      cfe_internal cf_promises_validated Changelog controls def.cf lib libraries promises.cf services sketches update update.cf xxx zzz
      root@d710i386:~# cf-agent -f /tmp/testsync.cf -K

      root@d710i386:~# mkdir -p /tmp/testdir/xxx/111/222 /tmp/testdir/zzz/aaa/bbb
      root@d710i386:~# cf-agent -f /tmp/testsync.cf -K
      root@d710i386:~# ls /tmp/testdir/
      cfe_internal cf_promises_validated Changelog controls def.cf lib libraries promises.cf services sketches update update.cf xxx zzz

      root@d710i386:~# cf-agent -f /tmp/testsync.cf -IK
      2013-09-16T11:45:10+0200 info: Purging '/tmp/testdir/./zzz' in copy dest directory
      2013-09-16T11:45:10+0200 info: Purging '/tmp/testdir/./xxx' in copy dest directory
      root@d710i386:~# ls /tmp/testdir/
      cfe_internal cf_promises_validated Changelog controls def.cf lib libraries promises.cf services sketches update update.cf xxx zzz

      root@d710i386:~# find /tmp/testdir/xxx/
      /tmp/testdir/xxx/
      /tmp/testdir/xxx/111
      /tmp/testdir/xxx/111/222
      root@d710i386:~# find /tmp/testdir/zzz/
      /tmp/testdir/zzz/
      /tmp/testdir/zzz/aaa
      /tmp/testdir/zzz/aaa/bbb
      </pre>

      A workaround should be having a command promise, for example, "find" to purge empty directories.

      <pre>
      commands:
      "/usr/bin/find -type d -empty -delete"
      contain => in_dir_shell_and_silent("/tmp/testdir");
      </pre>

        Attachments

          Activity

            People

            • Assignee:
              a10025 Volker Hilsheimer (Inactive)
              Reporter:
              a10005 Nakarin Phooripoom (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Summary Panel