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

storage - fstab edit fails when default_repository is set

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: (None)
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Promise type: storage
    • Labels:
      None

      Description

      original thread: https://groups.google.com/forum/#!topic/help-cfengine/NsPGRkQY7Pg

      With CFEngine 3.4.2 on Debian Wheezy I cannot add nfs mounts using cf3 because
      auto-fstab editing fails when a backup or "default_repository" is set. Other
      file editing and backup seems to work. If default_repository is not set,
      everything works as expected.

      Take this example:

      <pre>
      #########################################################
      body common control {
      ifelapsed => "0";
      bundlesequence =>

      { "files", "mounts" }

      ;
      inputs =>

      { "cfengine_stdlib.cf" }

      ;
      }

      #########################################################
      body agent control {
      any::
      default_repository => "/tmp/backups";
      }

      #########################################################
      bundle agent files

      { files: "/etc/delme" perms => system, create => "true", edit_line => insert_lines("blah"); }

      #########################################################
      bundle agent mounts {

      storage:

      "/path/to/nfsmount" mount => nfs3("myserver", "/vol/export");
      }

      #########################################################
      body mount nfs3(server, source) {
      mount_type => "nfs";
      mount_server => "$(server)";
      mount_source => "$(source)";
      mount_options =>

      {"rw,nfsvers=3,soft,intr,tcp,nodev,noatime,nosuid,rsize=65536,wsize=65536"}

      ;
      edit_fstab => "true";
      }

      #########################################################
      body perms system {
      mode => "0644";
      }

      </pre>

      Expected result:
      /etc/delme is created, ensures it contains "blah", backed up to /tmp/backups/ if changed.
      /etc/fstab is modified if necessary, backed up to /tmp/backups if changed; nfs exports mounted

      Actual result:
      <pre>
      admin@hostname:/var/cfengine/inputs$ sudo cf-agent -KI -f ./test-repo.cf
      -> Created file /etc/delme, mode = 420
      -> Edited file /etc/delme
      Moved /etc/delme.cf-before-edit to repository location /tmp/backups/_etc_delme_cf_before_edit
      Adding file system myserver:/vol/export seems to /path/to/nfsmount.
      -> Edited file /etc/fstab

      </pre>
      /etc/delme is created, edited, and backed up in the repository.
      At first glance, it appears that /etc/fstab is correct, but in fact fstab is missing:

      <pre>
      admin@hostname:/var/cfengine/inputs$ ls -la /etc/fstab*
      rw-rr- 1 root root 800 Feb 22 18:25 /etc/fstab.cf-after-edit
      rw-rr- 1 root root 668 Feb 22 18:25 /etc/fstab.cf-before-edit

      </pre>
      The contents of /etc/fstab.cf-after-edit and /etc/fstab.cf-before-edit are both correct, respectively.
      But the file is not backed up or moved to the repository.
      And of course the nfs export remains unmounted.

      <pre>
      admin@hostname:/var/cfengine/inputs$ ls -la /tmp/backups/_etc*
      rw------ 1 root root 0 Feb 22 18:25 _etc_delme_cf_before_edit

      </pre>

      More information from verbose and debug:
      <pre>
      sudo cf-agent -KI -f ./test-repo.cf -dv
      ...
      cf3> -> Number of changes observed in /etc/fstab is 1
      cf3> -> Edited file /etc/fstab
      Repository(/etc/fstab.cf-before-edit)
      Trying to create a parent directory for /tmp/backups/_etc_fstab_cf_before_edit
      Directory for /tmp/backups/_etc_fstab_cf_before_edit exists. Okay

      </pre>
      Afterwards, /tmp/backups/_etc_fstab_cf_before_edit does not actually exist.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              chrishiestand Chris Hiestand
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Summary Panel