{"action":"closed","issue":{"url":"https://api.github.com/repos/camptocamp/puppet-tomcat/issues/100","labels_url":"https://api.github.com/repos/camptocamp/puppet-tomcat/issues/100/labels{/name}","comments_url":"https://api.github.com/repos/camptocamp/puppet-tomcat/issues/100/comments","events_url":"https://api.github.com/repos/camptocamp/puppet-tomcat/issues/100/events","html_url":"https://github.com/camptocamp/puppet-tomcat/issues/100","id":34070327,"number":100,"title":"Instance not stopped running service if ensure=>absent","user":{"login":"toepi","id":952499,"avatar_url":"https://avatars.githubusercontent.com/u/952499?v=3","gravatar_id":"","url":"https://api.github.com/users/toepi","html_url":"https://github.com/toepi","followers_url":"https://api.github.com/users/toepi/followers","following_url":"https://api.github.com/users/toepi/following{/other_user}","gists_url":"https://api.github.com/users/toepi/gists{/gist_id}","starred_url":"https://api.github.com/users/toepi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toepi/subscriptions","organizations_url":"https://api.github.com/users/toepi/orgs","repos_url":"https://api.github.com/users/toepi/repos","events_url":"https://api.github.com/users/toepi/events{/privacy}","received_events_url":"https://api.github.com/users/toepi/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2014-05-22T10:48:57Z","updated_at":"2015-05-18T09:30:05Z","closed_at":"2015-05-18T09:30:05Z","body":"If you set ensure to absent for tomcat::instance, puppet doesn't stop the service, it only remove the init-script. I think this is the problem, because it delete init-script before stopping instance.\r\n\r\nI have made following changes:\r\n--- a/puppet/modules/tomcat/manifests/instance.pp\r\n+++ b/puppet/modules/tomcat/manifests/instance.pp\r\n@@ -556,7 +556,14 @@ define tomcat::instance(\r\n       installed => false,\r\n       absent    => false,\r\n     },\r\n-    require => [File[\"/etc/init.d/tomcat-${name}\"], $servicerequire],\r\n+    require => $ensure ? {\r\n+      absent  => [$servicerequire],\r\n+      default => [File[\"/etc/init.d/tomcat-${name}\"], $servicerequire],\r\n+    },\r\n+    before  => $ensure ? {\r\n+      absent  => File[\"/etc/init.d/tomcat-${name}\"],\r\n+      default => undef,\r\n+    },\r\n     pattern => \"-Dcatalina.base=${tomcat::instance_basedir}/${name}\",\r\n   }\r\nand it seem to work like expected."}}