Example #1
0
func (m *DebianOneInstallTemplate) Render(pkg urknall.Package) {

	ip := u.IP("")

	pkg.AddCommands("repository",
		u.Shell("wget -q -O- http://downloads.opennebula.org/repo/Debian/repo.key | apt-key add -"),
		u.Shell("echo 'deb http://downloads.opennebula.org/repo/4.14/Debian/8 stable opennebula' > /etc/apt/sources.list.d/opennebula.list"),
		u.UpdatePackagesOmitError(),
	)

	pkg.AddCommands("one-install",
		u.InstallPackages("build-essential autoconf libtool make lvm2 ssh iproute iputils-arping opennebula opennebula-sunstone ntp ruby-dev"),
	)

	pkg.AddCommands("requires",
		u.Shell("echo 'oneadmin ALL = (root) NOPASSWD:ALL' | tee /etc/sudoers.d/oneadmin"),
		u.Shell(" chmod 0440 /etc/sudoers.d/oneadmin"),
		u.Shell(" rm /usr/share/one/install_gems"),
		u.Shell(" cp /usr/share/megam/megdc/conf/install_gems /usr/share/one/install_gems"),
		u.Shell(" chmod 755 /usr/share/one/install_gems"),
		u.Shell("/usr/share/one/install_gems sunstone"),
		u.Shell("sed -i 's/^[ \t]*:host:.*/:host: "+ip+"/' /etc/one/sunstone-server.conf"),
		u.AsUser("oneadmin", u.Shell("echo 'TM_MAD=ssh' >/tmp/ds_tm_mad")),
		u.AsUser("oneadmin", u.Shell("onedatastore update 0 /tmp/ds_tm_mad")),
		u.AsUser("oneadmin", u.Shell("onedatastore update 1 /tmp/ds_tm_mad")),
		u.AsUser("oneadmin", u.Shell("onedatastore update 2 /tmp/ds_tm_mad")),

		u.Shell("sunstone-server start"),
		u.Shell("econe-server start"),
		u.AsUser("oneadmin", u.Shell("one restart")),
		u.Shell("service opennebula restart"),
	)
}
Example #2
0
func (m *DebianCephRemoveTemplate) Render(pkg urknall.Package) {
	host, _ := os.Hostname()

	CephUser := m.cephuser
	pkg.AddCommands("cache-clean",
		u.Shell("rm -r /var/lib/urknall/ceph*"),
	)
	pkg.AddCommands("purgedata",
		u.AsUser(CephUser, u.Shell("ceph-deploy purgedata "+host+"")),
	)
	pkg.AddCommands("forgetKeys",
		u.AsUser(CephUser, u.Shell("ceph-deploy forgetkeys")),
	)
	pkg.AddCommands("purge",
		u.AsUser(CephUser, u.Shell("ceph-deploy purge "+host+"")),
	)
	pkg.AddCommands("rm-sshkey",
		u.AsUser(CephUser, u.Shell("rm -r ~/.ssh")),
	)
	pkg.AddCommands("remove",
		u.Shell("rm -r /var/lib/ceph/"),
		u.Shell("rm -r "+CephUser+"/ceph-cluster"),
		u.Shell("apt-get -y remove ceph-deploy ceph-common ceph-mds"),
		u.Shell("apt-get -y purge ceph-deploy ceph-common ceph-mds"),
		u.Shell("apt-get -y autoremove"),
		u.Shell("rm -r /run/ceph"),
		u.Shell("rm /var/log/upstart/ceph*"),
	)

}
Example #3
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),
	)
}
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)),
	)

}
Example #5
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/"),
	)
}