1

I am using Puppet Enterprise.

# puppet master --version
4.8.1

Manifests dir (/etc/puppetlabs/code/environments/production/manifests) contains the following:

iis.pp
rds.pp
site.pp

I have a node definition in site.pp as shown below:

# cat site.pp
node 'box A' {
    include iis
}

Now the issue i am facing is that if i create a new node (say, box B) and add it to site.pp by creating a blank definition as shown below, it still installs softwares that are actually part of another node ('box A' in this case) definition.

node 'box B' { }

I don't have any include statement in site.pp defined outside the above two node definitions.

Why is this happening?

UPDATE:

# cat iis.pp
$iis_features = ['Web-Server','Web-WebServer','Web-Asp-Net45','Web-ISAPI-Ext','Web-ISAPI-Filter','NET-Framework-45-ASPNET']

windowsfeature { $iis_features:
  ensure => present,
}
ferventcoder
  • 11,952
  • 3
  • 57
  • 90
Technext
  • 7,887
  • 9
  • 48
  • 76
  • What exactly is in `iis.pp`? – Dominic Cleal Jan 23 '17 at 12:21
  • 1
    Puppet could very well be using everything in `/etc/puppetlabs/code/environments/production/manifests`, or the first manifest there, as a default manifest. Either way, it is very unusual to have anything other than a `site.pp` in there. Move out the other manifests and see if that fixes the problem. – Matthew Schuchard Jan 23 '17 at 12:21
  • @DominicCleal: Updated the post with content of iis.pp – Technext Jan 23 '17 at 14:09
  • @MattSchuchard: Seems you're right. I agree that it's unusual to have anything besides `site.pp`. Just getting my feet wet. :) Moving out those manifests did fix the problem. Thanks. – Technext Jan 23 '17 at 17:59

1 Answers1

2

Since Puppet 4, all files in the top-level environment manifests/ directory will be automatically loaded. Usually this is so you can define different node definitions or classes and have them all loaded without using the import directive (used in Puppet 2 and 3).

In your case, iis.pp, rds.pp and site.pp are parsed and used on every node. (Directories: The main manifest(s) has some more info on how this is configured.)

To fix it, use Puppet classes to group your IIS configuration (the windowsfeature resources) into an iis class - then your include iis will only use this configuration on "box A".

Change iis.pp to define a class:

class iis {
  $iis_features = ['Web-Server','Web-WebServer','Web-Asp-Net45','Web-ISAPI-Ext','Web-ISAPI-Filter','NET-Framework-45-ASPNET']

  windowsfeature { $iis_features:
    ensure => present,
  }
}

Ideally, move iis.pp to /etc/puppetlabs/code/environments/production/modules/iis/manifests/init.pp to be in the standard module location. This provides better performance as Puppet doesn't need to read iis.pp until you use include iis.

Dominic Cleal
  • 3,205
  • 19
  • 22
  • Coincidentally, i was also going through a similar link (after reading Matt's comment) that you've mentioned above although mine was for an [older](https://docs.puppet.com/puppet/3.8/dirs_manifest.html) release. :) Thanks for the last point related to performance. In case of multiple files, the effect may be significant. Keeping the performance aside, when you mentioned "Usually this is so you can define different node definitions or classes...", is this recommended? – Technext Jan 23 '17 at 18:11
  • 1
    @Technext not entirely. Classes should be in modules instead of the manifest dir, it's easier to organise and to put related items (templates, files, functions, Facter plugins etc) alongside them in the same module. Node definitions should be there if you use them, but I'd suggest using Hiera (e.g. hiera_include) so there's only a default node definition. – Dominic Cleal Jan 24 '17 at 08:07