Debugging puppet error : Could not find dependency

63 views
Skip to first unread message

Milind Vaidya

unread,
May 21, 2020, 1:06:32 PM5/21/20
to Puppet Users
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 :




Ben Ford

unread,
May 21, 2020, 7:22:37 PM5/21/20
to puppet...@googlegroups.com
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], #   ----------------
}


--
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 puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/c580925f-709a-4539-9b8e-c588fb970721%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages