Hi Milind,
The critical difference here is that subscribe =>
File[$old_launch_agent_path] does NOT tell Puppet to watch for changes in
that file on disk.
Instead it will run that exec if Puppet itself is managing that resource
and makes changes to that resource. In other words,
File[$old_launch_agent_path] has to be in the catalog, and it only fires
when it's out of sync and Puppet makes changes to it. Something like the
following:
$old_launch_agent_path =
"${home}/Library/LaunchAgents/com.company.program.plist"
file { $old_launch_agent_path: <----------------------------------┐
ensure => file, |
#... |
} |
|
exec { 'stop-old-program': |
command => "/bin/launchctl unload ${old_launch_agent_path}", |
refreshonly => true, |
subscribe => File[$old_launch_agent_path], # ----------------┘
}
On Thu, May 21, 2020 at 10:06 AM Milind Vaidya <[email protected]> wrote:
> *Background*
>
> Puppet Newbie, trying to maintain some old puppet version on a box. The
> aim is to unload an old program using it's old plist file and start new
> one.
>
> *Problem*
>
> I have following code in .pp file
>
> $old_launch_agent_path =
> "${home}/Library/LaunchAgents/com.company.program.plist"
>
> exec {
> 'stop-old-program':
> command => "/bin/launchctl unload ${old_launch_agent_path}",
> refreshonly => true,
> subscribe => [ File[$old_launch_agent_path] ];
> }
>
> *Error: Could not find dependency
> File[/Users/executer/Library/LaunchAgents/com.company.program.plist] for
> Exec[stop-old-program] at
> /private/tmp/mobile-puppet-manifests/puppet-manifests-test/modules/program/manifests/init.pp:51*
>
>
> The changes are on a git branch and are being applied *`sudo puppet-apply
> -d -f -b mac-upgrade`*
>
>
> ls -l /Users/executer/Library/LaunchAgents/com.company.program.plist`
> -rw-r--r-- 1 executer staff 999 May 19 14:36
> /Users/executer/Library/LaunchAgents/com.company.program.plist
>
>
>
> Stack overflow link :
>
> https://stackoverflow.com/questions/61938607/debugging-puppet-error-could-not-find-dependency
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/c580925f-709a-4539-9b8e-c588fb970721%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/c580925f-709a-4539-9b8e-c588fb970721%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/CACkW_L6VX4-pth0G0eGb60DJtZUPhd_1iOwx%3DexzuXNOdVr6VQ%40mail.gmail.com.