bartavelle / language-puppet

A library to work with Puppet manifests, test them and eventually replace everything ruby.
BSD 3-Clause "New" or "Revised" License
51 stars 8 forks source link

`Defined` for resource instance using Anchor #124

Closed PierreR closed 9 years ago

PierreR commented 9 years ago

Given this code and the following declaration:

Anchor['nginx::begin']
 ->
class { 'nginx::config' :
    confd_purge  => true,
    vhost_purge  => true,
}

class { 'nginx' :
    manage_repo   => false,
}

defined(Class['::nginx::config']) return false while it should be true.

See this issue

I guess this might be horrible to fix ...

bartavelle commented 9 years ago

What does it do when you replace with defined(Class['nginx::config']) (without the :: header) ?

bartavelle commented 9 years ago

It tried it and got:

ERROR: (a.b) Override of parameters of the following resource is forbidden in the current context:
class {
  nginx::params: # "/tmp/x/manifests/site.pp" (line 4, column 11) a.b [Scope []]
    ;
} # "/tmp/x/modules/nginx/manifests/config.pp" (line 202, column 5) at # "/tmp/x/modules/nginx/manifests/config.pp" (line 287, column 10)
bartavelle commented 9 years ago

Isn't it better now ? Class reference names are now normalized.

PierreR commented 9 years ago

I am going to try later today.

I was planning to describe in more detail the problem I have with global scoping but I haven't found the time yet. Yesterday for instance I was writing something such as require => Class['profile::mycompany'] where profile is an external module. In that case require => Class['profile::mycompany'] was working but require => Class['::profile::mycompany'] was not. I would have expected the completely opposite behavior.

I have to read the puppet doc again about global scoping but to me all the current practices in puppetlabs modules seems wrong. Isn't :: only useful when you want to start from the root of the module path ? So for instance to call an external postgresql class inside an apache one.

bartavelle commented 9 years ago

Hopefully both cases should work now !

PierreR commented 9 years ago

Work nicely so far. I am closing the issue. Thanks