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

edit_template creates zero length files

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: 3.6.0, 3.7.3, 3.7.2
    • Fix Version/s: 3.10.0
    • Component/s: Promise type: files
    • Labels:
      None
    • Platform:
      Linux
    • Found in version (details):
      CFEngine Core 3.6.0.f1e9f7c

      Description

      CFEngine Core 3.6.0.f1e9f7c edit_template promises create zero length files when cf-execd or cf-agent is run from the command line.

        [root@emo ~]# cf-agent -V
        CFEngine Core 3.6.0.f1e9f7c
        

      The subject files are managed by an edit_template:

        [root@emo outputs]# ls -l  /etc/ntp.conf /etc/resolv.conf /etc/sysctl.conf /etc/ssh/sshd_config /etc/syslog.conf
        -rw-r----- 1 root root 2576 Jun 13 06:50 /etc/ntp.conf
        -rw-r--r-- 1 root root  121 Jun 13 06:50 /etc/resolv.conf
        -rw------- 1 root root 3388 Jun 13 06:50 /etc/ssh/sshd_config
        -rw------- 1 root root 1712 Jun 13 06:50 /etc/sysctl.conf
        -rw-r----- 1 root sys   850 Jun 13 06:50 /etc/syslog.conf
        [root@emo outputs]# cf-execd -O
        [root@emo outputs]# ls -l  /etc/ntp.conf /etc/resolv.conf /etc/sysctl.conf /etc/ssh/sshd_config /etc/syslog.conf
        -rw-r----- 1 root root 0 Jun 13 10:13 /etc/ntp.conf
        -rw-r--r-- 1 root root 0 Jun 13 10:13 /etc/resolv.conf
        -rw------- 1 root root 0 Jun 13 10:13 /etc/ssh/sshd_config
        -rw------- 1 root root 0 Jun 13 10:13 /etc/sysctl.conf
        -rw-r----- 1 root sys  0 Jun 13 10:13 /etc/syslog.conf
        
        [root@emo outputs]# cat cf_emo_dcpds_cpms_osd_mil__1402672391_Fri_Jun_13_10_13_11_2014_0x2b9f7a340e70
        /var/cfengine/inputs/controls/cf_agent.cf:23:40: warning: Removed constraint 'syslog' in promise type 'agent' [-Wremoved]
              syslog                  => "false";
                                               ^
        R: [INFO]  Starting CFEngine 3.6.0.f1e9f7c on host emo.dcpds.cpms.osd.mil (redhat_5 x86_64)
        R: [INFO]  Running services, going to run bundle: baseline (in version 'stable')
        R: [INFO]  Running services, going to run bundle: audit (in version 'testing')
        R: [INFO]  Starting bundle runs...
        R: [INFO]  Starting bundle execution: baseline (with path /baseline/stable)
        2014-06-13T10:13:15-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/files/'/etc/ntp.conf'[0]: Edit file '/etc/ntp.conf'
        2014-06-13T10:13:15-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/files/'/etc/resolv.conf'[0]: Edit file '/etc/resolv.conf'
        2014-06-13T10:13:15-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/methods/'ok'/default/system_files_linux/files/'/etc/sysctl.conf'[0]: Edit file '/etc/sysctl.conf'
        2014-06-13T10:13:16-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/methods/'ok'/default/system_files_linux/files/'/etc/ssh/sshd_config'[0]: Edit file '/etc/ssh/sshd_config'
        2014-06-13T10:13:16-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/methods/'ok'/default/system_files_linux/files/'/etc/syslog.conf'[0]: Edit file '/etc/syslog.conf'
        2014-06-13T10:13:16-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/sbin/service ntpd restart'[0]: Executing 'no timeout' ... '/sbin/service ntpd restart'
        2014-06-13T10:13:16-0500   notice: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/sbin/service ntpd restart'[0]: Q: "...in/service ntpd": Shutting [  OK  ]d: 
        Q: "...in/service ntpd": Starting ntpd:                    [  OK  ]
        2014-06-13T10:13:16-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/sbin/service ntpd restart'[0]: Last 2 quoted lines were generated by promiser '/sbin/service ntpd restart'
        2014-06-13T10:13:16-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/sbin/service ntpd restart'[0]: Completed execution of '/sbin/service ntpd restart'
        2014-06-13T10:13:16-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/usr/bin/kill -HUP `/bin/cat /var/run/syslogd.pid`'[0]: Executing 'no timeout' ... '/usr/bin/kill -HUP `/bin/cat /var/run/syslogd.pid`'
        2014-06-13T10:13:16-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/usr/bin/kill -HUP `/bin/cat /var/run/syslogd.pid`'[0]: Completed execution of '/usr/bin/kill -HUP `/bin/cat /var/run/syslogd.pid`'
        2014-06-13T10:13:16-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/sbin/service sshd restart'[0]: Executing 'no timeout' ... '/sbin/service sshd restart'
        2014-06-13T10:13:16-0500   notice: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/sbin/service sshd restart'[0]: Q: "...in/service sshd": Stopping [  OK  ]
        Q: "...in/service sshd": Starting sshd:                    [  OK  ]
        2014-06-13T10:13:16-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/sbin/service sshd restart'[0]: Last 2 quoted lines were generated by promiser '/sbin/service sshd restart'
        2014-06-13T10:13:16-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/sbin/service sshd restart'[0]: Completed execution of '/sbin/service sshd restart'
        2014-06-13T10:13:16-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/sbin/sysctl -p'[0]: Executing 'no timeout' ... '/sbin/sysctl -p'
        2014-06-13T10:13:16-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/sbin/sysctl -p'[0]: Completed execution of '/sbin/sysctl -p'
        R: [INFO]  Finished bundle execution: baseline (with path /baseline/stable)
        R: [INFO]  Starting bundle execution: audit (with path /audit/testing)
        R: [INFO]  Finished bundle execution: audit (with path /audit/testing)
        R: [INFO]  Finished CFEngine 3.6.0.f1e9f7c on host emo.dcpds.cpms.osd.mil (redhat_5 x86_64)
        

      During the next scheduled cf-execd run the files are repaired:

        [root@emo outputs]# ls -l  /etc/ntp.conf /etc/resolv.conf /etc/sysctl.conf /etc/ssh/sshd_config /etc/syslog.conf
        -rw-r----- 1 root root 2576 Jun 13 10:15 /etc/ntp.conf
        -rw-r--r-- 1 root root  121 Jun 13 10:15 /etc/resolv.conf
        -rw------- 1 root root 3388 Jun 13 10:15 /etc/ssh/sshd_config
        -rw------- 1 root root 1712 Jun 13 10:15 /etc/sysctl.conf
        -rw-r----- 1 root sys   850 Jun 13 10:15 /etc/syslog.conf
        
        [root@emo outputs]# cat cf_emo_dcpds_cpms_osd_mil__1402672542_Fri_Jun_13_10_15_42_2014_0x2af926d4a940
        R: [INFO]  Starting CFEngine 3.6.0.f1e9f7c on host emo.dcpds.cpms.osd.mil (redhat_5 x86_64)
        R: [INFO]  Running services, going to run bundle: baseline (in version 'stable')
        R: [INFO]  Running services, going to run bundle: audit (in version 'testing')
        R: [INFO]  Starting bundle runs...
        R: [INFO]  Starting bundle execution: baseline (with path /baseline/stable)
        2014-06-13T10:15:45-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/files/'/etc/ntp.conf'[0]: Edit file '/etc/ntp.conf'
        2014-06-13T10:15:45-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/files/'/etc/resolv.conf'[0]: Edit file '/etc/resolv.conf'
        2014-06-13T10:15:46-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/methods/'ok'/default/system_files_linux/files/'/etc/sysctl.conf'[0]: Edit file '/etc/sysctl.conf'
        2014-06-13T10:15:47-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/methods/'ok'/default/system_files_linux/files/'/etc/ssh/sshd_config'[0]: Edit file '/etc/ssh/sshd_config'
        2014-06-13T10:15:47-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/methods/'ok'/default/system_files_linux/files/'/etc/syslog.conf'[0]: Edit file '/etc/syslog.conf'
        2014-06-13T10:15:47-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/sbin/service ntpd restart'[0]: Executing 'no timeout' ... '/sbin/service ntpd restart'
        2014-06-13T10:15:47-0500   notice: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/sbin/service ntpd restart'[0]: Q: "...in/service ntpd": Shutting down ntpd: [  OK  ]
        Q: "...in/service ntpd": Starting ntpd: [  OK  ]
        2014-06-13T10:15:47-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/sbin/service ntpd restart'[0]: Last 2 quoted lines were generated by promiser '/sbin/service ntpd restart'
        2014-06-13T10:15:47-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/sbin/service ntpd restart'[0]: Completed execution of '/sbin/service ntpd restart'
        2014-06-13T10:15:47-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/usr/bin/kill -HUP `/bin/cat /var/run/syslogd.pid`'[0]: Executing 'no timeout' ... '/usr/bin/kill -HUP `/bin/cat /var/run/syslogd.pid`'
        2014-06-13T10:15:47-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/usr/bin/kill -HUP `/bin/cat /var/run/syslogd.pid`'[0]: Completed execution of '/usr/bin/kill -HUP `/bin/cat /var/run/syslogd.pid`'
        2014-06-13T10:15:47-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/sbin/service sshd restart'[0]: Executing 'no timeout' ... '/sbin/service sshd restart'
        2014-06-13T10:15:47-0500   notice: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/sbin/service sshd restart'[0]: Q: "...in/service sshd": Stopping sshd: [  OK  ]
        Q: "...in/service sshd": Starting sshd: [  OK  ]
        2014-06-13T10:15:47-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/sbin/service sshd restart'[0]: Last 2 quoted lines were generated by promiser '/sbin/service sshd restart'
        2014-06-13T10:15:47-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/sbin/service sshd restart'[0]: Completed execution of '/sbin/service sshd restart'
        2014-06-13T10:15:47-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/sbin/sysctl -p'[0]: Executing 'no timeout' ... '/sbin/sysctl -p'
        2014-06-13T10:15:47-0500   notice: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/sbin/sysctl -p'[0]: Q: "...bin/sysctl -p": net.ipv4.ip_forward = 0
        Q: "...bin/sysctl -p": net.ipv4.conf.default.rp_filter = 1
        Q: "...bin/sysctl -p": net.ipv4.conf.default.accept_source_route = 0
        Q: "...bin/sysctl -p": kernel.sysrq = 0
        Q: "...bin/sysctl -p": kernel.core_uses_pid = 1
        Q: "...bin/sysctl -p": net.ipv4.tcp_max_syn_backlog = 1280
        Q: "...bin/sysctl -p": net.ipv4.tcp_syncookies = 1
        Q: "...bin/sysctl -p": vm.swappiness = 10
        Q: "...bin/sysctl -p": net.ipv4.conf.all.accept_redirects = 0
        Q: "...bin/sysctl -p": net.ipv4.conf.all.log_martians = 1
        Q: "...bin/sysctl -p": net.ipv4.conf.all.send_redirects = 0
        Q: "...bin/sysctl -p": net.ipv4.conf.default.accept_redirects = 0
        Q: "...bin/sysctl -p": net.ipv4.conf.default.log_martians = 1
        Q: "...bin/sysctl -p": net.ipv4.conf.default.send_redirects = 0
        Q: "...bin/sysctl -p": net.ipv4.icmp_echo_ignore_broadcasts = 1
        Q: "...bin/sysctl -p": net.ipv4.ip_local_port_range = 1024 65535
        Q: "...bin/sysctl -p": net.ipv4.tcp_fin_timeout = 15
        Q: "...bin/sysctl -p": net.ipv4.tcp_congestion_control = cubic
        Q: "...bin/sysctl -p": net.ipv4.tcp_max_syn_backlog = 1280
        Q: "...bin/sysctl -p": net.ipv4.tcp_timestamps = 0
        Q: "...bin/sysctl -p": net.ipv4.tcp_rmem = 4096 87380 16777216
        Q: "...bin/sysctl -p": net.ipv4.tcp_wmem = 4096 65536 16777216
        Q: "...bin/sysctl -p": net.ipv6.conf.default.accept_redirects = 0
        Q: "...bin/sysctl -p": net.ipv6.conf.all.accept_redirects = 0
        Q: "...bin/sysctl -p": net.core.netdev_max_backlog = 300000
        Q: "...bin/sysctl -p": net.core.rmem_default = 262144
        Q: "...bin/sysctl -p": net.core.wmem_default = 262144
        Q: "...bin/sysctl -p": net.core.rmem_max = 16777216
        Q: "...bin/sysctl -p": net.core.wmem_max = 16777216
        Q: "...bin/sysctl -p": kernel.shmall = 3279547
        Q: "...bin/sysctl -p": kernel.shmmax = 4294967295
        Q: "...bin/sysctl -p": kernel.shmmni = 4096
        Q: "...bin/sysctl -p": kernel.sem = 256 32000 100 142
        Q: "...bin/sysctl -p": fs.file-max = 327679
        Q: "...bin/sysctl -p": kernel.msgmni = 2878
        Q: "...bin/sysctl -p": kernel.msgmax = 8192
        Q: "...bin/sysctl -p": kernel.msgmnb = 65535
        Q: "...bin/sysctl -p": xen.independent_wallclock = 1
        2014-06-13T10:15:47-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/sbin/sysctl -p'[0]: Last 38 quoted lines were generated by promiser '/sbin/sysctl -p'
        2014-06-13T10:15:47-0500     info: /default/dispatcher/methods/'baseline'/default/caller/methods/'baseline'/default/baseline/methods/'any'/default/system_files/commands/'/sbin/sysctl -p'[0]: Completed execution of '/sbin/sysctl -p'
        R: [INFO]  Finished bundle execution: baseline (with path /baseline/stable)
        R: [INFO]  Starting bundle execution: audit (with path /audit/testing)
        R: [INFO]  Finished bundle execution: audit (with path /audit/testing)
        R: [INFO]  Finished CFEngine 3.6.0.f1e9f7c on host emo.dcpds.cpms.osd.mil (redhat_5 x86_64)
        

      The subject files are managed by promises exactly like:

              "/etc/ssh/sshd_config"
                edit_line       => expand_template("$(glb.templates)/sshd_config.template"),
                edit_defaults   => empty,
                classes         => if_repaired("restart_sshd"),
                perms           => mog("0600","root","root"),
                create          => "true";
        

      Thus far I have been unable to create a concise, reproducible example; they all run correctly. Still trying.

        Attachments

        1. cfagent.xz
          204 kB
          Bob Ingersoll

          Issue Links

            Activity

              People

              • Assignee:
                a10042 Nick Anderson
                Reporter:
                ringersoll Bob Ingersoll
              • Votes:
                3 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel