Пример #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 *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/"),
	)
}