Re: [Pacemaker] Automating Pacemaker Setup

2011-06-06 Thread Dejan Muhamedagic
On Mon, Jun 06, 2011 at 12:57:33PM +0200, Dejan Muhamedagic wrote:
> On Tue, May 31, 2011 at 02:02:38PM +, veghead wrote:
> > Dejan Muhamedagic  writes:
> > > On Fri, May 27, 2011 at 08:21:08PM +, veghead wrote:
> > > > 1) Is there a way to force crm to accept my configuration request 
> > > > ~before~ starting the second node?
> > > 
> > > No before the DC is elected. There are two settings: dc-deadtime
> > > and startup-fencing which can reduce the time for DC election.
> > > Note that disabling startup fencing is not recommended. But I
> > > don't know what's your use case. YMMV.
> > 
> > Well, I'm probably not quite the typical use case. We're using Amazon EC2 
> > to 
> > setup and tear down testing environments. I have automated the entire 
> > process 
> > except for setting up Pacemaker. Beyond testing environments, I'd like to 
> > automate Pacemaker setup to cover the scenario where all nodes in a 
> > Pacemaker 
> > cluster crash and the entire configuration is lost.
> > 
> > Obviously, once one node is running, setting up additional nodes becomes 
> > easy. 
> > It's just the bootstrap phase that's a challenge to automate.
> > 
> > > > 2) Is there a way to tell Pacemaker to ignore quorum requirements
> > > > ~before~ starting additional nodes?
> > > > 
> > > > 2) Is there an alternate way to configure Pacemaker?
> > > 
> > > Yes, you can modify the CIB _before_ starting pacemaker. Sth
> > > like:
> > > 
> > > CIB_file=/var/lib/heartbeat/crm/cib.xml crm configure ...
> > > 
> > > But in that case you need to remove cib.xml.sig. Then you have to
> > > make sure that pacemaker starts first on this node. Consider this
> > > only if everything else fails.
> > 
> > I'll give that a shot.
> 
> You can also test the attached patch. Either rebuild pacemaker or

Forgot to attach the patch as usual :) Here goes

> apply it to the crm python modules which should be installed in
> /usr/lib*/python*/site-packages/crm.
> 
> Afterwards, use crm -F or commit force.
> 
> Thanks,
> 
> Dejan
> 
> > Thanks.
> > 
> > -S
> > 
> > 
> > ___
> > Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
> > http://oss.clusterlabs.org/mailman/listinfo/pacemaker
> > 
> > Project Home: http://www.clusterlabs.org
> > Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
> > Bugs: 
> > http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker
# HG changeset patch
# User Dejan Muhamedagic 
# Date 1307357607 -7200
# Node ID 35dfe619460d0617ab4529a6bb34b9085786c7bb
# Parent  954c93bdb8dd3a2fc846d61f1a93502d19b27c7b
Medium: Shell: invoke cibadmin with --force when reqested by user

diff -r 954c93bdb8dd -r 35dfe619460d shell/modules/cibconfig.py
--- a/shell/modules/cibconfig.py	Thu May 26 10:44:28 2011 +0200
+++ b/shell/modules/cibconfig.py	Mon Jun 06 12:53:27 2011 +0200
@@ -1598,28 +1598,29 @@ class CibFactory(Singleton):
 print "Remove queue:"
 for obj in self.remove_queue:
 obj.dump_state()
-def commit(self):
+def commit(self,force = False):
 'Commit the configuration to the CIB.'
 if not self.doc:
 empty_cib_err()
 return False
 # all_committed is updated in the invoked object methods
 self.all_committed = True
-cnt = self.commit_doc()
+cnt = self.commit_doc(force)
 if cnt:
 # reload the cib!
 self.reset()
 self.initialize()
 return self.all_committed
-def commit_doc(self):
+def commit_doc(self,force):
 try:
 conf_node = self.doc.getElementsByTagName("configuration")[0]
 except:
 common_error("cannot find the configuration node")
 return False
-rc = pipe_string("%s -R" % cib_piped, conf_node.toxml())
+cibadmin_opts = force and "-R --force" or "-R"
+rc = pipe_string("%s %s" % (cib_piped,cibadmin_opts), conf_node.toxml())
 if rc != 0:
-update_err("cib",'-R',conf_node.toprettyxml(), rc)
+update_err("cib",cibadmin_opts,conf_node.toprettyxml(), rc)
 return False
 return True
 def mk_shadow(self):
diff -r 954c93bdb8dd -r 35dfe619460d shell/modules/ui.py.in
--- a/shell/modules/ui.py.in	Thu May 26 10:44:28 2011 +0200
+++ b/shell/modules/ui.py.in	Mon Jun 06 12:53:27 2011 +0200
@@ -1533,9 +1533,9 @@ cluster.
 return cib_factory.commit()
 if force or user_prefs.get_force():
 common_info("commit forced")
-return cib_factory.commit()
+return cib_factory.commit(True)
 if ask("Do you still want to commit?"):
-return cib_factory.commit()
+return cib_factory.commit(True)
 return False
 def upgrade(self,cmd,force = None):
 "usage: upgrade [force]"
___
Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
htt

Re: [Pacemaker] Automating Pacemaker Setup

2011-06-06 Thread Dejan Muhamedagic
On Tue, May 31, 2011 at 02:02:38PM +, veghead wrote:
> Dejan Muhamedagic  writes:
> > On Fri, May 27, 2011 at 08:21:08PM +, veghead wrote:
> > > 1) Is there a way to force crm to accept my configuration request 
> > > ~before~ starting the second node?
> > 
> > No before the DC is elected. There are two settings: dc-deadtime
> > and startup-fencing which can reduce the time for DC election.
> > Note that disabling startup fencing is not recommended. But I
> > don't know what's your use case. YMMV.
> 
> Well, I'm probably not quite the typical use case. We're using Amazon EC2 to 
> setup and tear down testing environments. I have automated the entire process 
> except for setting up Pacemaker. Beyond testing environments, I'd like to 
> automate Pacemaker setup to cover the scenario where all nodes in a Pacemaker 
> cluster crash and the entire configuration is lost.
> 
> Obviously, once one node is running, setting up additional nodes becomes 
> easy. 
> It's just the bootstrap phase that's a challenge to automate.
> 
> > > 2) Is there a way to tell Pacemaker to ignore quorum requirements
> > > ~before~ starting additional nodes?
> > > 
> > > 2) Is there an alternate way to configure Pacemaker?
> > 
> > Yes, you can modify the CIB _before_ starting pacemaker. Sth
> > like:
> > 
> > CIB_file=/var/lib/heartbeat/crm/cib.xml crm configure ...
> > 
> > But in that case you need to remove cib.xml.sig. Then you have to
> > make sure that pacemaker starts first on this node. Consider this
> > only if everything else fails.
> 
> I'll give that a shot.

You can also test the attached patch. Either rebuild pacemaker or
apply it to the crm python modules which should be installed in
/usr/lib*/python*/site-packages/crm.

Afterwards, use crm -F or commit force.

Thanks,

Dejan

> Thanks.
> 
> -S
> 
> 
> ___
> Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
> http://oss.clusterlabs.org/mailman/listinfo/pacemaker
> 
> Project Home: http://www.clusterlabs.org
> Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
> Bugs: 
> http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker

___
Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
http://oss.clusterlabs.org/mailman/listinfo/pacemaker

Project Home: http://www.clusterlabs.org
Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
Bugs: http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker


Re: [Pacemaker] Automating Pacemaker Setup

2011-05-31 Thread veghead
Dejan Muhamedagic  writes:
> On Fri, May 27, 2011 at 08:21:08PM +, veghead wrote:
> > 1) Is there a way to force crm to accept my configuration request 
> > ~before~ starting the second node?
> 
> No before the DC is elected. There are two settings: dc-deadtime
> and startup-fencing which can reduce the time for DC election.
> Note that disabling startup fencing is not recommended. But I
> don't know what's your use case. YMMV.

Well, I'm probably not quite the typical use case. We're using Amazon EC2 to 
setup and tear down testing environments. I have automated the entire process 
except for setting up Pacemaker. Beyond testing environments, I'd like to 
automate Pacemaker setup to cover the scenario where all nodes in a Pacemaker 
cluster crash and the entire configuration is lost.

Obviously, once one node is running, setting up additional nodes becomes easy. 
It's just the bootstrap phase that's a challenge to automate.

> > 2) Is there a way to tell Pacemaker to ignore quorum requirements
> > ~before~ starting additional nodes?
> > 
> > 2) Is there an alternate way to configure Pacemaker?
> 
> Yes, you can modify the CIB _before_ starting pacemaker. Sth
> like:
> 
> CIB_file=/var/lib/heartbeat/crm/cib.xml crm configure ...
> 
> But in that case you need to remove cib.xml.sig. Then you have to
> make sure that pacemaker starts first on this node. Consider this
> only if everything else fails.

I'll give that a shot.

Thanks.

-S


___
Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
http://oss.clusterlabs.org/mailman/listinfo/pacemaker

Project Home: http://www.clusterlabs.org
Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
Bugs: http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker


Re: [Pacemaker] Automating Pacemaker Setup

2011-05-31 Thread Dejan Muhamedagic
On Mon, May 30, 2011 at 10:16:12PM +0200, Andrew Beekhof wrote:
> On Mon, May 30, 2011 at 3:59 PM, Dejan Muhamedagic  
> wrote:
> > Hi,
> >
> > On Fri, May 27, 2011 at 08:21:08PM +, veghead wrote:
> >> veghead  writes:
> >> > Todd Nine  writes:
> >> > Wow. The example pacemaker config and the trick of starting
> >> > heartbeat before
> >>
> >> Bah. So close. But I still don't have it completely automated.
> >>
> >> If I start heatbeat on the first node and then run:
> >>
> >> crm configure < myconfigure.txt
> >>
> >> That fails. If I start heartbeat on the second node and wait for the
> >> two nodes to connect to each other (so that we have a quorum), then I
> >> can run "crm configure" and it works.
> >>
> >> So that leaves me with couple questions:
> >>
> >> 1) Is there a way to force crm to accept my configuration request
> >> ~before~ starting the second node?
> >
> > No before the DC is elected.
> 
> Isn't there a force option?  I thought that set the cib_quorum_override flag.

Actually no, the force option only overrides the shell. Of
course, we could add that.

Thanks,

Dejan

> > There are two settings: dc-deadtime
> > and startup-fencing which can reduce the time for DC election.
> > Note that disabling startup fencing is not recommended. But I
> > don't know what's your use case. YMMV.
> >
> >> 2) Is there a way to tell Pacemaker to ignore quorum requirements
> >> ~before~ starting additional nodes?
> >>
> >> 2) Is there an alternate way to configure Pacemaker?
> >
> > Yes, you can modify the CIB _before_ starting pacemaker. Sth
> > like:
> >
> > CIB_file=/var/lib/heartbeat/crm/cib.xml crm configure ...
> >
> > But in that case you need to remove cib.xml.sig. Then you have to
> > make sure that pacemaker starts first on this node. Consider this
> > only if everything else fails.
> >
> > Thanks,
> >
> > Dejan
> >
> >> -Sean
> >>
> >>
> >> ___
> >> Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
> >> http://oss.clusterlabs.org/mailman/listinfo/pacemaker
> >>
> >> Project Home: http://www.clusterlabs.org
> >> Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
> >> Bugs: 
> >> http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker
> >
> > ___
> > Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
> > http://oss.clusterlabs.org/mailman/listinfo/pacemaker
> >
> > Project Home: http://www.clusterlabs.org
> > Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
> > Bugs: 
> > http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker
> >
> 
> ___
> Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
> http://oss.clusterlabs.org/mailman/listinfo/pacemaker
> 
> Project Home: http://www.clusterlabs.org
> Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
> Bugs: 
> http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker

___
Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
http://oss.clusterlabs.org/mailman/listinfo/pacemaker

Project Home: http://www.clusterlabs.org
Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
Bugs: http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker


Re: [Pacemaker] Automating Pacemaker Setup

2011-05-30 Thread Andrew Beekhof
On Mon, May 30, 2011 at 3:59 PM, Dejan Muhamedagic  wrote:
> Hi,
>
> On Fri, May 27, 2011 at 08:21:08PM +, veghead wrote:
>> veghead  writes:
>> > Todd Nine  writes:
>> > Wow. The example pacemaker config and the trick of starting
>> > heartbeat before
>>
>> Bah. So close. But I still don't have it completely automated.
>>
>> If I start heatbeat on the first node and then run:
>>
>> crm configure < myconfigure.txt
>>
>> That fails. If I start heartbeat on the second node and wait for the
>> two nodes to connect to each other (so that we have a quorum), then I
>> can run "crm configure" and it works.
>>
>> So that leaves me with couple questions:
>>
>> 1) Is there a way to force crm to accept my configuration request
>> ~before~ starting the second node?
>
> No before the DC is elected.

Isn't there a force option?  I thought that set the cib_quorum_override flag.

> There are two settings: dc-deadtime
> and startup-fencing which can reduce the time for DC election.
> Note that disabling startup fencing is not recommended. But I
> don't know what's your use case. YMMV.
>
>> 2) Is there a way to tell Pacemaker to ignore quorum requirements
>> ~before~ starting additional nodes?
>>
>> 2) Is there an alternate way to configure Pacemaker?
>
> Yes, you can modify the CIB _before_ starting pacemaker. Sth
> like:
>
> CIB_file=/var/lib/heartbeat/crm/cib.xml crm configure ...
>
> But in that case you need to remove cib.xml.sig. Then you have to
> make sure that pacemaker starts first on this node. Consider this
> only if everything else fails.
>
> Thanks,
>
> Dejan
>
>> -Sean
>>
>>
>> ___
>> Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
>> http://oss.clusterlabs.org/mailman/listinfo/pacemaker
>>
>> Project Home: http://www.clusterlabs.org
>> Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
>> Bugs: 
>> http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker
>
> ___
> Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
> http://oss.clusterlabs.org/mailman/listinfo/pacemaker
>
> Project Home: http://www.clusterlabs.org
> Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
> Bugs: 
> http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker
>

___
Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
http://oss.clusterlabs.org/mailman/listinfo/pacemaker

Project Home: http://www.clusterlabs.org
Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
Bugs: http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker


Re: [Pacemaker] Automating Pacemaker Setup

2011-05-30 Thread Dejan Muhamedagic
Hi,

On Fri, May 27, 2011 at 08:21:08PM +, veghead wrote:
> veghead  writes:
> > Todd Nine  writes:
> > Wow. The example pacemaker config and the trick of starting
> > heartbeat before 
> 
> Bah. So close. But I still don't have it completely automated.
> 
> If I start heatbeat on the first node and then run:
> 
> crm configure < myconfigure.txt
> 
> That fails. If I start heartbeat on the second node and wait for the 
> two nodes to connect to each other (so that we have a quorum), then I 
> can run "crm configure" and it works.
> 
> So that leaves me with couple questions:
> 
> 1) Is there a way to force crm to accept my configuration request 
> ~before~ starting the second node?

No before the DC is elected. There are two settings: dc-deadtime
and startup-fencing which can reduce the time for DC election.
Note that disabling startup fencing is not recommended. But I
don't know what's your use case. YMMV.

> 2) Is there a way to tell Pacemaker to ignore quorum requirements
> ~before~ starting additional nodes?
> 
> 2) Is there an alternate way to configure Pacemaker?

Yes, you can modify the CIB _before_ starting pacemaker. Sth
like:

CIB_file=/var/lib/heartbeat/crm/cib.xml crm configure ...

But in that case you need to remove cib.xml.sig. Then you have to
make sure that pacemaker starts first on this node. Consider this
only if everything else fails.

Thanks,

Dejan

> -Sean
> 
> 
> ___
> Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
> http://oss.clusterlabs.org/mailman/listinfo/pacemaker
> 
> Project Home: http://www.clusterlabs.org
> Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
> Bugs: 
> http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker

___
Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
http://oss.clusterlabs.org/mailman/listinfo/pacemaker

Project Home: http://www.clusterlabs.org
Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
Bugs: http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker


Re: [Pacemaker] Automating Pacemaker Setup

2011-05-27 Thread Mike Caldwell
On Fri, May 27, 2011 at 2:21 PM, veghead  wrote:

> veghead  writes:
> > Todd Nine  writes:
> > Wow. The example pacemaker config and the trick of starting
> > heartbeat before
>
> crm configure < myconfigure.txt
>

I've had to use  crm configure load replace properties_file


> So that leaves me with couple questions:
>
> 2) Is there a way to tell Pacemaker to ignore quorum requirements
> ~before~ starting additional nodes?
>
> Have you tried setting property $id="cib-bootstrap-options"
no-quorum-policy="ignore" ?

2) Is there an alternate way to configure Pacemaker?
>
> cibadmin


> -Sean
>
>
> ___
> Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
> http://oss.clusterlabs.org/mailman/listinfo/pacemaker
>
> Project Home: http://www.clusterlabs.org
> Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
> Bugs:
> http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker
>
___
Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
http://oss.clusterlabs.org/mailman/listinfo/pacemaker

Project Home: http://www.clusterlabs.org
Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
Bugs: http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker


Re: [Pacemaker] Automating Pacemaker Setup

2011-05-27 Thread veghead
veghead  writes:
> Todd Nine  writes:
> Wow. The example pacemaker config and the trick of starting
> heartbeat before 

Bah. So close. But I still don't have it completely automated.

If I start heatbeat on the first node and then run:

crm configure < myconfigure.txt

That fails. If I start heartbeat on the second node and wait for the 
two nodes to connect to each other (so that we have a quorum), then I 
can run "crm configure" and it works.

So that leaves me with couple questions:

1) Is there a way to force crm to accept my configuration request 
~before~ starting the second node?

2) Is there a way to tell Pacemaker to ignore quorum requirements
~before~ starting additional nodes?

2) Is there an alternate way to configure Pacemaker?

-Sean


___
Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
http://oss.clusterlabs.org/mailman/listinfo/pacemaker

Project Home: http://www.clusterlabs.org
Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
Bugs: http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker


Re: [Pacemaker] Automating Pacemaker Setup

2011-05-27 Thread veghead
Todd Nine  writes:

>   I have a setup nearly working.  Would you be willing to share recipes?
...
> It's not quite working yet, but it's close.  Since you've managed to get
> this working, you may be able to finish these off.  I have everything
> working except the init start/stop hooks for pacemaker to set the
> Elastic IP automatically and then run chef-client to reconfigure
> everything on all the other nodes.

Wow. The example pacemaker config and the trick of starting heartbeat before 
using crm configure were the last steps I needed. Thanks!

So, here's how I got Elastic IP failover working. I can't claim credit for the 
idea... I found a basic example here: https://forums.aws.amazon.com/thread.jspa?
messageID=195373. That didn't quite work for me, so I rewrote the LSB script in 
pure ruby and leveraged the amazon-ec2 gem (https://github.com/grempe/amazon-
ec2) to handle associating the EIP with the current instance. I have included 
my 
script below. A couple of key things. 

First, I found that when an instance loses it's elastic ip (whether through 
"disassociate" or another instance grabbed eip), it loses public internet 
connectivity for 1-3 minutes. Apparently this is expected, according to AWS 
Support: https://forums.aws.amazon.com/message.jspa?messageID=250571#250571. As 
a result, I decided it didn't make any sense to have the "stop" method for the 
EIP LSB script do anything.

Second, my Pacemaker configure is pretty close to yours. I setup the nodes with 
ucast in almost the exact same manner. The key differences are all in setting 
up 
the primitives with the correct order and colocation:

primitive elastic_ip lsb:elastic-ip op monitor interval="10s"
primitive haproxy lsb:haproxy op monitor interval="10s"
order haproxy-after-eip inf: elastic_ip haproxy
colocation haproxy-with-eip inf: haproxy elastic_ip

Third, here's my elastic-ip.rb LSB script that handles the Elastic IP. Since 
LSB 
scripts can't take any parameters other than the usual start/stop/status/etc, I 
treat the script as a Chef template and inject the desired EIP into the 
template. The other secret is that I created a special user using AWS IAM with 
a 
policy that only allows the user to associate/disassociate EIP addresses. I 
store the AccessKey and SecretAccessKey in a file in /etc/aws/pacemaker_keys. 

Let me know if you have any questions. And thanks for the tip on using crm to 
initialize pacemaker.

#!/usr/bin/ruby

# Follows the LSB Spec: http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-
generic/LSB-Core-generic/iniscrptact.html

require 'rubygems'
require 'AWS'

ELASTIC_IP="<%= @elastic_ip %>"
EC2_INSTANCE_ID=`wget -T 5 -q -O - http://169.254.169.254/latest/meta-
data/instance-id`

# Load the AWS access keys
properties = {}
File.open("/etc/aws/pacemaker_keys", 'r') do |file|
  file.read.each_line do |line|
line.strip!
if (line[0] != ?# and line[0] != ?=)
  i = line.index('=')
  if (i)
properties[line[0..i - 1].strip] = line[i + 1..-1].strip
  else
properties[line] = ''
  end
end
  end
end
AWS_ACCESS_KEY = properties["AWS_ACCESS_KEY"].delete "\""
AWS_SECRET_ACCESS_KEY = properties["AWS_SECRET_ACCESS_KEY"].strip.delete "\""

[ ELASTIC_IP, EC2_INSTANCE_ID, AWS_ACCESS_KEY, AWS_SECRET_ACCESS_KEY ].each do 
|value|
  if value.nil? || value.length == 0
exit case ARGV[0]
  when "status" then 4
  else 1
end
  end
end

def status(ec2)
  # Typical responses look like the following:
  #   {"requestId"=>"065d1661-31b1-455d-8f63-ba086b8104de", "addressesSet"=>
{"item"=>[{"instanceId"=>"i-22e93a4d", "publicIp"=>"50.19.93.215"}]}, 
"xmlns"=>"http://ec2.amazonaws.com/doc/2010-08-31/"}
  # or
  #   {"requestId"=>"9cd3ab7e-1c03-4821-9565-1791dd1bb0fc", "addressesSet"=>
{"item"=>[{"instanceId"=>nil, "publicIp"=>"174.129.34.161"}]}, 
"xmlns"=>"http://ec2.amazonaws.com/doc/2010-08-31/"}
  response = ec2.describe_addresses({:public_ip => ELASTIC_IP})
  retval = 4
  if ! response.nil?
if ! response["addressesSet"].nil?
  if ! response["addressesSet"]["item"].nil? && response["addressesSet"]
["item"].length >= 1
if response["addressesSet"]["item"][0]["instanceId"] == EC2_INSTANCE_ID
  retval = 0
else
  retval = 3
end
  end
end
  end
  retval
end

def start(ec2)
  # Throws exception if the instance does not exist or the address does not 
belong to us
  retval = 1
  begin
response = ec2.associate_address({ :public_ip => ELASTIC_IP, :instance_id 
=> 
EC2_INSTANCE_ID })
retval = 0
  rescue => e
puts "Error attempting to associate address: " + e
  end
  retval
end

def stop(ec2)
  0
end

def reload(ec2)
  start(ec2)
end

def force_reload(ec2)
  reload(ec2)
end

def restart(ec2)
  start(ec2)
end

def try_restart(ec2)
  start(ec2)
end

ec2 = AWS::EC2::Base.new(:access_key_id => AWS_ACCESS_KEY, :secret_access_key 
=> 
AWS_SECRET_ACCESS_KEY)

retval = case ARGV[0]
  when "status" then status(ec2)
  when "start" then

Re: [Pacemaker] Automating Pacemaker Setup

2011-05-26 Thread Todd Nine
Hey Mate,
  I have a setup nearly working.  Would you be willing to share recipes?
I specifically am trying to get haproxy and NginX ssl termination
running in groups.  1 node runs ha proxy and the other nodes run nginx
for ssl termination.  I've set it up with chef.  It's not quite working
yet, but it's close.  Since you've managed to get this working, you may
be able to finish these off.  I have everything working except the init
start/stop hooks for pacemaker to set the Elastic IP automatically and
then run chef-client to reconfigure everything on all the other nodes.

Todd





On Thu, 2011-05-26 at 22:26 +, veghead wrote:

> Does anyone have any links to documentation on automating Pacemaker setup 
> with 
> tools like Chef or Puppet?
> 
> I have a working two node cluster for HAProxy on EC2, but I'd like to fully 
> automate the setup process for future nodes. Specifically so I can spin up a 
> new 
> instance w/out any manual intervention.
> 
> Thanks.
> 
> 
> ___
> Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
> http://oss.clusterlabs.org/mailman/listinfo/pacemaker
> 
> Project Home: http://www.clusterlabs.org
> Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
> Bugs: 
> http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker


ec2_failover.rb
Description: application/ruby


ec2setip.rb
Description: application/ruby
#Auto generated ha.conf file for all load balancer nodes
udpport 694
use_logd yes
autojoin none
keepalive 2
warntime 5
deadtime 10
initdead 60

<%node[:haproxy][:peers].each_value do |peer| %>
ucast eth0 <%=peer%>
<% end %>

<%node[:haproxy][:peers].each_key do |peer| %>
node <%=peer%>
<% end %>
crm respawn#Turn off stonith, does not apply to our use case
property stonith-enabled=false
property no-quorum-policy=ignore

#Define all the primitives
#primitive haproxy lsb:/etc/init.d/haproxy
#primitive nginx lsb:/etc/init.d/nginx
primitive ec2setip lsb:/etc/init.d/ec2setip

#Group all services together TODO use Collocating to try and offload nginx to 
other 2 nodes
#group proxygroup haproxy nginx ec2setip
 


commit 
___
Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
http://oss.clusterlabs.org/mailman/listinfo/pacemaker

Project Home: http://www.clusterlabs.org
Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
Bugs: http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker


[Pacemaker] Automating Pacemaker Setup

2011-05-26 Thread veghead
Does anyone have any links to documentation on automating Pacemaker setup with 
tools like Chef or Puppet?

I have a working two node cluster for HAProxy on EC2, but I'd like to fully 
automate the setup process for future nodes. Specifically so I can spin up a 
new 
instance w/out any manual intervention.

Thanks.


___
Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
http://oss.clusterlabs.org/mailman/listinfo/pacemaker

Project Home: http://www.clusterlabs.org
Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
Bugs: http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker