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

Collectors don't match when attribute set by namevar

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Won't Do
    • Affects Version/s: PUP 3.6.0, PUP 4.0.0
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Environment:

      GNU/Linux
      Oracle Linux Server release 7.1

    • Template:

      Description

      Collectors do not appear to match declared resources when the match parameter of the resource is set via namevar.

      Given the following manifest (test.pp):

      exec { '/bin/cat':
      }
       
      Exec <| command == '/bin/cat' |> {
      cwd => '/root',
      }
      

      Executing /opt/puppetlabs/bin/puppet master --compile --default_manifest /home/phb12/test.pp --node_terminus plain --verbose yields the following output:

      Info: Caching node for --default_manifest
      Notice: Compiled catalog for --default_manifest in environment production in 0.63 seconds
      {
        "tags": ["settings"],
        "name": "--default_manifest",
        "version": 1447064691,
        "environment": "production",
        "resources": [
          {
            "type": "Stage",
            "title": "main",
            "tags": ["stage"],
            "exported": false,
            "parameters": {
              "name": "main"
            }
          },
          {
            "type": "Class",
            "title": "Settings",
            "tags": ["class","settings"],
            "exported": false
          },
          {
            "type": "Class",
            "title": "main",
            "tags": ["class"],
            "exported": false,
            "parameters": {
              "name": "main"
            }
          },
          {
            "type": "Exec",
            "title": "/bin/cat",
            "tags": ["exec","class"],
            "file": "/home/phb12/test.pp",
            "line": 1,
            "exported": false
          }
        ],
        "edges": [
          {
            "source": "Stage[main]",
            "target": "Class[Settings]"
          },
          {
            "source": "Stage[main]",
            "target": "Class[main]"
          },
          {
            "source": "Class[main]",
            "target": "Exec[/bin/cat]"
          }
        ],
        "classes": [
          "settings"
        ]
      }
      

      We can see that the cwd attribute has not made it into the final catalogue.
      I originally noticed this when setting the purge attribute on a File resource, attempting to collect the File via its path attribute; this displayed the same behaviour.

      If I change the manifest such that the command attribute is set explicitly, like so:

      exec { 'test':
      command => '/bin/cat',
      }
       
      Exec <| command == '/bin/cat' |> {
      cwd => '/root',
      }
      

      The compiled JSON looks as follows:

      {
        "tags": ["settings"],
        "name": "--default_manifest",
        "version": 1447065451,
        "environment": "production",
        "resources": [
          {
            "type": "Stage",
            "title": "main",
            "tags": ["stage"],
            "exported": false,
            "parameters": {
              "name": "main"
            }
          },
          {
            "type": "Class",
            "title": "Settings",
            "tags": ["class","settings"],
            "exported": false
          },
          {
            "type": "Class",
            "title": "main",
            "tags": ["class"],
            "exported": false,
            "parameters": {
              "name": "main"
            }
          },
          {
            "type": "Exec",
            "title": "test",
            "tags": ["exec","test","class"],
            "file": "/home/phb12/test.pp",
            "line": 1,
            "exported": false,
            "parameters": {
              "command": "/bin/cat",
              "cwd": "/root"
            }
          }
        ],
        "edges": [
          {
            "source": "Stage[main]",
            "target": "Class[Settings]"
          },
          {
            "source": "Stage[main]",
            "target": "Class[main]"
          },
          {
            "source": "Class[main]",
            "target": "Exec[test]"
          }
        ],
        "classes": [
          "settings"
        ]
      }
      

      I would expect the catalogue selector to match irrespective of how the attribute was set.

      EDIT: helps if I copy-paste the correct excerpts...

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              pb Peter Bridgman
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support