I have a module for windows nodes that is defined like: class ast_win { Class['ast_win::env'] ~> Class['ast_win::restart'] -> Class['ast_win']
ast_win::env contains a bunch of scripts that modify the environment on the host machine. Mostly the PATH variable, but also other variables (e.g. http_proxy) that are required for downstream installations. ast_win::restart is supposed to run any time there is an environment change. It will restart the Puppet Agent service and prompt the user to close a command prompt, if that's how they're running the agent. Here's the class definition for that guy: class ast_win::restart { file {'RestartAgentBat' : ensure => file, source => 'puppet:///modules/ast_win/restart_agent.bat', path => 'C:\programdata\puppet\restart_agent.bat', recurse => true, mode => 0777, } exec {'restart_agent': cwd => 'C:\programdata\puppet', command => 'C:\programdata\puppet\restart_agent.bat', subscribe => File['RestartAgentBat'], refreshonly => true, creates => 'C:\programdata\puppet\restart_agent.txt', onlyif => 'cmd /c if exist restart_agent.txt (exit 1) else (exit)', path => $::path, } } This much works. What I'm trying to accomplish is when a restart is required, the "restart_agent" exec will return a non-zero exit status and Puppet will skip all of the resources defined in Class['ast_win'] (Class['ast_win::restart'] -> Class['ast_win']). restart_agent.bat creats a text file that wil be deteted on future runs via the onlyif check. The problem I'm running into is that even though restart_agent fails, Puppet still continues onto Class['ast_win']. Currently, I have everything commented out in that class except for a dummy exec task that always fails. Here is an example run, where a restart should be required, restart_agent fails, and puppet continues onto Class['ast_win']: Info: Class[Ast_win::Env]: Scheduling refresh of Class[Ast_win::Restart] Info: Class[Ast_win::Restart]: Scheduling refresh of Exec[restart_agent] Notice: /Stage[main]/Ast_win::Restart/File[RestartAgentBat]/ensure: defined content as '{md5}84ef01a7640a75f2fe702e8991be9e91' Info: /Stage[main]/Ast_win::Restart/File[RestartAgentBat]: Scheduling refresh of Exec[restart_agent] Notice: /Stage[main]/Ast_win::Restart/Exec[restart_agent]/returns: The Puppet Agent service is stopping. Notice: /Stage[main]/Ast_win::Restart/Exec[restart_agent]/returns: The Puppet Agent service was stopped successfully. Notice: /Stage[main]/Ast_win::Restart/Exec[restart_agent]/returns: Notice: /Stage[main]/Ast_win::Restart/Exec[restart_agent]/returns: ************* ************************************************************* Notice: /Stage[main]/Ast_win::Restart/Exec[restart_agent]/returns: Install Stage Complete. Restarting the puppet service. Notice: /Stage[main]/Ast_win::Restart/Exec[restart_agent]/returns: IF USING A COMMAND PROMPT, YOU MUST NOW CLOSE IT AND OPEN A NEW ONE BEFORE CONTINUING! Notice: /Stage[main]/Ast_win::Restart/Exec[restart_agent]/returns: ************* ************************************************************* Error: /Stage[main]/Ast_win::Restart/Exec[restart_agent]: Failed to call refresh: C:\programdata\puppet\restart_agent.bat returned 1 instead of one of [0] Error: /Stage[main]/Ast_win::Restart/Exec[restart_agent]: C:\programdata\puppet\restart_agent.bat returned 1 instead of one of [0] Notice: /Stage[main]/Ast_win/Exec[exit_init]/returns: INIT PATH <snip /> Error: cmd /c echo INIT PATH %PATH% & exit 1 returned 1 instead of one of [0] Error: /Stage[main]/Ast_win/Exec[exit_init]/returns: change from notrun to 0 failed: cmd /c echo INIT PATH %PATH% & exit 1 returned 1 instead of one of [0] Notice: Finished catalog run in 237.10 seconds Basically, what I'm looking for is a way to say: "Always run ast_win::env before ast_win::restart. Always run ast_win::restart before ast_win and don't run ast_win if ast_win::restart fails. The following chain seems to fail that very last bit: Class['ast_win::env'] ~> Class['ast_win::restart'] -> Class['ast_win'] Is there any way to accomplish what I'm trying to do? -- 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+unsubscr...@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.