On Jun 29, 2010, at 6:56 AM, Annie Rana wrote:
Hi all,
I am new to Puppet and Ruby. Currently I am using puppet iptables
work (http://github.com/camptocamp/puppet-iptables/) to prioritise
different types of network traffic on a linux machine (see the
details here, http://www.mail-archive.com/[email protected]/msg08810.html)
and I would also require to develop a custom TC type (http://tldp.org/HOWTO/Traffic-Control-HOWTO/index.html
) to create priority queues.
The Iptables, the custom type that was developed by camptocamp (http://github.com/camptocamp
), is quite different from the standard puppet custom types’
development approach. Now looking at their code (http://github.com/camptocamp/puppet-iptables/blob/master/lib/puppet/type/iptables.rb
), I can see that they have defined an iptables type with many
parameters same as the way puppet tutorials ask to do. In init/
sudo.pp, when we will define an iptable rule such as:
iptables { "iptables rule no. 1":
proto => "tcp",
dport => "80",
jump => "ACCEPT",
}
, an iptables module's instance will be created and initialise
method (constructor) will be invoked. What I don’t understand is the
aftermath once the constructor is invoked. I have deployed iptables
custom type module at my linux machine and it works fine so far.
What I don’t understand is that once the rules are pushed in @@rules
(module variable) in initialise method then what happens next
because there is not any explicit method call or code block within
initialise method or even after that. It is very important for me to
understand the flow because TC rules would also be incorporated with
same iptables rules.
I can't help too much on this particular code -- you're definitely
right that it doesn't follow what we consider to be recommended
practice. For instance, I can't really recommend the style of
development used in this module - it involves quite a lot of class
variables, and uses no provider. That isn't to say it's wrong per se
- whatever works, works - but it's always going to be a bit tougher to
understand and maintain this way.
However, the thing that's probably confusing you is the extent to
which the framework (mostly the transaction class) is making calls
against the resource type. It looks like everything's being driven by
the 'evaluate' and 'initialize' methods. 'initialize' is a bit
obvious, but 'evaluate' is called by the transaction.
Note to the developers of this module - in 2.6, the 'evaluate' method
goes away, so this code won't work any more.
I have looked at the standard approach of developing the custom
types here:
http://projects.puppetlabs.com/projects/puppet/wiki/Development_Practical_Types
http://projects.puppetlabs.com/projects/puppet/wiki/Development_Provider_Development
http://projects.puppetlabs.com/projects/puppet/wiki/Development_Complete_Resource_Example
http://docs.puppetlabs.com/guides/custom_types.html
But in reality it is not as simple as it is shown in above
tutorials. If you look at the custom type code for iptables at the
following website, you will see it is different from the standard
approach of developing puppet custom types:
http://github.com/camptocamp/puppet-iptables
I contacted the camptocamp team but they are asking me to post my
questions at this mailing list. Can anyone of you please help me to
clarify how it is really working? I know it might be very basic
question that I am asking and may be I don’t understand how custom
types really work in puppet, but if you can help me in understanding
the code flow/sequence, it would be great help for me.
The transaction calls 'evaluate' on the resource, which would normally
produce a bunch of change objects, which the transaction then applies,
thus actually doing work. In this case, it's being used as a hook to
get some setup done, it looks like.
--
I'm worried about Bart. Today, he's sucking people's blood,
tommorrow he might be smoking. -Marge Simpson
---------------------------------------------------------------------
Luke Kanies -|- http://puppetlabs.com -|- +1(615)594-8199
--
You received this message because you are subscribed to the Google Groups "Puppet
Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en.