vagrant - How to reuse class in Puppet -
i have puppet class
class project::classname( $program_name = '', $command = '' ) { .... }
and i'm using this
class { 'project::classname': program_name => 'programe_name', command => 'ls /dev/' }
this works fine, when used twice this
class { 'project::classname': program_name => 'programe_name', command => 'ls /dev/' } class { 'project::classname': program_name => 'programe_name2', command => 'ls /dev/' }
vagrant provision giving me error
error: duplicate declaration: class[project::classname] declared in file ..
so question how can reuse class?
thank you!
you need understand difference of class , defined types.
classes vs defined types classes not thought of in ‘object oriented’ meaning of class. means machine belongs particular class of machine. instance, generic webserver class. include class part of node needed built generic webserver. class drop in whatever packages, etc, needed do. defined types on other hand (created ‘define’) can have many instances on machine, , can encapsulate classes , other resources. can created using user supplied variables. instance, manage iptables, defined type may wrap each rule in iptables file, , iptables configuration built out of fragments generated defined types. usage of classes , defined types, in addition built-in managed types, helpful towards having managable puppet infrastructure.
refer: https://docs.puppetlabs.com/guides/best_practices.html
Comments
Post a Comment