Re: [Puppet Users] duplicate resource with inherit and puppet apply

2016-10-05 Thread Toni Schmidbauer
>Henrik Lindberg  writes:
>> On 03/10/16 15:48, jcbollinger wrote:
>> The behavior you describe seems buggy to me, but your manifests are also
>> unusual.  Specifically, it is strange for test/manifests/init.pp to
>> contain a top-scope declaration.  It is especially strange for that
>> declaration to be "include test" because this is the very same file that
>> would be evaluated, if needed, as a result of evaluating that
>> declaration.

yes, i agree fully. this is not the usual way to write modules. i was
just showing a collegue who's getting started with puppet an example
module and while playing around we found this rather strange behaviour.

> Top scope logic in autoloaded code have very strange effects and
> should not be used. At some point in the future it will probably be
> forbidden to have any code outside of the structure that is supposed
> to be in an autoloaded file.

ok, thanks for the clarification.

>> As I said, however, I think it should work, and even if there were a
>> reason for it not to work, the error message that is emitted is bizarre
>> for the code presented.  I think that's probably indicative that the
>> code is doing something unexpected by its authors.  I encourage you to
>> file a ticket for buggy behavior here, but if you do so, do not neglect
>> to mention the diagnostic because at the very least, there are grounds
>> here for an RFE around improving the diagnostic.

ok, once again thanks for your time. i'll file a ticket.

thank you both
toni

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/8737kalgzn.fsf%40stderr.at.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] duplicate resource with inherit and puppet apply

2016-10-03 Thread Henrik Lindberg

On 03/10/16 15:48, jcbollinger wrote:



On Friday, September 30, 2016 at 2:03:06 PM UTC-5, Toni Schmidbauer wrote:

Henrik Lindberg  writes:

> On 28/09/16 14:30, Toni Schmidbauer wrote:
> I tried this on latest puppet:
>
> === test.pp
> class test::subclass {}
> class test inherits test::subclass {
>   notify { 'hello?': }
> }
> include test

did some more tests with puppet 4.7. so the above works but if i move
tests::subclass into a separate file (subclass.pp) in the manifests
folder puppet apply fails with duplicate resource.

my source code layout:

├── manifests
│   ├── init.pp
│   └── subclass.pp
└── tests
└── init.pp

manifests/init.pp:

## code
class test inherits test::subclass {
  notify { 'hello world': }
}

include test
# end code

manifests/subclass.pp:

## code
class test::subclass {}
# end code

tests/init.pp:

## code
include test
# end code

i run the code with the following command

puppet apply --modulepath=/vagrant/modules manifests/init.pp

if i use

puppet apply --modulepath=/vagrant/modules tests/init.pp
   ^
   |- HEADS UP

puppet apply works.



The behavior you describe seems buggy to me, but your manifests are also
unusual.  Specifically, it is strange for test/manifests/init.pp to
contain a top-scope declaration.  It is especially strange for that
declaration to be "include test" because this is the very same file that
would be evaluated, if needed, as a result of evaluating that declaration.



Top scope logic in autoloaded code have very strange effects and should 
not be used. At some point in the future it will probably be forbidden 
to have any code outside of the structure that is supposed to be in an 
autoloaded file.



I suppose the reason for that is to make the manifest usable both
directly with 'puppet apply' and as an ordinary module manifest, and I
think that /should/ work.  Nevertheless, it looks to me like an awkward
mix of Puppet module and site manifests, and even if it worked, I would
not recommend structuring your manifests like that.  I observe that your
workaround involves partially splitting the site manifest part from the
module manifest part, but personally, I'd go farther and take the site
manifest part completely out of the module.



Agree with John here.

- henrik


As I said, however, I think it should work, and even if there were a
reason for it not to work, the error message that is emitted is bizarre
for the code presented.  I think that's probably indicative that the
code is doing something unexpected by its authors.  I encourage you to
file a ticket for buggy behavior here, but if you do so, do not neglect
to mention the diagnostic because at the very least, there are grounds
here for an RFE around improving the diagnostic.


John

--
You received this message because you are subscribed to the Google
Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to puppet-users+unsubscr...@googlegroups.com
.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/fec40211-95a6-4e3f-94ae-e7ea37069bdc%40googlegroups.com
.
For more options, visit https://groups.google.com/d/optout.



--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/c615aa89-5669-9f63-4aa6-ccb8fe53a4ec%40puppet.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] duplicate resource with inherit and puppet apply

2016-10-03 Thread jcbollinger


On Friday, September 30, 2016 at 2:03:06 PM UTC-5, Toni Schmidbauer wrote:
>
> Henrik Lindberg  writes: 
>
> > On 28/09/16 14:30, Toni Schmidbauer wrote: 
> > I tried this on latest puppet: 
> > 
> > === test.pp 
> > class test::subclass {} 
> > class test inherits test::subclass { 
> >   notify { 'hello?': } 
> > } 
> > include test 
>
> did some more tests with puppet 4.7. so the above works but if i move 
> tests::subclass into a separate file (subclass.pp) in the manifests 
> folder puppet apply fails with duplicate resource. 
>
> my source code layout: 
>
> ├── manifests 
> │   ├── init.pp 
> │   └── subclass.pp 
> └── tests 
> └── init.pp 
>
> manifests/init.pp: 
>
> ## code 
> class test inherits test::subclass { 
>   notify { 'hello world': } 
> } 
>
> include test 
> # end code 
>
> manifests/subclass.pp: 
>
> ## code 
> class test::subclass {} 
> # end code 
>
> tests/init.pp: 
>
> ## code 
> include test 
> # end code 
>
> i run the code with the following command 
>
> puppet apply --modulepath=/vagrant/modules manifests/init.pp 
>
> if i use 
>
> puppet apply --modulepath=/vagrant/modules tests/init.pp 
>^ 
>|- HEADS UP 
>
> puppet apply works. 
>
>

The behavior you describe seems buggy to me, but your manifests are also 
unusual.  Specifically, it is strange for test/manifests/init.pp to contain 
a top-scope declaration.  It is especially strange for that declaration to 
be "include test" because this is the very same file that would be 
evaluated, if needed, as a result of evaluating that declaration.

I suppose the reason for that is to make the manifest usable both directly 
with 'puppet apply' and as an ordinary module manifest, and I think that 
*should* work.  Nevertheless, it looks to me like an awkward mix of Puppet 
module and site manifests, and even if it worked, I would not recommend 
structuring your manifests like that.  I observe that your workaround 
involves partially splitting the site manifest part from the module 
manifest part, but personally, I'd go farther and take the site manifest 
part completely out of the module.

As I said, however, I think it should work, and even if there were a reason 
for it not to work, the error message that is emitted is bizarre for the 
code presented.  I think that's probably indicative that the code is doing 
something unexpected by its authors.  I encourage you to file a ticket for 
buggy behavior here, but if you do so, do not neglect to mention the 
diagnostic because at the very least, there are grounds here for an RFE 
around improving the diagnostic.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/fec40211-95a6-4e3f-94ae-e7ea37069bdc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] duplicate resource with inherit and puppet apply

2016-09-30 Thread Toni Schmidbauer
Henrik Lindberg  writes:

> On 28/09/16 14:30, Toni Schmidbauer wrote:
> I tried this on latest puppet:
>
> === test.pp
> class test::subclass {}
> class test inherits test::subclass {
>   notify { 'hello?': }
> }
> include test

did some more tests with puppet 4.7. so the above works but if i move
tests::subclass into a separate file (subclass.pp) in the manifests
folder puppet apply fails with duplicate resource.

my source code layout:

├── manifests
│   ├── init.pp
│   └── subclass.pp
└── tests
└── init.pp

manifests/init.pp:

## code
class test inherits test::subclass {
  notify { 'hello world': }
}

include test
# end code

manifests/subclass.pp:

## code
class test::subclass {}
# end code

tests/init.pp:

## code
include test
# end code

i run the code with the following command

puppet apply --modulepath=/vagrant/modules manifests/init.pp

if i use

puppet apply --modulepath=/vagrant/modules tests/init.pp
   ^
   |- HEADS UP

puppet apply works.

thanks for your help

toni

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/874m4xus6a.fsf%40stderr.at.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] duplicate resource with inherit and puppet apply

2016-09-28 Thread Henrik Lindberg

On 28/09/16 14:30, Toni Schmidbauer wrote:

hi,

it's a stupid example but nevertheless it would be interesting to now
why the following throws a duplicate resource error under puppet 3.7.4
and puppet 4.2.1

test/manifests/init.pp:

# start puppet code
class test inherits test::subclass {
  notify { 'hello?': }
}
include test
#end puppet code

test/manifests/subclass.pp:

# start puppet code
class test::subclass {}
# end puppet code

running

# puppet apply --modulepath=.../modules .../modules/test/init.pp

throws a duplicate resource error (4.2.1 error message):

Error: Evaluation Error: Error while evaluating a Resource Statement,
Duplicate declaration: Notify[hello?] is already declared in file
/vagrant/modules/test/manifests/init.pp:2; cannot redeclare at
/vagrant/modules/test/manifests/init.pp:2 at /vagrant/modules/test/manif
ests/init.pp:2:3 on node centos7.eb.lan.at

if i remove 'inherits test::subclass' from init.pp it works:

Notice: Compiled catalog for centos7.eb.lan.at in environment production
in 0.32 seconds
Notice: hello?
Notice: /Stage[main]/Test/Notify[hello?]/message: defined 'message' as
'hello?'
Notice: Applied catalog in 0.02 seconds

also removing 'include test' in init.pp and running


Yes, then it does nothing - so that would work :-)


puppet apply --modulepath=/vagrant/modules 
/vagrant/modules/test/manifests/init.pp -e 'include test'

works

Notice: Compiled catalog for centos7.eb.lan.at in environment production
in 0.29 seconds
Notice: hello?
Notice: /Stage[main]/Test/Notify[hello?]/message: defined 'message' as
'hello?'
Notice: Applied catalog in 0.02 seconds

any hints?



I tried this on latest puppet:

=== test.pp
class test::subclass {}
class test inherits test::subclass {
  notify { 'hello?': }
}
include test

puppet apply test.pp

And that works - does that fail for you ?

- henrik


thanks for your time and help

toni




--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/34a93418-1455-0c01-5e43-1ddcbc7b591c%40puppet.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] duplicate resource with inherit and puppet apply

2016-09-28 Thread Toni Schmidbauer
hi,

it's a stupid example but nevertheless it would be interesting to now
why the following throws a duplicate resource error under puppet 3.7.4
and puppet 4.2.1

test/manifests/init.pp:

# start puppet code
class test inherits test::subclass {
  notify { 'hello?': }
}
include test
#end puppet code

test/manifests/subclass.pp:

# start puppet code
class test::subclass {}
# end puppet code

running

# puppet apply --modulepath=.../modules .../modules/test/init.pp

throws a duplicate resource error (4.2.1 error message):

Error: Evaluation Error: Error while evaluating a Resource Statement,
Duplicate declaration: Notify[hello?] is already declared in file
/vagrant/modules/test/manifests/init.pp:2; cannot redeclare at
/vagrant/modules/test/manifests/init.pp:2 at /vagrant/modules/test/manif
ests/init.pp:2:3 on node centos7.eb.lan.at

if i remove 'inherits test::subclass' from init.pp it works:

Notice: Compiled catalog for centos7.eb.lan.at in environment production
in 0.32 seconds
Notice: hello?
Notice: /Stage[main]/Test/Notify[hello?]/message: defined 'message' as
'hello?'
Notice: Applied catalog in 0.02 seconds

also removing 'include test' in init.pp and running

puppet apply --modulepath=/vagrant/modules 
/vagrant/modules/test/manifests/init.pp -e 'include test'

works

Notice: Compiled catalog for centos7.eb.lan.at in environment production
in 0.29 seconds
Notice: hello?
Notice: /Stage[main]/Test/Notify[hello?]/message: defined 'message' as
'hello?'
Notice: Applied catalog in 0.02 seconds

any hints?

thanks for your time and help

toni

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/86twd0dx53.fsf%40stderr.at.
For more options, visit https://groups.google.com/d/optout.