Sorry, my last post got cut off: So my real problem is how to trigger the conditional exec notify after the vcsrepo resource pulls in updates. It is very important that this stay abstract because this is used in multiple modules and in each triggers different build operations.
On Tuesday, October 9, 2012 2:40:04 PM UTC+1, Adrian Webb wrote: > > Unfortunately what I need is a little more abstract because I have rolled > my definition into a module that is used by other modules. Below is my > definition (that does not work as intended) right now > > define git::repo ( > > $repo_name = $name, > $user = $git::params::user, > $group = $git::params::group, > $home = $git::params::home, > $source = $git::params::source, > $revision = $git::params::revision, > $base = $git::params::base, > $post_update_commands = $git::params::post_update_commands, > $post_update_template = $git::params::post_update_template, > $update_notify = undef, > > ) { > > $repo_dir = $home ? { > '' => $repo_name, > default => "${home}/${repo_name}", > } > > $repo_git_dir = $base ? { > 'true' => $repo_dir, > default => "${repo_dir}/.git" > } > > $test_diff_cmd = "diff ${repo_git_dir}/_NEW_REVISION > ${repo_git_dir}/_LAST_REVISION" > > include git > > #-- > > Exec { > path => [ '/bin', '/usr/bin', '/usr/local/bin' ], > cwd => $repo_dir, > user => $user, > } > > > #----------------------------------------------------------------------------- > > if $source and $revision { > $revision_real = $revision > } > else { > $revision_real = undef > } > > vcsrepo { $repo_dir: > ensure => $base ? { > 'true' => 'base', > default => $source ? { > '' => 'present', > default => 'latest', > }, > }, > provider => 'git', > owner => $user, > group => $group, > force => true, > source => $source ? { > '' => undef, > default => $source, > }, > revision => $revision_real, > require => Class['git'], > } > > #--- > > exec { "${repo_dir}-new-revision": > command => "git rev-parse HEAD > ${repo_git_dir}/_NEW_REVISION", > returns => [ 0, 128 ], > require => Class['git'], > subscribe => Vcsrepo[$repo_dir], > } > > exec { "${repo_dir}-update-notify": > command => 'test true', > onlyif => $test_diff_cmd, > notify => $update_notify, > require => Exec["${repo_dir}-new-revision"], > } > > exec { "${repo_dir}-last-revision": > command => "git rev-parse HEAD > ${repo_git_dir}/_LAST_REVISION", > returns => [ 0, 128 ], > subscribe => Exec["${repo_dir}-update-notify"], > } > > > #----------------------------------------------------------------------------- > > if $home and $base == 'false' { > exec { "${repo_dir}-receive-deny-current-branch": > command => "git config receive.denyCurrentBranch 'ignore'", > refreshonly => true, > subscribe => Vcsrepo[$repo_dir], > } > } > > file { "${repo_dir}-post-update": > path => "${repo_git_dir}/hooks/post-update", > owner => $user, > group => $group, > mode => '0755', > content => template($post_update_template), > subscribe => Vcsrepo[$repo_dir], > } > } > > As you can see I use the vcsrepo module to update my repo and then desire to > send a notify up to the caller through the parameters. So my real problem is > how to trigger the conditional exec notify after the vcsrepo resource pulls > in updates. It is very important that this stay abstract because this is > used in multiple modules and in each triggers different build operations. > > Thanks, > Adrian > > > > On Tuesday, October 9, 2012 1:12:53 PM UTC+1, Henrik Lindberg wrote: >> >> Did you try using an update resource, and a build resource, where the >> second depends on the first? >> >> i.e. something like >> >> exec { 'repository_update': >> command => 'git pull', >> } >> exec { 'build': >> command => 'make', >> require => Exec['repository_update'] >> } >> >> or, if you prefer: >> >> exec { 'repository_update': >> command => 'git pull', >> } >> exec { 'build': >> command => 'make', >> } >> >> Exec['build'] -> Exec['repository_update'] >> >> - henrik >> >> On 2012-09-10 13:12, Adrian Webb wrote: >> > Hello, >> > >> > I've been trying to implement a puppet definition that uses vcsrepo and >> > notifies the caller through an update_notify parameter when the >> > repository contents change on disk. I have however found this very >> hard >> > to accomplish. >> > >> > Basically I am trying to pull down a git repo and when the head of the >> > repo changes on the disk of the agent, run a build command (such as >> > make) into a release directory. So the system automatically tracks a >> > branch or responds to changes in tags and the system automatically >> > builds off of that information. In order to allow for multiple types >> of >> > build processes I am trying to notify other resources through the exec >> > notify property. >> > >> > My problem is this: >> > >> > The only way to trigger the notification in a conditional manner that I >> > have found is to use the onlyif or unless properties on the exec >> > resource. Notifications still happen on the exec command even if the >> > command fails so I can not use an inline command to notify or not (that >> > I know of). But the onlyif property which I have been trying seems to >> > execute before any of the actual commands so it always runs before the >> > vcsrepo update, which voids the intended purpose. I can not use >> > functions with a conditional because they are only run on puppet master >> > and also suffer from the same issue where they run before any commands, >> > and I can not use a fact because I need a directory parameter and it is >> > also runs before any of the commands. >> > >> > So I need a way to conditionally trigger a notify during the course of >> a >> > execution run right after the vcsrepo gets done pulling down any >> > updates. Does anyone know how I might accomplish this task through >> > puppet? So far nothing I have tried works. I would think that this >> > goal would not be that isolated (building a repository after and only >> > after repository updates). In my case I normally build into release >> > directories so absolutely can not afford to rebuild on every puppet >> > execution which runs every 5 minutes. >> > >> > Thanks for any help you can provide! >> > >> > Adrian >> > >> > -- >> > You received this message because you are subscribed to the Google >> > Groups "Puppet Users" group. >> > To view this discussion on the web visit >> > https://groups.google.com/d/msg/puppet-users/-/NNQsDH1nox8J. >> > To post to this group, send email to puppet...@googlegroups.com. >> > To unsubscribe from this group, send email to >> > puppet-users...@googlegroups.com. >> > For more options, visit this group at >> > http://groups.google.com/group/puppet-users?hl=en. >> >> >> -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/i4BAYSoZebYJ. 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.