Chris MacLeod
2007-Sep-24 22:15 UTC
conceptual problem deploying git repos to a puppetmaster
So before I start I should be upfront and disclose that I''m using external_nodes, so in keeping with that I''m trying as hard as possible to keep all the actually ''specific'' data in the node config files (currently just yaml)and have nothing specific in modules especially. So I have this definition: (credit goes to DavidS for the inspiration) define git::repo ( $owner = "git", $group = "git", $src = "", $dst = "", $branch = "master", $use_names = '''' ) { if $name { include git if $use_names { $clonedst = "$dst/${name}" $clonesrc = "$src/${name}" } else { $clonedst = $dst $clonesrc = $src } file { $clonedst: owner => $owner, group => $group, mode => 0644, } exec { "clone-repo-${name}": creates => $clonedst, path => "/usr/bin:/bin:/usr/local/bin", command => "git clone ${clonesrc} ${clonedst}", require => Package["git-core"], } case $branch { master: { exec { "branch-repo-${name}-${branch}": cwd => $clonedst, path => "/usr/bin:/bin:/usr/local/bin", command => "git checkout -b ${branch}", unless => "git branch | grep ''* ${branch}''", require => Exec["clone-repo-${name}"], } } } } } Then I call it like this: (for my puppetmaster in this case) git::repo { $puppet_modules: src => "${gitserver}", dst => "${puppetdir}/modules/main/", use_names => true, } where: $puppet_modules = [ ''puppet'', ''ssh'', ''apache'', ... ] # and so on listing out all my modules This works great, no problems, in my yaml I can define a list of modules that should be cloned on the puppet server in the appropriate directory. myproblem comes in that my puppetserver (at least 1 of them) will be the master for multiple environments. In keeping with the multienvironment wiki node, each of my modules is a git repo and has mutliple branches for each env (development, testing, etc) So on the puppetmaster I need to checkout the default module set, then all the modules that may have various branches. Right now I''m going with an explicit list of modules so I can control what goes into what env. So I was thinking I would have this: git::repo { $puppet_dev_modules: src => "${gitserver}", dst => "${puppetdir}/modules/dev", branch => "dev", use_names => true, } where: $puppet_dev_modules = [ ''ssh'', ''apache'' ] #some subset of the main list the problem is (can you guess), I get a namespace collision b/c the module names are the same so puppet the ''repo'' type is the same and can''t be redefined. Certainly this is the right behavior but I''m kinda at a loss of how to rework things b/c of the collision. I had hoped to use git''s superprojects but it''s very hard to decree that the submodules are defaulted to a single branch. Also I like only the modules that have branched to show up in the dev modulepath, it removes question of where a module is being pulled from. I recognize that I could create a class that explicitly called git::repo each time for all the modules and their branches. I may have to go to that, but it seems like there''s a way to solve this problem without throwing another class at it and keeping all the specific data in the node. Thanks, Chris -- stickm@gmail.com -==< Stick >==- _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
Bryan Kearney
2007-Sep-24 22:21 UTC
Re: conceptual problem deploying git repos to a puppetmaster
Can you change the name to be more descriptive, and add the repos as a variable? So.. instead of this: git::repo { $puppet_modules: src => "${gitserver}", dst => "${puppetdir}/modules/main/", use_names => true, } You have git::repo { "Dev repos": $puppet_modules: src => "${gitserver}", dst => "${puppetdir}/modules/main/", use_names => true, } On 9/24/07, Chris MacLeod <stickm@gmail.com> wrote:> > So before I start I should be upfront and disclose that I''m using > external_nodes, so in keeping with that I''m trying as hard as possible to > keep all the actually ''specific'' data in the node config files (currently > just yaml) and have nothing specific in modules especially. > > So I have this definition: (credit goes to DavidS for the inspiration) > define git::repo ( $owner = "git", $group = "git", $src = "", $dst = "", > $branch = "master", $use_names = '''' ) { > if $name { > include git > if $use_names { > $clonedst = "$dst/${name}" > $clonesrc = "$src/${name}" > } else { > $clonedst = $dst > $clonesrc = $src > } > file { $clonedst: > owner => $owner, > group => $group, > mode => 0644, > } > exec { "clone-repo-${name}": > creates => $clonedst, > path => "/usr/bin:/bin:/usr/local/bin", > command => "git clone ${clonesrc} ${clonedst}", > require => Package["git-core"], > } > case $branch { > master: { > exec { "branch-repo-${name}-${branch}": > cwd => $clonedst, > path => "/usr/bin:/bin:/usr/local/bin", > command => "git checkout -b ${branch}", > unless => "git branch | grep ''* ${branch}''", > require => Exec["clone-repo-${name}"], > } > } > } > } > } > > Then I call it like this: (for my puppetmaster in this case) > > git::repo { $puppet_modules: > src => "${gitserver}", > dst => "${puppetdir}/modules/main/", > use_names => true, > } > > where: > $puppet_modules = [ ''puppet'', ''ssh'', ''apache'', ... ] # and so on listing > out all my modules > > This works great, no problems, in my yaml I can define a list of modules > that should be cloned on the puppet server in the appropriate directory. > > myproblem comes in that my puppetserver (at least 1 of them) will be the > master for multiple environments. In keeping with the multienvironment wiki > node, each of my modules is a git repo and has mutliple branches for each > env (development, testing, etc) > > So on the puppetmaster I need to checkout the default module set, then all > the modules that may have various branches. Right now I''m going with an > explicit list of modules so I can control what goes into what env. > > So I was thinking I would have this: > > git::repo { $puppet_dev_modules: > src => "${gitserver}", > dst => "${puppetdir}/modules/dev", > branch => "dev", > use_names => true, > } > > where: > $puppet_dev_modules = [ ''ssh'', ''apache'' ] #some subset of the main list > > the problem is (can you guess), I get a namespace collision b/c the module > names are the same so puppet the ''repo'' type is the same and can''t be > redefined. > > Certainly this is the right behavior but I''m kinda at a loss of how to > rework things b/c of the collision. > > I had hoped to use git''s superprojects but it''s very hard to decree that > the submodules are defaulted to a single branch. Also I like only the > modules that have branched to show up in the dev modulepath, it removes > question of where a module is being pulled from. > > I recognize that I could create a class that explicitly called git::repo > each time for all the modules and their branches. I may have to go to that, > but it seems like there''s a way to solve this problem without throwing > another class at it and keeping all the specific data in the node. > > Thanks, > > Chris > > > > > -- > stickm@gmail.com > -==< Stick >==- > > _______________________________________________ > Puppet-users mailing list > Puppet-users@madstop.com > https://mail.madstop.com/mailman/listinfo/puppet-users > >_______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
Bryan Kearney
2007-Sep-24 22:23 UTC
Re: conceptual problem deploying git repos to a puppetmaster
Stupid gmail... instead of this: git::repo { $puppet_modules: src => "${gitserver}", dst => "${puppetdir}/modules/main/", use_names => true, } You have git::repo { "Dev repos": projects => $puppet_modules, src => "${gitserver}", dst => "${puppetdir}/modules/main/", use_names => true, } On 9/24/07, Bryan Kearney <bkearney@redhat.com> wrote:> > Can you change the name to be more descriptive, and add the repos as a > variable? So.. instead of this: > > git::repo { $puppet_modules: > src => "${gitserver}", > dst => "${puppetdir}/modules/main/", > use_names => true, > } > > You have > > git::repo { "Dev repos": > $puppet_modules: > src => "${gitserver}", > dst => "${puppetdir}/modules/main/", > use_names => true, > } > > > > On 9/24/07, Chris MacLeod <stickm@gmail.com > wrote: > > > So before I start I should be upfront and disclose that I''m using > > external_nodes, so in keeping with that I''m trying as hard as possible to > > keep all the actually ''specific'' data in the node config files (currently > > just yaml) and have nothing specific in modules especially. > > > > So I have this definition: (credit goes to DavidS for the inspiration) > > define git::repo ( $owner = "git", $group = "git", $src = "", $dst = "", > > $branch = "master", $use_names = '''' ) { > > if $name { > > include git > > if $use_names { > > $clonedst = "$dst/${name}" > > $clonesrc = "$src/${name}" > > } else { > > $clonedst = $dst > > $clonesrc = $src > > } > > file { $clonedst: > > owner => $owner, > > group => $group, > > mode => 0644, > > } > > exec { "clone-repo-${name}": > > creates => $clonedst, > > path => "/usr/bin:/bin:/usr/local/bin", > > command => "git clone ${clonesrc} ${clonedst}", > > require => Package["git-core"], > > } > > case $branch { > > master: { > > exec { "branch-repo-${name}-${branch}": > > cwd => $clonedst, > > path => "/usr/bin:/bin:/usr/local/bin", > > command => "git checkout -b ${branch}", > > unless => "git branch | grep ''* > > ${branch}''", > > require => Exec["clone-repo-${name}"], > > } > > } > > } > > } > > } > > > > Then I call it like this: (for my puppetmaster in this case) > > > > git::repo { $puppet_modules: > > src => "${gitserver}", > > dst => "${puppetdir}/modules/main/", > > use_names => true, > > } > > > > where: > > $puppet_modules = [ ''puppet'', ''ssh'', ''apache'', ... ] # and so on > > listing out all my modules > > > > This works great, no problems, in my yaml I can define a list of modules > > that should be cloned on the puppet server in the appropriate directory. > > > > myproblem comes in that my puppetserver (at least 1 of them) will be the > > master for multiple environments. In keeping with the multienvironment wiki > > node, each of my modules is a git repo and has mutliple branches for each > > env (development, testing, etc) > > > > So on the puppetmaster I need to checkout the default module set, then > > all the modules that may have various branches. Right now I''m going with an > > explicit list of modules so I can control what goes into what env. > > > > So I was thinking I would have this: > > > > git::repo { $puppet_dev_modules: > > src => "${gitserver}", > > dst => "${puppetdir}/modules/dev", > > branch => "dev", > > use_names => true, > > } > > > > where: > > $puppet_dev_modules = [ ''ssh'', ''apache'' ] #some subset of the main > > list > > > > the problem is (can you guess), I get a namespace collision b/c the > > module names are the same so puppet the ''repo'' type is the same and can''t be > > redefined. > > > > Certainly this is the right behavior but I''m kinda at a loss of how to > > rework things b/c of the collision. > > > > I had hoped to use git''s superprojects but it''s very hard to decree that > > the submodules are defaulted to a single branch. Also I like only the > > modules that have branched to show up in the dev modulepath, it removes > > question of where a module is being pulled from. > > > > I recognize that I could create a class that explicitly called git::repo > > each time for all the modules and their branches. I may have to go to that, > > but it seems like there''s a way to solve this problem without throwing > > another class at it and keeping all the specific data in the node. > > > > Thanks, > > > > Chris > > > > > > > > > > -- > > stickm@gmail.com > > -==< Stick >==- > > > > _______________________________________________ > > Puppet-users mailing list > > Puppet-users@madstop.com > > https://mail.madstop.com/mailman/listinfo/puppet-users > > > > >_______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
Luke Kanies
2007-Sep-25 16:22 UTC
Re: conceptual problem deploying git repos to a puppetmaster
On Sep 24, 2007, at 5:15 PM, Chris MacLeod wrote:> the problem is (can you guess), I get a namespace collision b/c the > module names are the same so puppet the ''repo'' type is the same and > can''t be redefined. > > Certainly this is the right behavior but I''m kinda at a loss of how > to rework things b/c of the collision.Hmm, that''s a tough one. Until we get to the point where we can support multi-key resources, I think you''re stuck doing something silly like including both the module name and branch in the title, and then figuring it out internal to the definition. Alternatively, you could maybe have a ''puppet-environment'' setup, and list the modules there, assuming you have a standard source: puppet::environment { dev: branch => dev, destination => "$puppetdir/ modules/dev", modules => $modules } Something like that. -- The Number 1 Sign You Have Nothing to Do at Work... The 4th Division of Paperclips has overrun the Pushpin Infantry and General White-Out has called for a new skirmish. --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com