Having to work around defining parent directories multiple times is kind of annoying. It'd be nice to be able to say something like:
file { "/usr/local/something": ensure => directory, createparent => true } This would be the equivalent of doing a mkdir -p. The parent directory (or directories) would be created, but only if they didn't already exist. Because you wouldn't actually be defining the parent directory, you wouldn't have to worry about multiple definition errors. -Josh On Mar 16, 2009, at 9:01 AM, Felix Schäfer wrote: > > Your definition seems fine and sound (on a quick look), just replace > the part that is always the same (here being file { "/data01/ > multi_mysql": ... }) with a virtual resource, and you're done > > Greets, > > Felix > > Am 16.03.2009 um 16:48 schrieb TomTom: > >> >> Hi Bruce, >> Thanks for the snappy reply. >> I need to create X number of mysql_X directories under /data01/ >> multi_mysql/. Sometimes I might need to only create one instance, >> sometimes I might need to create as many as 10. How can I craft a >> flexible class that will create and install X number? >> For example >> /data01/multi_mysql/mysql_A >> /data01/multi_mysql/mysql_B >> /data01/multi_mysql/mysql_C >> /data01/multi_mysql/mysql_D >> /data01/multi_mysql/mysql_E >> /data01/multi_mysql/mysql_F >> /data01/multi_mysql/mysql_G >> /data01/multi_mysql/mysql_H >> >> Your suggestion for creating a class to do the file system creation >> is >> a good one, but how would I make it flexible to create mysql_X number >> of directories? I didn't think you could with a puppet class. That's >> why I went down the path of trying to call a function (definition) >> multiple times. More information on how you would implement a >> flexible puppet class would be greatly appreciated. >> >> Thank you very much for your help. Ill buy you a beer at the first >> puppet conference. :) >> -Tom >> >> >> On Mar 16, 11:33 am, Bruce Richardson <itsbr...@workshy.org> wrote: >>> On Mon, Mar 16, 2009 at 08:16:31AM -0700, TomTom wrote: >>>> Second of all, when I try to run the second mysql_B installation, >>>> puppet borks and says: >>>> puppetd[23415]: Could not retrieve configuration: Duplicate >>>> definition: File[/data01/multi_mysql] is already defined in file / >>>> etc/ >>>> puppet/manifests/definitions/dba/mysql_instance.pp at line 76; >>>> cannot >>>> redefine at /etc/puppet/manifests/definitions/dba/ >>>> mysql_instance.pp:76 >>> >>>> I believe puppet is getting hung up on the "idempotency" (Not >>>> sure if >>>> I am using this word correctly) >>>> Puppet is seeing the file definition when the function is called to >>>> install the second instance, and is saying that the definition is >>> >>> By function I take it you mean "definition". >>> >>> Puppet only lets you define any resource once. If you have defined >>> File['/data_dir/multi_mysql'] once, you can't define it again, no >>> matter >>> how deeply buried it is within nested classes or definitions. Don't >>> panic one way to get around this is checking to see if the resource >>> has >>> already been defined and only creating it if not. So change your >>> mysql_install_definition to have some thing like this: >>> >>> if defined( File["/$data_dir/multi_mysql"] ) { >>> debug( "/$data_dir/multi_mysql already exists" ) >>> } else { >>> >>> file { "/$data_dir/multi_mysql": >>> mode => 775, owner => "mysql", group => >>> "sysadmin", >>> require => File [ "/$data_dir" ], >>> } >>> } >>> >>> Another way to do this would be to have a class that creates the >>> multi_mysql directory and have this definition include it. That >>> would >>> be more idiomatic puppetry, I think, because it sticks with the >>> convention of using classes for things of which there is only one. >>> >>> -- >>> Bruce >>> >>> What would Edward Woodward do? >>> > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---