# somewhat heavily commented so you can make sure
# you've done the prerequisite tasks.

#yum -y groupinstall iSCSI Storage Client

#yum -y groupinstall Storage Availability Tools

# mpathconf --enable --user_friendly_names y --find_multipaths y --with_module y --with_multipathd y --with_chkconfig y

# fix multipath.conf:

# defaults {
# 	find_multipaths yes
# 	user_friendly_names yes
# 	path_selector service-time 0
# 	path_grouping_policy multibus
# }

# blacklist {
# }

# scp the /etc/multipath.conf and /etc/multipath/bindings files
#to each node

# chkconfig multipathd on
# service multipathd restart

#yum -y groupinstall High Availability 
#yum -y groupinstall Resilient Storage

# iscsiadm -m discovery -t sendtargets -p
# iscsiadm -m discovery -t sendtargets -p
# iscsiadm --mode node --targetname iqn.2012-06-16.com.redhat:lady3jane:storage -p -l
# iscsiadm --mode node --targetname iqn.2012-06-16.com.redhat:lady3jane:storage -p -l

#chkconfig ricci on
#echo password | passwd --stdin ricci

# create cluster and add nodes
ccs -h armitage --createcluster summit
ccs -h armitage --addnode armitage.tc.redhat.com
ccs -h armitage --addnode finn.tc.redhat.com
ccs -h armitage --addnode neuromancer.tc.redhat.com
ccs -h armitage --sync --activate
ccs -h armitage --startall

# create storage
# this assumes that /dev/mapper/mpathap1 has already been created

for i in armitage finn neuromancer; do ssh $i lvmconf --enable-cluster; done
pvcreate /dev/mapper/mpathap1
vgcreate -c y vg_cluster /dev/mapper/mpathap1
lvcreate -L 10G -n lv_apache vg_cluster
mkfs.gfs2 -j 4 -O -p lock_dlm -t summit:web /dev/mapper/vg_cluster-lv_apache
ccs -h armitage --addresource clusterfs device=/dev/mapper/vg_cluster-lv_apache force_unmount=on fstype=gfs2 mountpoint=/var/www/html name=web-gfs options=noatime self_fence=on

# add fencing

ccs -h armitage --addmethod power armitage.tc.redhat.com
ccs -h armitage --addmethod power finn.tc.redhat.com
ccs -h armitage --addmethod power neuromancer.tc.redhat.com
ccs -h armitage --addfencedev wti agent=fence_wti ipaddr=wti.tc.redhat.com login=root passwd=red22hat power_wait=5
ccs -h armitage --addfenceinst wti armitage.tc.redhat.com power port=4
ccs -h armitage --addfenceinst wti finn.tc.redhat.com power port=2
ccs -h armitage --addfenceinst wti neuromancer.tc.redhat.com power port=1
ccs -h armitage --setfencedaemon post_fail_delay=5

# add failover domains

ccs -h armitage --addfailoverdomain prefer_armitage restricted ordered
ccs -h armitage --addfailoverdomain prefer_finn restricted ordered
ccs -h armitage --addfailoverdomain prefer_neuromancer restricted ordered
ccs -h armitage --addfailoverdomainnode prefer_armitage armitage.tc.redhat.com 1
ccs -h armitage --addfailoverdomainnode prefer_armitage finn.tc.redhat.com 10
ccs -h armitage --addfailoverdomainnode prefer_armitage neuromancer.tc.redhat.com 20
ccs -h armitage --addfailoverdomainnode prefer_finn finn.tc.redhat.com 1
ccs -h armitage --addfailoverdomainnode prefer_finn neuromancer.tc.redhat.com 10
ccs -h armitage --addfailoverdomainnode prefer_finn armitage.tc.redhat.com 20
ccs -h armitage --addfailoverdomainnode prefer_neuromancer neuromancer.tc.redhat.com 1
ccs -h armitage --addfailoverdomainnode prefer_neuromancer armitage.tc.redhat.com 10
ccs -h armitage --addfailoverdomainnode prefer_neuromancer finn.tc.redhat.com 20

# add resources

ccs -h armitage --addresource ip address= monitor_link=on sleeptime=1
ccs -h armitage --addresource script name=web-script file=/etc/rc.d/init.d/httpd

# add service

ccs -h armitage --addservice web-service domain=prefer_armitage max_restarts=3 name=web-service recovery=restart restart_expire_time=600

# add resources to service

ccs -h armitage --addsubservice web-service ip ref=
ccs -h armitage --addsubservice web-service script ref=web-script
ccs -h armitage --addsubservice web-service clusterfs ref=web-gfs

# sync and activate

ccs -h armitage --sync --activate
ccs -h armitage --startall