<Derek.Whayman@barclayscapital.com>
2007-Nov-29 14:58 UTC
Overriding resources in a define in a module - can''t get syntax right
Maybe it works, maybe it doesn''t, but I sure as hell can''t
make it work.
I get stuck with
"Could not find object(s)" whatever I do
This is my module init.pp
class ztest::setup {
notice "MAIN SETUP CLASS"
file { directfile:
path => "/etc/directfile",
owner => root, group => root, mode => 0644,
content => "A B C D\n"
}
testfile { testing:
content => "1 2 3 4\n"
}
define testfile($content) {
file { myfile:
# file { "ztest::myfile":
path => "/etc/testfile",
owner => root, group => root, mode => 0644,
content => $content
}
}
}
This is my test class:
include ztest::setup
include ztest::override
# notice: //ztest::setup/File[directfile]/content: created file with
contents {md5}3c96e5169486f07524a2e2fde1b74002
# notice:
//ztest::setup/ztest::setup::testfile[testing]/File[myfile]/content:
changed file contents from {md5}bcd4a67dec344d585a41e60151d8a19b to
{md5}fe59a05ba880dc4ad0d50e7401b1648d
class ztest::override inherits ztest::setup {
notice "OVERRIDE"
File[directfile] {
content => "W X Y Z"
}
File[myfile] {
# File["ztest::myfile"] {
# File["testfile::myfile"] {
# File["ztest::testfile::myfile"] {
# File["ztest::setup::testfile::myfile"] {
# File["setup::testfile::myfile"] {
# Testfile[testing] {
content => "5 6 7 8\n"
}
}
You can see some of the syntaxes I''ve tried in the comments. Whatever
I
do, I get
notice: ztest::setup: MAIN SETUP CLASS
notice: ztest::override: OVERRIDE
Could not find object(s) File[myfile]
(or similar)
I can easily override "directfile", but I can''t get it to
override
"myfile".
Anyone got any clues?
Derek
------------------------------------------------------------------------
For important statutory and regulatory disclosures and more information about
Barclays Capital, please visit our web site at http://www.barcap.com.
Internet communications are not secure and therefore the Barclays Group does not
accept legal responsibility for the contents of this message. Although the
Barclays Group operates anti-virus programmes, it does not accept responsibility
for any damage whatsoever that is caused by viruses being passed. Any views or
opinions presented are solely those of the author and do not necessarily
represent those of the Barclays Group. Replies to this email may be monitored
by the Barclays Group for operational or business reasons.
Barclays Capital is the investment banking division of Barclays Bank PLC, a
company registered in England (number 1026167) with its registered office at 1
Churchill Place, London, E14 5HP. This email may relate to or be sent from other
members of the Barclays Group.
------------------------------------------------------------------------
Luke Kanies
2007-Dec-04 19:57 UTC
Re: Overriding resources in a define in a module - can''t get syntax right
On Nov 29, 2007, at 8:58 AM, <Derek.Whayman@barclayscapital.com> <Derek.Whayman@barclayscapital.com> wrote:> You can see some of the syntaxes I''ve tried in the comments. > Whatever I > do, I get > > notice: ztest::setup: MAIN SETUP CLASS > notice: ztest::override: OVERRIDE > Could not find object(s) File[myfile] > (or similar) > > I can easily override "directfile", but I can''t get it to override > "myfile". > > Anyone got any clues?Two things: I think you may be suffering from a bug I''ve fixed but (as so many) not yet released. Can you try that in the current git code? The bug was related to ordering issues around when definitions were turned into resources. Also, note that the fully qualifed path to your ''testfile'' definition is ''ztest::setup::testfile'', so if you want to override an instance of it, you should use Ztest::Setup::Testfile, not just Testfile or Ztest::Testfile. You can use ''search'' to add that class to your search path. It''s possibly a bug that inheriting from a class doesn''t automatically search though that class''s namespace... -- Be wary of the man who urges an action in which he himself incurs no risk. -- Joaquin Setanti --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
<Derek.Whayman@barclayscapital.com>
2007-Dec-05 09:56 UTC
Re: Overriding resources in a define in a module -can''t get syntax right
Fist up, right about the namespace Ztest::Setup::Testfile - the errors
here relative to the object not being found, not the resource to that
part is demonstrably working with 0.23.2
Secondly, it seems you checked in the fix 1-2 weeks ago. This now works
:-)
Ztest::Setup::Testfile[testing] {
content => "5 6 7 8\n"
}
In fact, you can use Testfile[testing] rather than
Ztest::Setup::Testfile[testing] - presumably the inheritance sets up the
searchpath.
Many thanks,
Derek
-----Original Message-----
From: puppet-users-bounces@madstop.com
[mailto:puppet-users-bounces@madstop.com] On Behalf Of Luke Kanies
Sent: 04 December 2007 19:57
To: Puppet User Discussion
Subject: Re: [Puppet-users] Overriding resources in a define in a module
-can''t get syntax right
On Nov 29, 2007, at 8:58 AM, <Derek.Whayman@barclayscapital.com>
<Derek.Whayman@barclayscapital.com> wrote:
> You can see some of the syntaxes I''ve tried in the comments.
> Whatever I
> do, I get
>
> notice: ztest::setup: MAIN SETUP CLASS
> notice: ztest::override: OVERRIDE
> Could not find object(s) File[myfile]
> (or similar)
>
> I can easily override "directfile", but I can''t get it
to override
> "myfile".
>
> Anyone got any clues?
Two things:
I think you may be suffering from a bug I''ve fixed but (as so many)
not yet released. Can you try that in the current git code? The
bug was related to ordering issues around when definitions were turned
into resources.
Also, note that the fully qualifed path to your ''testfile''
definition is
''ztest::setup::testfile'', so if you want to override an
instance of it,
you should use Ztest::Setup::Testfile, not just Testfile or
Ztest::Testfile. You can use ''search'' to add that class to
your search
path.
It''s possibly a bug that inheriting from a class doesn''t
automatically
search though that class''s namespace...
--
Be wary of the man who urges an action in which he himself incurs no
risk. -- Joaquin Setanti
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com
_______________________________________________
Puppet-users mailing list
Puppet-users@madstop.com
https://mail.madstop.com/mailman/listinfo/puppet-users
------------------------------------------------------------------------
For important statutory and regulatory disclosures and more information about
Barclays Capital, please visit our web site at http://www.barcap.com.
Internet communications are not secure and therefore the Barclays Group does not
accept legal responsibility for the contents of this message. Although the
Barclays Group operates anti-virus programmes, it does not accept responsibility
for any damage whatsoever that is caused by viruses being passed. Any views or
opinions presented are solely those of the author and do not necessarily
represent those of the Barclays Group. Replies to this email may be monitored
by the Barclays Group for operational or business reasons.
Barclays Capital is the investment banking division of Barclays Bank PLC, a
company registered in England (number 1026167) with its registered office at 1
Churchill Place, London, E14 5HP. This email may relate to or be sent from other
members of the Barclays Group.
------------------------------------------------------------------------