Skip to content

change from 'notrun' to ['0'] failed: undefined method `close!' for nil:NilClass (corrective) #9385

@michaelday008

Description

@michaelday008

I'm creating this issue because if PDK validates it, and it still fails, that seems like a bug. IMO anything that validates with PDK should not produce an error message like below.

Discussed in puppetlabs/community#72

Originally posted by michaelday008 May 17, 2024
I hope this is the correct place to post this question. I have a puppet module and I can't figure out why it is failing.

Here is the relevant code that is failing. There is a bunch of other code that runs successfully before this, but I've excluded it for brevity. If I comment out the below lines, the rest of the module completes successfully:

exec { 'Sysmon':
    command => 'c:\installers\sysmon\Sysmon64.exe -accepteula -i c:\installers\sysmon\sysmonconfig-export.xml'
  }

The output I get is

C:\installers\sysmon>puppet agent -t
Info: Using environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Notice: Requesting catalog from puppet:8140
Notice: Catalog compiled by puppet-01-dc1.prod.mydomain.ca
Info: Caching catalog for win-ad01.prod.mydomain.ca
Info: Applying configuration version '1715966702'
Error: undefined method `close!' for nil:NilClass
Error: /Stage[main]/Windows_splunk/Exec[Sysmon]/returns: change from 'notrun' to ['0'] failed: undefined method `close!' for nil:NilClass (corrective)
Notice: Applied catalog in 2.97 seconds

I know the file is there, because if I change the file path to something that doesn't exist (to troubleshoot), I get a different error:

Error: Could not find command 'c:\installers\system\Sysmon64.exe'
Error: /Stage[main]/Windows_splunk/Exec[Sysmon]/returns: change from 'notrun' to ['0'] failed: Could not find command 'c:\installers\system\Sysmon64.exe'

PDK passes with no errors:

[root@puppet-01-dc1 windows_splunk]# pdk validate
pdk (INFO): Using Ruby 3.2.3
pdk (INFO): Using Puppet 8.6.0
pdk (INFO): Running all available validators...
pdk (INFO): Validator 'puppet-plan-syntax' skipped for '/etc/puppetlabs/code/environments/production/modules/windows_splunk'. No files matching '["plans/**/*.pp"]' found to validate.
pdk (INFO): Validator 'puppet-epp' skipped for '/etc/puppetlabs/code/environments/production/modules/windows_splunk'. No files matching '["**/*.epp"]' found to validate.
pdk (INFO): Validator 'task-name' skipped for '/etc/puppetlabs/code/environments/production/modules/windows_splunk'. No files matching '["tasks/**/*"]' found to validate.
pdk (INFO): Validator 'task-metadata-lint' skipped for '/etc/puppetlabs/code/environments/production/modules/windows_splunk'. No files matching '["tasks/*.json"]' found to validate.
┌ [✔] Running metadata validators ...
├── [✔] Checking metadata syntax (metadata.json tasks/*.json).
└── [✔] Checking module metadata style (metadata.json).
┌ [✔] Running puppet validators ...
├── [✔] Checking Puppet manifest syntax (**/*.pp).
└── [✔] Checking Puppet manifest style (**/*.pp).
┌ [✔] Running ruby validators ...
└── [✔] Checking Ruby code style (**/**.rb).
┌ [✔] Running tasks validators ...
├── [✔] Checking task names (tasks/**/*).
└── [✔] Checking task metadata style (tasks/*.json).
┌ [✔] Running yaml validators ...
└── [✔] Checking YAML syntax (**/*.yaml **/*.yml).
pdk (WARNING): puppet-lint: class not documented (manifests/init.pp:1:1)
pdk (WARNING): puppet-lint: missing trailing comma after last element (manifests/init.pp:21:141)

If I run the command manually from the command line, it succeeds:

C:\installers\sysmon>c:\installers\sysmon\Sysmon64.exe -accepteula -i c:\installers\sysmon\sysmonconfig-export.xml

System Monitor v15.14 - System activity monitor
By Mark Russinovich and Thomas Garnier
Copyright (C) 2014-2024 Microsoft Corporation
Using libxml2. libxml2 is Copyright (C) 1998-2012 Daniel Veillard. All Rights Reserved.
Sysinternals - www.sysinternals.com

Loading configuration file with schema version 4.50
Sysmon schema version: 4.90
Configuration file validated.
The service Sysmon64 is already registered. Uninstall Sysmon before reinstalling.

Puppet Version:

C:\installers\sysmon>puppet --version
8.4.0

In short, I'm completely stumped because pdk validates the syntax as good syntax, but the puppet run still fails and the error message is entirely unhelpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions