예제 #1
0
func (m *DebianCephGatewayTemplate) Render(pkg urknall.Package) {
	host, _ := os.Hostname()
	pkg.AddCommands("apache2",
		u.UpdatePackagesOmitError(),
		u.InstallPackages("apache2 libapache2-mod-fastcgi"),
		u.Shell("echo 'ServerName "+host+"' >>/etc/apache2/apache2.conf"),
		u.Shell("sudo a2enmod rewrite"),
		u.Shell("sudo a2enmod fastcgi"),
		u.Shell("service apache2 start"),
	)
	pkg.AddCommands("gateway-daemon",
		u.InstallPackages("radosgw"),
		u.Shell("ceph-authtool --create-keyring /etc/ceph/ceph.client.radosgw.keyring"),
		u.Shell("chmod +r /etc/ceph/ceph.client.radosgw.keyring"),
		u.Shell("ceph-authtool /etc/ceph/ceph.client.radosgw.keyring -n client.radosgw.admin --gen-key"),
		u.Shell("ceph-authtool -n client.radosgw.admin --cap osd 'allow rwx' --cap mon 'allow rwx' /etc/ceph/ceph.client.radosgw.keyring"),
		u.Shell("ceph -k /etc/ceph/ceph.client.admin.keyring auth add client.radosgw.admin -i /etc/ceph/ceph.client.radosgw.keyring"),
	)
	/*	pkg.AddCommands("copy_keyring",
		u.Shell("sudo scp /etc/ceph/ceph.client.radosgw.keyring  "+ USERNAME+"@"+GATEWAY_IP+":/home/ceph"),
		u.Shell("ssh "+ USERNAME+"@"+GATEWAY_IP+" 'sudo mv ceph.client.radosgw.keyring /etc/ceph/ceph.client.radosgw.keyring'"),
	)*/
	pkg.AddCommands("create-osd-pools",
		u.Shell("ceph osd pool create .rgw.buckets 16 16"),
		u.Shell("ceph osd pool create .rgw 16 16"),
		u.Shell("ceph osd pool create .rgw.root 16 16"),
		u.Shell("ceph osd pool create .rgw.control 16 16"),
		u.Shell("ceph osd pool create .rgw.gc 16 16"),
		u.Shell("ceph osd pool create .rgw..buckets.index 16 16"),
		u.Shell("ceph osd pool create .log 16 16"),
		u.Shell("ceph osd pool create .intent-log 16 16"),
		u.Shell("ceph osd pool create .usage 16 16"),
		u.Shell("ceph osd pool create .users 16 16"),
		u.Shell("ceph osd pool create .users.email 16 16"),
		u.Shell("ceph osd pool create .users.swift 16 16"),
		u.Shell("ceph osd pool create .users.uid 16 16"),
		u.Shell("rados lspools"),
	)
	pkg.AddCommands("ceph-conf",
		u.Shell("cat >> /etc/ceph/ceph.conf <<'EOF' "+fmt.Sprintf(Ceph_conf, host)+"EOF"),
		u.Shell("ceph-deploy --overwrite-conf config pull "+host),
		u.Shell("ceph-deploy --overwrite-conf config push "+host),
	)
	/*	pkg.AddCommands("copy_keyring",
		u.Shell("sudo scp /etc/ceph/ceph.client.admin.keyring  "+ USERNAME+"@"+GATEWAY_IP+":/home/"+USERNAME),
		u.Shell("ssh "+ USERNAME+"@"+GATEWAY_IP+" 'sudo mv ceph.client.admin.keyring /etc/ceph/ceph.client.admin.keyring'"),
	)*/
	pkg.AddCommands("Cgi-wrapper",
		u.WriteFile("/var/www/html/s3gw.fcgi", S3gw, "root", 0755),
		u.Mkdir("/var/lib/ceph/radosgw/ceph-radosgw.admin", "", 0755),
		u.Shell("sudo /etc/init.d/radosgw start"),
		u.WriteFile("/etc/apache2/sites-available/rgw.conf", Rgw_conf, "root", 0644),
		u.Shell("sudo a2dissite 000-default"),
		u.Shell("sudo a2ensite rgw.conf"),
		u.Shell("sudo service apache2 restart"),
	)
}
예제 #2
0
func (m *DebianSshPassTemplate) Render(pkg urknall.Package) {

	pkg.AddCommands("install-sshpass",
		u.InstallPackages("sshpass"),
	)
	pkg.AddCommands("SSHPass",
		u.AsUser("oneadmin", u.Shell("sshpass -p 'oneadmin' scp -o StrictHostKeyChecking=no /var/lib/one/.ssh/id_rsa.pub oneadmin@"+m.Host+":/var/lib/one/.ssh/authorized_keys")),
		u.WriteFile("/var/lib/one/.ssh/config", KnownHostsList, "oneadmin", 0755),
	)
}
예제 #3
0
func (m *DebianCephDatastoreTemplate) Render(pkg urknall.Package) {
	Uid := uuid.NewUUID()
	pkg.AddCommands("cephdatastore",
		u.AsUser(Ceph_User, u.Shell("ceph osd pool create "+Poolname+" 150")),
		u.Shell("cd "+UserHomePrefix+Ceph_User+"/ceph-cluster;ceph auth get-or-create client.libvirt mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool="+Poolname+"'"),
		u.Shell("cd "+UserHomePrefix+Ceph_User+"/ceph-cluster;ceph auth get-key client.libvirt | tee client.libvirt.key"),
		u.Shell("cd "+UserHomePrefix+Ceph_User+"/ceph-cluster;ceph auth get client.libvirt -o ceph.client.libvirt.keyring"),
		u.Shell("cd "+UserHomePrefix+Ceph_User+"/ceph-cluster;cp ceph.client.* /etc/ceph"),
		u.Shell("cd "+UserHomePrefix+Ceph_User+"/ceph-cluster; "+fmt.Sprintf(Echo, Uid)+" >uid"),
		u.Shell("echo '*****************************************' "),
		u.Shell(fmt.Sprintf(Echo, Uid)),
		u.Shell("echo '*****************************************' "),
		u.WriteFile(UserHomePrefix+Ceph_User+"/ceph-cluster"+"/secret.xml", fmt.Sprintf(Xml, Uid), "root", 644),
		u.InstallPackages("libvirt-bin"),
		u.Shell("cd "+UserHomePrefix+Ceph_User+"/ceph-cluster;sudo virsh secret-define secret.xml"),
		u.Shell("cd "+UserHomePrefix+Ceph_User+"/ceph-cluster;"+fmt.Sprintf(Setval, Uid)),
	)

}
예제 #4
0
func (m *DebianCephInstallTemplate) Render(pkg urknall.Package) {
	host, _ := os.Hostname()
	ip := u.IP(m.phydev)
	osddir := u.ArraytoString("/", "/osd", m.osds)
	hostosd := u.ArraytoString(host+":/", "/osd", m.osds)
	CephUser := m.cephuser
	CephHome := m.cephhome

	pkg.AddCommands("cephinstall",
		u.Shell("echo deb https://download.ceph.com/debian-infernalis/ jessie main | tee /etc/apt/sources.list.d/ceph.list"),
		u.Shell("wget -q -O- 'https://download.ceph.com/keys/release.asc' | apt-key add -"),
		u.InstallPackages("apt-transport-https  sudo"),
		u.UpdatePackagesOmitError(),
		u.InstallPackages("ceph-deploy ceph-common ceph-mds dnsmasq openssh-server ntp sshpass ceph ceph-mds ceph-deploy radosgw"),
	)

	pkg.AddCommands("cephuser_add",
		u.AddUser(CephUser, false),
	)

	pkg.AddCommands("cephuser_sudoer",
		u.Shell("echo '"+CephUser+" ALL = (root) NOPASSWD:ALL' && mkdir -p /etc/sudoers.d  | tee /etc/sudoers.d/"+CephUser+""),
	)

	pkg.AddCommands("chmod_sudoer",
		u.Shell("chmod 0440 /etc/sudoers.d/"+CephUser+""),
	)

	pkg.AddCommands("etchost",
		u.Shell("echo '"+ip+" "+host+"' >> /etc/hosts"),
	)

	pkg.AddCommands("ssh-keygen",
		u.Mkdir(CephHome+"/.ssh", CephUser, 0700),
		u.AsUser(CephUser, u.Shell("ssh-keygen -N '' -t rsa -f "+CephHome+"/.ssh/id_rsa")),
		u.AsUser(CephUser, u.Shell("cp "+CephHome+"/.ssh/id_rsa.pub "+CephHome+"/.ssh/authorized_keys")),
	)

	pkg.AddCommands("ssh_known_hosts",
		u.WriteFile(CephHome+"/.ssh/ssh_config", StrictHostKey, CephUser, 0755),
		u.WriteFile(CephHome+"/.ssh/config", fmt.Sprintf(SSHHostConfig, host, host, CephUser), CephUser, 0755),
	)

	pkg.AddCommands("mkdir_osd",
		u.Mkdir(osddir, "", 0755),
		u.Shell("sudo chown -R"+CephUser+":"+CephUser+" "+osddir),
	)

	pkg.AddCommands("write_cephconf",
		u.AsUser(CephUser, u.Shell("mkdir "+CephHome+"/ceph-cluster")),
		u.AsUser(CephUser, u.Shell("cd "+CephHome+"/ceph-cluster")),
		u.AsUser(CephUser, u.Shell("cd "+CephHome+"/ceph-cluster;ceph-deploy new "+host+" ")),
		u.AsUser(CephUser, u.Shell("echo 'osd crush chooseleaf type = 0' >> "+CephHome+"/ceph-cluster/ceph.conf")),
		u.AsUser(CephUser, u.Shell("echo 'osd_pool_default_size = 2' >> "+CephHome+"/ceph-cluster/ceph.conf")),
		u.AsUser(CephUser, u.Shell("echo 'mon_pg_warn_max_per_osd = 0' >> "+CephHome+"/ceph-cluster/ceph.conf")),
		u.AsUser(CephUser, u.Shell("cd "+CephHome+"/ceph-cluster;ceph-deploy install "+host+"")),
		u.AsUser(CephUser, u.Shell("cd "+CephHome+"/ceph-cluster;ceph-deploy mon create-initial | ceph-deploy mon create-initial")),
		u.AsUser(CephUser, u.Shell("cd "+CephHome+"/ceph-cluster;ceph-deploy osd prepare "+hostosd)),
		u.AsUser(CephUser, u.Shell("cd "+CephHome+"/ceph-cluster;ceph-deploy osd activate "+hostosd)),
		u.AsUser(CephUser, u.Shell("cd "+CephHome+"/ceph-cluster;ceph-deploy admin "+host+"")),
		u.AsUser(CephUser, u.Shell("chmod +r /etc/ceph/ceph.client.admin.keyring")),
		u.AsUser(CephUser, u.Shell("sleep 180")),
		u.AsUser(CephUser, u.Shell("ceph osd pool set rbd pg_num 150")),
		u.AsUser(CephUser, u.Shell("sleep 180")),
		u.AsUser(CephUser, u.Shell("ceph osd pool set rbd pgp_num 150")),
	)
	pkg.AddCommands("copy_keyring",
		u.Shell("cp "+CephHome+"/ceph-cluster/*.keyring /etc/ceph/"),
	)
}