TomTom
2009-Mar-16 15:16 UTC
[Puppet Users] Expert Idempotency Question: Multi-Mysql Installation File System Creation Question
Hello All, I am trying to puppetize a multi-mysql installation. Our mysql consultant suggested that we use the pre-compiled binary installations from mysql.com. So a multi-instance mysql installation would look like /data01/multi_mysql/mysql_A/ /data01/multi_mysql/mysql_B/ /data01/multi_mysql/mysql_C/ First of all, my puppet definition below tries to do the untar first, and doesn''t try to create the file system. I don''t think I have my require order correct. How can I fix that. 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 previously defined. Does anyone know how to get around this. My instance installation class is: define mysql_install_definition ( $data_dir, $mysql_instance, $mysql_distro ) { $wget = "wget -q" $build_area = "/usr/local/puppet" #data_dir should be there before this gets started #file { "/$data_dir": # mode => 775, owner => "mysql", group => "sysadmin", # } file { "/$data_dir/multi_mysql": mode => 775, owner => "mysql", group => "sysadmin", require => File [ "/$data_dir" ], } file { "/$data_dir/multi_mysql/$mysql_instance": mode => 775, owner => "mysql", group => "sysadmin", require => File [ "/$data_dir/multi_mysql" ], } file { "/$data_dir/log": mode => 775, owner => "mysql", group => "sysadmin", require => File [ "/$data_dir" ], } file { "/$data_dir/log/$mysql_instance": mode => 775, owner => "mysql", group => "sysadmin", require => File [ "/$data_dir/log" ], } exec { "wget -q ftp://$server_local/depot/precompiled/$mysql_distro": cwd => "$build_area/KITS", creates => "$build_area/KITS/${mysql_distro}", require => [File [ "$build_area/KITS" ], File [ "/ $data_dir/multi_mysql/$mysql_instance" ]], } tarextract { "$buld_area/KITS/$mysql_distro": source => "$build_area/KITS/$mysql_distro", directory => "/$data_dir/multi_mysql/ $mysql_instance", newfile => "INSTALL-BINARY", uid => "mysql", gid => "sysadmin", compression => "gzip", } }#end of mysql_install define Thanks to all the puppet masters for any help with this. -Tom --~--~---------~--~----~------------~-------~--~----~ 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Bruce Richardson
2009-Mar-16 15:33 UTC
[Puppet Users] Re: Expert Idempotency Question: Multi-Mysql Installation File System Creation Question
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 isBy 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Bruce Richardson
2009-Mar-16 15:45 UTC
[Puppet Users] Re: Expert Idempotency Question: Multi-Mysql Installation File System Creation Question
On Mon, Mar 16, 2009 at 08:16:31AM -0700, TomTom wrote:> > First of all, my puppet definition below tries to do the untar first, > and doesn''t try to create the file system. I don''t think I have my > require order correct. How can I fix that.I''m not familiar with "tarextract"; it isn''t a built-in type, so I assume this is either a definition or a user-written function. In any case, there''s nothing in the tarextract instance as shown there that creates any requirement. I''d say that the tarextract definition needs to be rewritten to require the file named by the $source parameter. -- Bruce Those who cast the votes decide nothing. Those who count the votes decide everything. -- Joseph Stalin --~--~---------~--~----~------------~-------~--~----~ 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Felix Schäfer
2009-Mar-16 15:47 UTC
[Puppet Users] Re: Expert Idempotency Question: Multi-Mysql Installation File System Creation Question
Hello, Am 16.03.2009 um 16:16 schrieb TomTom:> I am trying to puppetize a multi-mysql installation. Our mysql > consultant suggested that we use the pre-compiled binary installations > from mysql.com. > So a multi-instance mysql installation would look like > /data01/multi_mysql/mysql_A/ > /data01/multi_mysql/mysql_B/ > /data01/multi_mysql/mysql_C/ > > First of all, my puppet definition below tries to do the untar first, > and doesn''t try to create the file system. I don''t think I have my > require order correct. How can I fix that.Not sure what the tarextrat {} does, but wouldn''t it be enough to require => Exec["some_alias"] (I''d pop in an alias => "some_alias" in the exec)?> 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 > previously defined. Does anyone know how to get around this.Try a virtual resource http://reductivelabs.com/trac/puppet/wiki/LanguageTutorial#virtual-resources . Basically, you define the resource somewhere outside the define, but it won''t do anything on its own. You then put the realize function in the definition, which will make the resource do something if it''s called at least once, but it won''t bother puppet if the realize is called more than once.> My > instance installation class is: > define mysql_install_definition ( > $data_dir, $mysql_instance, $mysql_distro > ) { > $wget = "wget -q" > $build_area = "/usr/local/puppet" > > #data_dir should be there before this gets started > #file { "/$data_dir": > # mode => 775, owner => "mysql", group => "sysadmin", > # } > > file { "/$data_dir/multi_mysql": > mode => 775, owner => "mysql", group => "sysadmin", > require => File [ "/$data_dir" ], > } > > file { "/$data_dir/multi_mysql/$mysql_instance": > mode => 775, owner => "mysql", group => "sysadmin", > require => File [ "/$data_dir/multi_mysql" ], > } > > file { "/$data_dir/log": > mode => 775, owner => "mysql", group => > "sysadmin", > require => File [ "/$data_dir" ], > } > > file { "/$data_dir/log/$mysql_instance": > mode => 775, owner => "mysql", group => > "sysadmin", > require => File [ "/$data_dir/log" ], > } > > exec { "wget -q ftp://$server_local/depot/precompiled/ > $mysql_distro": > cwd => "$build_area/KITS", > creates => "$build_area/KITS/${mysql_distro}", > require => [File [ "$build_area/KITS" ], File [ "/ > $data_dir/multi_mysql/$mysql_instance" ]], > } > > tarextract { "$buld_area/KITS/$mysql_distro": > source => "$build_area/KITS/$mysql_distro", > directory => "/$data_dir/multi_mysql/ > $mysql_instance", > newfile => "INSTALL-BINARY", > uid => "mysql", > gid => "sysadmin", > compression => "gzip", > } > }#end of mysql_install definePeace, Felix Schäfer --~--~---------~--~----~------------~-------~--~----~ 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
TomTom
2009-Mar-16 15:48 UTC
[Puppet Users] Re: Expert Idempotency Question: Multi-Mysql Installation File System Creation Question
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Bruce Richardson
2009-Mar-16 15:54 UTC
[Puppet Users] Re: Expert Idempotency Question: Multi-Mysql Installation File System Creation Question
On Mon, Mar 16, 2009 at 08:48:13AM -0700, TomTom wrote:> > 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_HYou create a definition that can create one instance and doesn''t clash with others. Then you define all your directories at once like this: mysql_instance { [''mysql_A'', ''mysql_B'', ''mysql_C'']: data_dir => ''/data01/multi_mysql'', parameter1 => ''whatever'', parameter2 => ''whatever_next'', } If you follow either of my recommendations for avoiding the data_dir clash, it will work fine. -- Bruce I unfortunately do not know how to turn cheese into gold. --~--~---------~--~----~------------~-------~--~----~ 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Felix Schäfer
2009-Mar-16 16:01 UTC
[Puppet Users] Re: Expert Idempotency Question: Multi-Mysql Installation File System Creation Question
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
TomTom
2009-Mar-16 16:36 UTC
[Puppet Users] Re: Expert Idempotency Question: Multi-Mysql Installation File System Creation Question
Thanks a lot Fellows, I will start working on the virtual resource immediately. Thanks again! -Tom On Mar 16, 12:01 pm, Felix Schäfer <schae...@cypres-it.com> 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Joshua Anderson
2009-Mar-16 17:57 UTC
[Puppet Users] Re: Expert Idempotency Question: Multi-Mysql Installation File System Creation Question
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
sjmudd@pobox.com
2009-Mar-17 07:00 UTC
[Puppet Users] Re: Expert Idempotency Question: Multi-Mysql Installation File System Creation Question
mcgonagle@gmail.com (TomTom) writes:> I am trying to puppetize a multi-mysql installation. Our mysql > consultant suggested that we use the pre-compiled binary installations > from mysql.com. > So a multi-instance mysql installation would look like > /data01/multi_mysql/mysql_A/ > /data01/multi_mysql/mysql_B/ > /data01/multi_mysql/mysql_C/ >I do something like this storing each instance under /mysql/<instance_name> though I have an lvm partition under filesystem and puppet builds this for me. In case it helps I do it like this: ########################################################################### # This is for creating a partition of the defined type if it doesn''t exit # and mounting it. # Typical usage: # logicalvolume{ "/tmp/mount_point": # $lvsize => "20G", # $fstype => "xfs", # $mode => "755", # } # # NOTE: use mode 755 for /mysql/<instance> as local socket access for all # users requires access to /mysql/<instance>/data/mysql.sock and mode # 750 breaks that unless you are the user mysql or part of the mysql # group. # Manage a partition and create if needed. # The name SHOULD be the mount point, such as "/mysql/bp" define logicalvolume ( $lvsize = "1G", $fstype = "ext3", $vgname = "vg00", $lvname = "$name", $owner = "root", $group = "root", $mode = "755" ) { # FIXME: Ensure the user/group exist before trying to create the directory # $ getent passwd | grep ^$user: | wc -l # could be replaced by id ? # 1 # $ getent group | grep ^$group: | wc -l # replacable by something else? # 1 # The mysql user will only exist once the MySQL rpm has been installed, # but we can''t add the package dependency here as lvm configs should not # depend on mysql configs. file { "${name}": ensure => directory, owner => $owner, group => $group, mode => $mode, } exec { "lvcreate-${vgname}-${lvname}": path => [ "/sbin", "/bin", "/usr/sbin", "/usr/bin" ], logoutput => false, command => "lvcreate -n ${lvname} -L ${lvsize} /dev/${vgname} && mkfs -t ${fstype} /dev/${vgname}/${lvname}", unless => "lvs | grep -q ''${lvname}.*${vgname}''", subscribe => File[ "$name"], } mount { "${name}": atboot => true, device => "/dev/$vgname/$lvname", ensure => mounted, fstype => "${fstype}", options => "defaults", dump => "1", pass => "2", require => [ Exec["lvcreate-${vgname}-${lvname}"], File["${name}"] ], } } Then for each instance I need to build I define a class class instance_01 { ... other stuff for this group of boxes logicalvolume { "/mysql/instance_01": lvname => "mysqlVol", lvsize => "150G", fstype => "xfs", vgname => "sysvm", owner => "mysql", group => "mysql", mode => "755", } } This doesn''t include your tarball extract and of course may need adjusting for your environment but basically does the same thing as you want. It works well for me. Hope it helps. Simon --~--~---------~--~----~------------~-------~--~----~ 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
TomTom
2009-Mar-17 21:52 UTC
[Puppet Users] Re: Expert Idempotency Question: Multi-Mysql Installation File System Creation Question
Hi Simon, That is very helpful, I am going to go through your puppet definition. Ill post any questions I have to this thread. Thanks a lot everyone! -Tom On Mar 17, 3:00 am, sjm...@pobox.com wrote:> mcgona...@gmail.com (TomTom) writes: > > I am trying to puppetize a multi-mysql installation. Our mysql > > consultant suggested that we use the pre-compiled binary installations > > from mysql.com. > > So a multi-instance mysql installation would look like > > /data01/multi_mysql/mysql_A/ > > /data01/multi_mysql/mysql_B/ > > /data01/multi_mysql/mysql_C/ > > I do something like this storing each instance under > /mysql/<instance_name> though I have an lvm partition under filesystem > and puppet builds this for me. > > In case it helps I do it like this: > > ########################################################################### > # This is for creating a partition of the defined type if it doesn''t exit > # and mounting it. > # Typical usage: > # logicalvolume{ "/tmp/mount_point": > # $lvsize => "20G", > # $fstype => "xfs", > # $mode => "755", > # } > # > # NOTE: use mode 755 for /mysql/<instance> as local socket access for all > # users requires access to /mysql/<instance>/data/mysql.sock and mode > # 750 breaks that unless you are the user mysql or part of the mysql > # group. > > # Manage a partition and create if needed. > # The name SHOULD be the mount point, such as "/mysql/bp" > define logicalvolume ( > $lvsize = "1G", > $fstype = "ext3", > $vgname = "vg00", > $lvname = "$name", > $owner = "root", > $group = "root", > $mode = "755" ) { > > # FIXME: Ensure the user/group exist before trying to create the directory > # $ getent passwd | grep ^$user: | wc -l # could be replaced by id ? > # 1 > # $ getent group | grep ^$group: | wc -l # replacable by something else? > # 1 > # The mysql user will only exist once the MySQL rpm has been installed, > # but we can''t add the package dependency here as lvm configs should not > # depend on mysql configs. > > file { "${name}": > ensure => directory, > owner => $owner, > group => $group, > mode => $mode, > } > > exec { "lvcreate-${vgname}-${lvname}": > path => [ "/sbin", "/bin", "/usr/sbin", "/usr/bin" ], > logoutput => false, > command => "lvcreate -n ${lvname} -L ${lvsize} /dev/${vgname} && mkfs -t ${fstype} /dev/${vgname}/${lvname}", > unless => "lvs | grep -q ''${lvname}.*${vgname}''", > subscribe => File[ "$name"], > } > > mount { "${name}": > atboot => true, > device => "/dev/$vgname/$lvname", > ensure => mounted, > fstype => "${fstype}", > options => "defaults", > dump => "1", > pass => "2", > require => [ Exec["lvcreate-${vgname}-${lvname}"], File["${name}"] ], > } > > } > > Then for each instance I need to build I define a class > > class instance_01 { > ... other stuff for this group of boxes > logicalvolume { "/mysql/instance_01": > lvname => "mysqlVol", > lvsize => "150G", > fstype => "xfs", > vgname => "sysvm", > owner => "mysql", > group => "mysql", > mode => "755", > } > > } > > This doesn''t include your tarball extract and of course may need > adjusting for your environment but basically does the same thing as > you want. It works well for me. > > Hope it helps. > > Simon--~--~---------~--~----~------------~-------~--~----~ 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---