Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-1904

Host resource type corrupts /etc/hosts

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Duplicate
    • Affects Version/s: PUP 3.4.3
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Environment:

      Linux Mint 15 / Ubuntu Raring

    • Template:
    • UX Priority:
      Critical

      Description

      Hello,

      It seems when /etc/hosts has a syntax error, Puppet only reports the error, and start over with an empty file, only adding the new resource. It essentially erases all original entries to the file. When file syntax is OK, everything seems to work fine.

      I had problems with this situation in production systems, where, due to a human error, there was a syntax error at /etc/hosts, which made Puppet loose the whole file. I was able to recover the original file from backup, but in the meantime, my system was down.

      Here is an example to reproduce the error:

      fornellas@mint:~/tmp$ cat hosts
      # valid comment
       syntax error line
      1.2.3.4	host1
      5.6.7.8	host2
      1.2.3.4	new_host1
      fornellas@mint:~/tmp$ puppet resource --debug host new_host2 ensure=present target="hosts" ip=5.6.7.8
      Debug: Failed to load library 'selinux' for feature 'selinux'
      Debug: Loaded state in 0.00 seconds
      Debug: Prefetching parsed resources for host
      Error: Could not prefetch host provider 'parsed': Could not parse line " syntax error line" at hosts:3
      Notice: /Host[new_host2]/ensure: created
      Debug: Flushing host provider target hosts
      Debug: Finishing transaction 17978080
      Debug: Storing state
      Debug: Stored state in 0.05 seconds
      host { 'new_host2':
        ensure => 'present',
        ip     => '5.6.7.8',
        target => 'hosts',
      }
      fornellas@mint:~/tmp$ cat hosts
      # HEADER: This file was autogenerated at 2014-03-10 04:53:37 -0300
      # HEADER: by puppet.  While it can still be managed manually, it
      # HEADER: is definitely not recommended.
      5.6.7.8	new_host2
      fornellas@mint:~/tmp$ 
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bw57899 Bill W
              Reporter:
              fornellas Fabio Pugliese Ornellas
              Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support