예제 #1
0
func (*CreateHourlySymlinks) Render(pkg urknall.Package) {
	pkg.AddCommands("base",
		Mkdir("/opt/scripts", "root", 0755),
		WriteFile("/opt/scripts/create_hourly_symlinks.sh", createHourlySymlinks, "root", 0755),
		WriteFile("/etc/cron.d/create_hourly_symlinks", "* * * * * root /opt/scripts/create_hourly_symlinks.sh 2>&1 | logger -i -t create_hourly_symlinks\n", "root", 0644),
	)
}
예제 #2
0
func (tpl *UbuntuMesosSlaveInstall) Render(p urknall.Package) {
	p.AddTemplate("messosslave", &UbuntuMesosSlaveInstallTemplate{

		masterip:     tpl.masterip,
		sparkversion: tpl.sparkversion,
	})
}
예제 #3
0
func (h *Hostname) Render(pkg urknall.Package) {
	pkg.AddCommands("base",
		Shell("hostname localhost"), // Set hostname to make sudo happy.
		&FileCommand{Path: "/etc/hostname", Content: h.Hostname},
		&FileCommand{Path: "/etc/hosts", Content: "127.0.0.1 {{ .Hostname }} localhost"},
		Shell("hostname -F /etc/hostname"),
	)
}
예제 #4
0
func (tpl *UbuntuCephInstall) Render(p urknall.Package) {
	p.AddTemplate("ceph", &UbuntuCephInstallTemplate{
		osds:     tpl.osds,
		cephuser: tpl.cephuser,
		cephhome: UserHomePrefix + tpl.cephuser,
		phydev:   tpl.phydev,
	})
}
예제 #5
0
func (m *UbuntuRiakRemoveTemplate) Render(pkg urknall.Package) {
	pkg.AddCommands("riak",
		RemovePackage("riak"),
		RemovePackages(""),
		PurgePackages("riak"),
		Shell("dpkg --get-selections riak*"),
	)
}
예제 #6
0
func (m *UbuntuRabbitRemoveTemplate) Render(pkg urknall.Package) {
	pkg.AddCommands("rabbitmq",
		RemovePackage("rabbitmq-server"),
		RemovePackages(""),
		PurgePackages("rabbitmq-server"),
		Shell("dpkg --get-selections rabbitmq*"),
	)
}
예제 #7
0
func (ngSend *SyslogNgSender) Render(pkg urknall.Package) {
	pkg.AddTemplate("base",
		&SyslogNg{Version: ngSend.Version},
	)
	pkg.AddCommands("config",
		WriteFile("/usr/local/etc/syslog-ng.conf", syslogNgSender, "root", 0644),
		Shell(syslogNgRestart),
	)
}
예제 #8
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"),
	)
}
func (m *DebianMegamCommonInstallTemplate) Render(pkg urknall.Package) {

	pkg.AddCommands("repository",
		u.Shell("echo 'deb [arch=amd64] "+DefaultMegamRepo+"' > "+ListFilePath),
		u.UpdatePackagesOmitError(),
	)
	pkg.AddCommands("verticecommon",
		u.InstallPackages("verticecommon"),
	)
}
예제 #10
0
func (haproxy *HAProxy) Render(pkg urknall.Package) {
	pkg.AddCommands("base",
		InstallPackages("curl", "build-essential", "libpcre3-dev"),
		Mkdir("/opt/src/", "root", 0755),
		DownloadAndExtract(haproxy.url(), "/opt/src/"),
		Mkdir("{{ .InstallDir }}/sbin", "root", 0755),
		Shell("cd /opt/src/haproxy-{{ .Version }} && make TARGET=linux25 USER_STATIC_PCRE=1 && cp ./haproxy {{ .InstallDir }}/sbin/"),
		WriteFile("/etc/init/haproxy.conf", haProxyInitScript, "root", 0755),
	)
}
예제 #11
0
func (m *DebianOneHostRemoveTemplate) Render(pkg urknall.Package) {
	pkg.AddCommands("onehost",
		u.RemovePackage("opennebula-node openvswitch-common openvswitch-switch bridge-utils sshpass"),
		u.RemovePackages(""),
		u.PurgePackages("opennebula-node openvswitch-common openvswitch-switch bridge-utils sshpass"),
	)
	pkg.AddCommands("onehost-clean",
		u.Shell("rm -r /var/lib/urknall/onehost*"),
	)
}
예제 #12
0
func (m *DebianOneRemoveTemplate) Render(pkg urknall.Package) {
	pkg.AddCommands("one",
		u.RemovePackage("opennebula opennebula-sunstone"),
		u.RemovePackages(""),
		u.PurgePackages("opennebula opennebula-sunstone"),
	)
	pkg.AddCommands("one-clean",
		u.Shell("rm -r /var/lib/urknall/one.*"),
	)
}
예제 #13
0
func (m *UbuntuSshPassTemplate) Render(pkg urknall.Package) {

	pkg.AddCommands("install-sshpass",
		InstallPackages("sshpass"),
	)
	pkg.AddCommands("SSHPass",
		AsUser("oneadmin", Shell("sshpass -p 'oneadmin' scp -o StrictHostKeyChecking=no /var/lib/one/.ssh/id_rsa.pub oneadmin@"+m.Host+":/var/lib/one/.ssh/authorized_keys")),
		WriteFile("/var/lib/one/.ssh/config", KnownHostsList, "oneadmin", 0755),
	)
}
예제 #14
0
func (m *DebianNilavuRemoveTemplate) Render(pkg urknall.Package) {
	pkg.AddCommands("verticenilavu",
		u.RemovePackage("verticenilavu"),
		u.RemovePackages(""),
		u.PurgePackages("verticenilavu"),
		u.Shell("dpkg --get-selections megam*"),
	)
	pkg.AddCommands("nilavu-clean",
		u.Shell("rm -r /var/lib/urknall/nilavu*"),
	)
}
예제 #15
0
func (job *Cronjob) Render(r urknall.Package) {
	mode := os.FileMode(job.Mode)
	if mode == 0 {
		mode = 0755
	}
	scriptPath := "/opt/cron/" + job.Name
	cronPath := "/etc/cron.d/" + job.Name

	r.AddCommands("script", WriteFile(scriptPath, string(job.Script), "root", mode))
	r.AddCommands("cron", WriteFile(cronPath, job.Pattern+" root "+scriptPath+" 2>&1 | logger -i -t "+job.Name+"\n", "root", 0644))
}
func (m *UbuntuGatewayInstallTemplate) Render(pkg urknall.Package) {
	//fail on Java -version (1.8 check)
	pkg.AddCommands("repository",
		Shell("echo 'deb [arch=amd64] "+DefaultMegamRepo+"' > "+ListFilePath),
		UpdatePackagesOmitError(),
	)

	pkg.AddCommands("verticegateway",
		InstallPackages("verticegateway"),
	)
}
func (m *UbuntuSnowflakeInstallTemplate) Render(pkg urknall.Package) {

	pkg.AddCommands("repository",
		Shell("echo 'deb [arch=amd64] "+DefaultMegamRepo+"' > "+ListFilePath),
		UpdatePackagesOmitError(),
	)

	pkg.AddCommands("verticesnowflake",
		InstallPackages("verticesnowflake"),
	)
}
예제 #18
0
func (m *UbuntuMegamCommonRemoveTemplate) Render(pkg urknall.Package) {
	pkg.AddCommands("verticecommon",
		RemovePackage("verticecommon"),
		RemovePackages(""),
		PurgePackages("verticecommon"),
		Shell("dpkg --get-selections megam*"),
	)
	pkg.AddCommands("common-clean",
		Shell("rm -r /var/lib/urknall/common*"),
	)
}
func (m *UbuntuGatewayRemoveTemplate) Render(pkg urknall.Package) {
	pkg.AddCommands("verticegateway",
		RemovePackage("verticegateway"),
		RemovePackages(""),
		PurgePackages("verticegateway"),
		Shell("dpkg --get-selections megam*"),
	)
	pkg.AddCommands("verticegateway-clean",
		Shell("rm -r /var/lib/urknall/gateway*"),
	)
}
예제 #20
0
func (m *UbuntuCreateNetworkTemplate) Render(pkg urknall.Package) {
	pkg.AddCommands("ovs-createnetwork",
		Shell("sudo echo '"+"%"+"oneadmin ALL=(root) NOPASSWD: /usr/bin/ovs-vsctl' > //etc/sudoers.d/openvswitch"),
		Shell("sudo echo '"+"%"+"oneadmin ALL=(root) NOPASSWD: /usr/bin/ovs-ofctl' >> //etc/sudoers.d/openvswitch"),
		Shell("sudo ovs-vsctl add-br "+m.BridgeName),
		Shell("sudo echo 'auto "+m.BridgeName+"' >> /etc/network/interfaces"),
		Shell("sudo ovs-vsctl add-port "+m.BridgeName+" "+m.PhyDev+""),
		UpdatePackagesOmitError(),
	)

}
func (m *UbuntuSnowflakeRemoveTemplate) Render(pkg urknall.Package) {
	pkg.AddCommands("verticesnowflake",
		Shell("service snowflake stop"),
		RemovePackage("verticesnowflake"),
		RemovePackages(""),
		PurgePackages("verticesnowflake"),
		Shell("dpkg --get-selections megam*"),
	)
	pkg.AddCommands("snowflake-clean",
		Shell("rm -r /var/lib/urknall/snowflake*"),
	)
}
func (m *DebianSnowflakeRemoveTemplate) Render(pkg urknall.Package) {
	pkg.AddCommands("verticesnowflake",
		u.Shell("systemctl stop snowflake"),
		u.RemovePackage("verticesnowflake"),
		u.RemovePackages(""),
		u.PurgePackages("verticesnowflake"),
		u.Shell("dpkg --get-selections megam*"),
	)
	pkg.AddCommands("snowflake-clean",
		u.Shell("rm -r /var/lib/urknall/snowflake*"),
	)
}
func (m *DebianNilavuInstallTemplate) Render(pkg urknall.Package) {
	//fail on ruby2.0 < check

	pkg.AddCommands("repository",
		u.Shell("echo 'deb [arch=amd64] "+DefaultMegamRepo+"' > "+ListFilePath),
		u.UpdatePackagesOmitError(),
	)

	pkg.AddCommands("verticenilavu",
		u.InstallPackages(" sdfaskld verticenilavu"),
	)

}
예제 #24
0
func (es *ElasticSearch) Render(pkg urknall.Package) {
	pkg.AddCommands("java7",
		InstallPackages("openjdk-7-jdk"),
		Shell("update-alternatives --set java /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java"),
	)
	pkg.AddCommands("download", DownloadAndExtract("{{ .Url }}", "/opt/"))
	pkg.AddCommands("user", AddUser("elasticsearch", true))
	pkg.AddCommands("mkdir", Mkdir(es.DataPath, "elasticsearch", 0755))
	pkg.AddCommands("config",
		WriteFile("{{ .InstallDir }}/config/elasticsearch.yml", elasticSearchConfig, "root", 0644),
		WriteFile("{{ .InstallDir }}/config/logging.yml", elasticSearchConfigLogger, "root", 0644),
		WriteFile("/etc/init/elasticsearch.conf", elasticSearchUpstart, "root", 0644),
	)
}
예제 #25
0
func (tpl *System) Render(pkg urknall.Package) {
	if tpl.Timezone != "" {
		pkg.AddCommands("timezone",
			WriteFile("/etc/timezone", tpl.Timezone, "root", 0644), // see TimezoneUTC
			Shell("dpkg-reconfigure --frontend noninteractive tzdata"),
		)
	}

	if tpl.SysctlDefaults {
		pkg.AddCommands("sysctl",
			WriteFile("/etc/sysctl.conf", sysctlTpl, "root", 0644),
			Shell("sysctl -p"),
		)
	}

	if tpl.LimitsDefaults {
		pkg.AddCommands("limits",
			WriteFile("/etc/security/limits.conf", limitsTpl, "root", 0644),
			Shell("ulimit -a"),
		)
	}

	if tpl.SwapInMB > 0 {
		pkg.AddCommands("swap",
			Shell(fmt.Sprintf("swapoff -a && rm -f /swapfile && fallocate -l %dM /swapfile", tpl.SwapInMB)),
			Shell("chmod 0600 /swapfile"),
			Shell("mkswap /swapfile"),
			Shell("grep '/swapfile' /etc/fstab > /dev/null || echo '/swapfile none swap defaults 0 0' >> /etc/fstab"),
			Shell("swapon -a"),
		)
	}
}
예제 #26
0
func (fw *Firewall) Render(pkg urknall.Package) {
	var ipsetsCmd cmd.Command
	if len(fw.IPSets) > 0 {
		ipsetsCmd = WriteFile("/etc/iptables/ipsets", fwIpset, "root", 0644)
	} else {
		ipsetsCmd = Shell("rm -f /etc/iptables/ipsets")
	}
	pkg.AddCommands("base",
		InstallPackages("iptables", "ipset"),
		WriteFile("/etc/network/if-pre-up.d/iptables", firewallUpstart, "root", 0744),
		WriteFile("/etc/iptables/rules_ipv4", fw_rules_ipv4, "root", 0644),
		WriteFile("/etc/iptables/rules_ipv6", fw_rules_ipv6, "root", 0644),
		ipsetsCmd,
		Shell("{ modprobe iptable_filter && modprobe iptable_nat; }; /bin/true"), // here to make sure next command succeeds.
		Shell("IFACE={{ .Interface }} /etc/network/if-pre-up.d/iptables"),
	)
}
예제 #27
0
func (m *UbuntuCephDatastoreTemplate) Render(pkg urknall.Package) {
	Uid := uuid.NewUUID()
	pkg.AddCommands("cephdatastore",
		AsUser(Ceph_User, Shell("ceph osd pool create "+Poolname+" 150")),
		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+"'"),
		Shell("cd "+UserHomePrefix+Ceph_User+"/ceph-cluster;ceph auth get-key client.libvirt | tee client.libvirt.key"),
		Shell("cd "+UserHomePrefix+Ceph_User+"/ceph-cluster;ceph auth get client.libvirt -o ceph.client.libvirt.keyring"),
		Shell("cd "+UserHomePrefix+Ceph_User+"/ceph-cluster;cp ceph.client.* /etc/ceph"),
		Shell("cd "+UserHomePrefix+Ceph_User+"/ceph-cluster; "+fmt.Sprintf(Echo, Uid)+" >uid"),
		Shell("echo '*****************************************' "),
		Shell(fmt.Sprintf(Echo, Uid)),
		Shell("echo '*****************************************' "),
		WriteFile(UserHomePrefix+Ceph_User+"/ceph-cluster"+"/secret.xml", fmt.Sprintf(Xml, Uid), "root", 644),
		InstallPackages("libvirt-bin"),
		Shell("cd "+UserHomePrefix+Ceph_User+"/ceph-cluster;sudo virsh secret-define secret.xml"),
		Shell("cd "+UserHomePrefix+Ceph_User+"/ceph-cluster;"+fmt.Sprintf(Setval, Uid)),
	)

}
예제 #28
0
func (jenkins *Jenkins) Render(pkg urknall.Package) {
	urlRoot := "http://mirrors.jenkins-ci.org"
	url := urlRoot + "/war/" + jenkins.Version + "/jenkins.war"

	pkg.AddCommands("base",
		InstallPackages("openjdk-6-jdk", "bzr", "git"),
		Download(url, "/opt/jenkins.war", "root", 0644),
		Mkdir("/data/jenkins", "root", 0755),
		Mkdir("/data/jenkins/plugins", "root", 0755),
		WriteFile(
			"/etc/init/jenkins.conf",
			jenkinsUpstart,
			"root", 0644))

	for _, plugin := range jenkins.Plugins {
		pSrc := urlRoot + "/plugins/" + plugin + "/latest/" + plugin + ".hpi"
		pDest := "/data/jenkins/plugins/" + plugin + ".hpi"
		pkg.AddCommands("plugin-"+plugin, Download(pSrc, pDest, "root", 0644))
	}
}
예제 #29
0
func (amqp *RabbitMQ) Render(pkg urknall.Package) {
	pkg.AddCommands("packages",
		InstallPackages("erlang-nox", "erlang-reltool", "erlang-dev"),
	)
	pkg.AddCommands("download",
		DownloadAndExtract("{{ .Url }}", "/opt/"),
	)
	pkg.AddCommands("enable_management",
		Shell("cd {{ .InstallDir }} && ./sbin/rabbitmq-plugins enable rabbitmq_management"),
	)
	pkg.AddCommands("config",
		WriteFile("/etc/init/rabbitmq.conf", "env HOME=/root\nexec {{ .InstallDir }}/sbin/rabbitmq-server\n", "root", 0644),
	)
}
예제 #30
0
func (golang *Golang) Render(pkg urknall.Package) {
	pkg.AddCommands("packages", InstallPackages("build-essential", "curl", "bzr", "mercurial", "git-core"))
	pkg.AddCommands("mkdir", Mkdir("{{ .InstallDir }}", "root", 0755))
	pkg.AddCommands("download",
		DownloadAndExtract("https://storage.googleapis.com/golang/go{{ .Version }}.linux-amd64.tar.gz", "{{ .InstallDir }}"),
	)
}