Re: [Puppet Users] Optionally ensuring a service is running

2010-08-11 Thread Matthew Macdonald-Wallace
On Wed, 2010-08-11 at 14:49 -0400, Marc Zampetti wrote:
> Thanks all for the suggestions so far. A little more info to make it
> clear what I'm trying to do.
> 
> Basically, I don't want to stop Puppet from running and managing the
> rest of the system, I just don't want it changing the state of the
> service itself. For example, an Apache http server is in maintenance
> mode because someone is troubleshooting an issue or something like
> that. I want to be able to have apache running, or not, but I don't
> want apache to be started or stopped while I'm working on it. For
> example, debugging some dynamic pages or something like that. I know I
> can turn off puppet, and in some cases that is the better way to go.
> But for some things, like say a dev or qa server, where I have other
> things running that need to be kept up to date, I want the option of
> controlling the service itself. Once out of maintenance, I want Puppet
> to resume controlling the running state. 

Check out mcollective - R.I.'s written quite a few agents that will push
you in this direction already:

http://code.google.com/p/mcollective/
http://www.devco.net/archives/2010/08/05/rapid_puppet_runs_with_mcollective.php
http://www.devco.net/archives/2010/03/17/scheduling_puppet_with_mcollective.php

Hope that's of some use,

Matt

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@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.



Re: [Puppet Users] Optionally ensuring a service is running

2010-08-11 Thread Marc Zampetti
 Thanks all for the suggestions so far. A little more info to make it 
clear what I'm trying to do.


Basically, I don't want to stop Puppet from running and managing the 
rest of the system, I just don't want it changing the state of the 
service itself. For example, an Apache http server is in maintenance 
mode because someone is troubleshooting an issue or something like that. 
I want to be able to have apache running, or not, but I don't want 
apache to be started or stopped while I'm working on it. For example, 
debugging some dynamic pages or something like that. I know I can turn 
off puppet, and in some cases that is the better way to go. But for some 
things, like say a dev or qa server, where I have other things running 
that need to be kept up to date, I want the option of controlling the 
service itself. Once out of maintenance, I want Puppet to resume 
controlling the running state.


I'll report back what I'm able to get to work.

Marc

On 8/11/10 1:44 PM, Nan Liu wrote:
On Wed, Aug 11, 2010 at 12:27 PM, Marc Zampetti 
mailto:marc.zampe...@gmail.com>> wrote:


To do this, I see two issues.
1) How do I test for the existence of a file? The docs don't seem
to be able to do so. I'm guessing I would need to define a custom
fact for that, right?
2) How do make it so that the service "ensure" property is
correct? Right now, it appears that only "running" or "notrunning"
is valid. Would "ignored" or undef or something like that work?


Depends whether you want puppet to fail the rest of the dependency of 
this service or simply not perform any changes to the service state 
but allow the rest of the manifest to process without any issues.


In the first scenario, require an exec which checks for file absent. 
In the second scenario, write a custom fact $maintenance (recommend 
prefixing your site name to the fact) and simply apply the 
meta-parameter noop => true and Puppet simply won't make any changes 
to the service state:


# maintenance.rb
Facter.add("maintenance") do
  setcode do
File::exists?("/path/to/file")
  end
end

# in Puppet Class
If ${maintenance} {
  notice ("System in maintenance mode.")
  Service {
noop => true,
  }
}

Not sure if it's ideal, since both solutions will generate a fair 
amount of logging.


Thanks,

Nan
--
You received this message because you are subscribed to the Google 
Groups "Puppet Users" group.

To post to this group, send email to puppet-us...@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.


--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To post to this group, send email to puppet-us...@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.



Re: [Puppet Users] Optionally ensuring a service is running

2010-08-11 Thread Nan Liu
On Wed, Aug 11, 2010 at 1:02 PM, Nigel Kersten  wrote:

> You could use tags to identify that subset of resources, and have the
> client work out whether it's under a maintenance window or not and
> supply the appropriate tag specification to Puppet if so?
>

I recommend voting up the negate tag feature, since the list of resource to
exclude is usually a much smaller subset:
http://projects.puppetlabs.com/issues/3746

Thanks,

Nan

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@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.



Re: [Puppet Users] Optionally ensuring a service is running

2010-08-11 Thread Nan Liu
On Wed, Aug 11, 2010 at 12:27 PM, Marc Zampetti wrote:

> To do this, I see two issues.
> 1) How do I test for the existence of a file? The docs don't seem to be
> able to do so. I'm guessing I would need to define a custom fact for that,
> right?
> 2) How do make it so that the service "ensure" property is correct? Right
> now, it appears that only "running" or "notrunning" is valid. Would
> "ignored" or undef or something like that work?
>

Depends whether you want puppet to fail the rest of the dependency of this
service or simply not perform any changes to the service state but allow the
rest of the manifest to process without any issues.

In the first scenario, require an exec which checks for file absent. In the
second scenario, write a custom fact $maintenance (recommend prefixing your
site name to the fact) and simply apply the meta-parameter noop => true and
Puppet simply won't make any changes to the service state:

# maintenance.rb
Facter.add("maintenance") do
  setcode do
File::exists?("/path/to/file")
  end
end

# in Puppet Class
If ${maintenance} {
  notice ("System in maintenance mode.")
  Service {
noop => true,
  }
}

Not sure if it's ideal, since both solutions will generate a fair amount of
logging.

Thanks,

Nan

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@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.



Re: [Puppet Users] Optionally ensuring a service is running

2010-08-11 Thread Nigel Kersten
On Wed, Aug 11, 2010 at 9:27 AM, Marc Zampetti  wrote:
>  I want puppet to normally manage the running state of a service, so that if
> the service stops, it is restarted, etc. But during maintenance windows, I
> want puppet to leave the service in whatever state it is in. My idea is to
> have a file that can be checked to see if the service is in maintenance
> mode, and if so, then skip the ensure check.

Do you want all of puppet to be like this? Or do you have a
significant subset of your manifests that you still want applied
during maintenance windows?

You could use tags to identify that subset of resources, and have the
client work out whether it's under a maintenance window or not and
supply the appropriate tag specification to Puppet if so?

>
> To do this, I see two issues.
> 1) How do I test for the existence of a file? The docs don't seem to be able
> to do so. I'm guessing I would need to define a custom fact for that, right?
> 2) How do make it so that the service "ensure" property is correct? Right
> now, it appears that only "running" or "notrunning" is valid. Would
> "ignored" or undef or something like that work?
>
> Is there a better way to achieve what I'm trying to do?
>
> Marc Zampetti
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To post to this group, send email to puppet-us...@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.
>
>



-- 
nigel

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@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.



Re: [Puppet Users] Optionally ensuring a service is running

2010-08-11 Thread Patrick Mohr

On Aug 11, 2010, at 9:31 AM, Joe McDonagh wrote:

> On 08/11/2010 12:27 PM, Marc Zampetti wrote:
>> I want puppet to normally manage the running state of a service, so that if 
>> the service stops, it is restarted, etc. But during maintenance windows, I 
>> want puppet to leave the service in whatever state it is in. My idea is to 
>> have a file that can be checked to see if the service is in maintenance 
>> mode, and if so, then skip the ensure check.
>> 
>> To do this, I see two issues.
>> 1) How do I test for the existence of a file? The docs don't seem to be able 
>> to do so. I'm guessing I would need to define a custom fact for that, right?
>> 2) How do make it so that the service "ensure" property is correct? Right 
>> now, it appears that only "running" or "notrunning" is valid. Would 
>> "ignored" or undef or something like that work?
>> 
>> Is there a better way to achieve what I'm trying to do?
>> 
>> Marc Zampetti
>> 
> Marc, you might want to look into the schedule resource, and use that.
> 
> As for your questions:
> 
> 1. You would need a custom fact.

This will give you a race condition if you aren't careful.

Something like this should work:
*) Stop puppet
*) Stop service
*) Create File
*) Run puppet

Also, on some platforms you can modify the server's config so the platform init 
scripts won't start the service.  That might be easier.

> 2. There are more options for ensure for services, such as enabled, 
> installed, etc. I'm not sure undef would work. If you set a schedule for it 
> though, it shoudl only apply the resource during that schedule.
> 


-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@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.



Re: [Puppet Users] Optionally ensuring a service is running

2010-08-11 Thread Joe McDonagh

On 08/11/2010 12:27 PM, Marc Zampetti wrote:
 I want puppet to normally manage the running state of a service, so 
that if the service stops, it is restarted, etc. But during 
maintenance windows, I want puppet to leave the service in whatever 
state it is in. My idea is to have a file that can be checked to see 
if the service is in maintenance mode, and if so, then skip the ensure 
check.


To do this, I see two issues.
1) How do I test for the existence of a file? The docs don't seem to 
be able to do so. I'm guessing I would need to define a custom fact 
for that, right?
2) How do make it so that the service "ensure" property is correct? 
Right now, it appears that only "running" or "notrunning" is valid. 
Would "ignored" or undef or something like that work?


Is there a better way to achieve what I'm trying to do?

Marc Zampetti


Marc, you might want to look into the schedule resource, and use that.

As for your questions:

1. You would need a custom fact.
2. There are more options for ensure for services, such as enabled, 
installed, etc. I'm not sure undef would work. If you set a schedule for 
it though, it shoudl only apply the resource during that schedule.


--
Joe McDonagh
AIM: YoosingYoonickz
IRC: joe-mac on freenode
"When the going gets weird, the weird turn pro."

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To post to this group, send email to puppet-us...@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.



[Puppet Users] Optionally ensuring a service is running

2010-08-11 Thread Marc Zampetti
 I want puppet to normally manage the running state of a service, so 
that if the service stops, it is restarted, etc. But during maintenance 
windows, I want puppet to leave the service in whatever state it is in. 
My idea is to have a file that can be checked to see if the service is 
in maintenance mode, and if so, then skip the ensure check.


To do this, I see two issues.
1) How do I test for the existence of a file? The docs don't seem to be 
able to do so. I'm guessing I would need to define a custom fact for 
that, right?
2) How do make it so that the service "ensure" property is correct? 
Right now, it appears that only "running" or "notrunning" is valid. 
Would "ignored" or undef or something like that work?


Is there a better way to achieve what I'm trying to do?

Marc Zampetti

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To post to this group, send email to puppet-us...@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.