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

host provider clobbers /etc/hosts with invalid syntax

    Details

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

      OS: CentOS 6.6 Linux
      Puppet version: 3.6.2

      Description

      When the Host provider fails to parse /etc/hosts, it replaces all existing contents of the file.

      Steps to reproduce:
      Tested on CentOS 6.6 with Puppet 3.6.2
      1. Have an /etc/hosts file with a single word line, i.e.:

      127.0.0.1	localhost.localdomain localhost localhost4.localdomain4 localhost4
      ::1	localhost6.localdomain6	localhost6
       
      test-host
      

      2. Apply a manifest that defines a Host resource.

      puppet apply -e "host {'test-host.example.com': ip => '192.168.1.1'}"
      

      Expected result: /etc/hosts contains the following content

      # HEADER: This file was autogenerated at 2015-04-07 11:43:19 -0500
      # HEADER: by puppet.  While it can still be managed manually, it
      # HEADER: is definitely not recommended.
      127.0.0.1	localhost.localdomain localhost localhost4.localdomain4 localhost4
      ::1	localhost6.localdomain6	localhost6
       
      test-host
      192.168.1.1 test-host.example.com 
      

      Actual result: All of the previous contents of /etc/host are overwritten

      # HEADER: This file was autogenerated at 2015-04-07 11:43:19 -0500
      # HEADER: by puppet.  While it can still be managed manually, it
      # HEADER: is definitely not recommended.
      192.168.1.1	test-host.example.com
      

      The following is an example of the output from the puppet apply:

      # puppet apply -e "host {'test-host.example.com': ip => '192.168.1.1'}"
      Notice: Compiled catalog for REDACTED in environment production in 0.10 seconds
      Error: Could not prefetch host provider 'parsed': Could not parse line "test-host" at /etc/hosts:5
      Notice: /Stage[main]/Main/Host[test-host.example.com]/ensure: created
      Notice: Finished catalog run in 0.72 seconds
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                rmc3 Richard Chatterton
              • Votes:
                2 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Zendesk Support