From: Stephen Soltesz Date: Sun, 15 May 2011 03:19:35 +0000 (+0000) Subject: Add spec file for basic puppet configuration on client & server X-Git-Url: http://git.onelab.eu/?p=myops.git;a=commitdiff_plain;h=2b8bf09f10cc0b44bb341c661230cf6de38e48fd Add spec file for basic puppet configuration on client & server includes basic node_classifier configuration includes autosign setup from plc nodes fixed author --- diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3e7a7d6 --- /dev/null +++ b/Makefile @@ -0,0 +1,39 @@ +# $Id$ +CURL := curl -H Pragma: -O -R -S --fail --show-error +SHA1SUM = sha1sum + +# default - overridden by the build +SPECFILE = myops.spec + +#main.URL := http://build.planet-lab.org/third-party/zabbix-1.6.2.tar.gz +#main.SHA1SUM := 575c443adec1703c2c242dbf353de9dc3bb4cafb +main.FILE := myops-1.0.tar.bz2 + +# Thierry - when called from within the build, PWD is /build +SOURCEFILES := $(main.FILE) + +$(main.FILE): #FORCE + rm -f myops-1.0.tar.bz2 + tar -jchvf myops-1.0.tar.bz2 -C ../ myops-1.0 + @echo "hello" + +sources: $(SOURCEFILES) +.PHONY: sources + +PWD=$(shell pwd) +PREPARCH ?= noarch +RPMDIRDEFS = --define "_sourcedir $(PWD)" --define "_builddir $(PWD)" --define "_srcrpmdir $(PWD)" --define "_rpmdir $(PWD)" + +trees: sources + rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps -bp --target $(PREPARCH) $(SPECFILE) + +srpm: sources + rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps -bs $(SPECFILE) + +TARGET ?= $(shell uname -m) +rpm: sources + rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps --target $(TARGET) -bb $(SPECFILE) + +clean: + rm -f *.rpm *.tgz *.bz2 *.gz + rm *.pyc *.dat *.log diff --git a/myops.spec b/myops.spec new file mode 100644 index 0000000..9647ed4 --- /dev/null +++ b/myops.spec @@ -0,0 +1,113 @@ +# +# $Id$ +# + +%define url $URL: git://git.planet-lab.org/myops.git$ + +%define name myops +# keep this version in sync with monitor/monitor_version.py +%define version 1.0 +%define taglevel 0 + +%define release %{taglevel}%{?pldistro:.%{pldistro}}%{?date:.%{date}} +%global python_sitearch %( python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)" ) + +Name: %{name} +Version: %{version} +Release: %{release} +Source0: %{name}-%{version}.tar.bz2 +License: GPL +Group: Applications/System +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot + +Vendor: PlanetLab +Packager: PlanetLab Central +Distribution: PlanetLab %{plrelease} +URL: %(echo %{url} | cut -d ' ' -f 2) + + +Summary: MyOps operational packages. +Group: Applications/System + +%description +MyOps is a collection of support services and scripts for operating a MyPLC +deployment. + +%package client +Summary: MyOps for client +Group: Applications/System + +Requires: puppet +Requires: coreutils + +%description client +Client side configuration. + +######################################## Server +%package server +Summary: MyOps the server side +Group: Applications/System + +Requires: puppet-server +Requires: puppet +Requires: coreutils + +%description server +Server side services + +%prep +%setup -q + +%install +rm -rf $RPM_BUILD_ROOT + + +#################### SERVER +echo "Reminder: open ports 8139,8140,8141 in iptables" +install -d $RPM_BUILD_ROOT/usr/share/%{name} +install -d $RPM_BUILD_ROOT/etc/puppet/manifests +install -d $RPM_BUILD_ROOT/etc/puppet/bin +install -d $RPM_BUILD_ROOT/etc/cron.hourly +install -d $RPM_BUILD_ROOT/var/lib/puppet + +rsync -a ./puppet $RPM_BUILD_ROOT/usr/share/myops/ + +# Generate an autosign list from plc node hostnames +install -D -m 755 puppet/cron.d/autosign.plcsh $RPM_BUILD_ROOT/%{_sysconfdir}/cron.hourly/ +install -D -m 755 puppet/server/bin/node_classifier $RPM_BUILD_ROOT/%{_sysconfdir}/puppet/bin/ +install -D -m 644 puppet/server/manifests/site.pp $RPM_BUILD_ROOT/%{_sysconfdir}/puppet/manifests/ +install -D -m 644 puppet/server/puppetmaster.conf $RPM_BUILD_ROOT/%{_sysconfdir}/puppet/ +install -D -m 644 puppet/client/hardcoded.conf $RPM_BUILD_ROOT/%{_sysconfdir}/puppet + +rsync -ar ./puppet/server/modules $RPM_BUILD_ROOT/%{_sysconfdir}/puppet/ + + +%clean +rm -rf $RPM_BUILD_ROOT + +%files puppet-server +%defattr(-,root,root) +/%{_sysconfdir}/cron.hourly/autosign.plcsh +/%{_sysconfdir}/puppet/bin/node_classifier +/%{_sysconfdir}/puppet/manifests/site.pp +/%{_sysconfdir}/puppet/puppetmaster.conf +/%{_sysconfdir}/puppet/modules + +%files puppet-client +%defattr(-,root,root) +/%{_sysconfdir}/puppet/hardcoded.conf +/usr/share/%{name} + +%post server +chkconfig --add puppetmaster +chkconfig puppetmaster on + +%post client +chkconfig --add puppet +chkconfig puppet on + +cat /etc/puppet/hardcoded.conf >> /etc/puppet/puppet.conf + + +%changelog +%define module_current_branch 1.0 diff --git a/puppet/client/hardcoded.conf b/puppet/client/hardcoded.conf new file mode 100644 index 0000000..a54ef11 --- /dev/null +++ b/puppet/client/hardcoded.conf @@ -0,0 +1,9 @@ +[puppetd] + server = myops.planet-lab.org + ca_server = myops.planet-lab.org + report_server = myops.planet-lab.org + reportserver = myops.planet-lab.org + mkusers = true + report = true + factsync = false + diff --git a/puppet/cron.d/autosign.plcsh b/puppet/cron.d/autosign.plcsh new file mode 100755 index 0000000..fb61179 --- /dev/null +++ b/puppet/cron.d/autosign.plcsh @@ -0,0 +1,14 @@ +#!/usr/bin/env plcsh +# create /etc/puppet/autosign.conf +# list of nodes from which puppetmaster should automatically sign + +import os + +nodes = GetNodes({'peer_id' : None}) +f = open('/etc/puppet/autosign.conf.pre', 'w') +for n in nodes: + print >>f, n['hostname'] + +f.close() +os.rename('/etc/puppet/autosign.conf.pre', '/etc/puppet/autosign.conf') + diff --git a/puppet/server/bin/node_classifier b/puppet/server/bin/node_classifier new file mode 100755 index 0000000..efb80d3 --- /dev/null +++ b/puppet/server/bin/node_classifier @@ -0,0 +1,22 @@ +#!/usr/bin/env plcsh +# -*-python-*- + +# Super-simple external_node script for versions 0.23 and later +import sys +try: + n = GetNodes(sys.argv[1]) +except: + pass + +if True: + print """ +--- +classes: + - puppet_config + - planetlab_node +parameters: + puppet_server: myops.planet-lab.org + +""" + +sys.exit(0) diff --git a/puppet/server/manifests/site.pp b/puppet/server/manifests/site.pp new file mode 100644 index 0000000..66274d0 --- /dev/null +++ b/puppet/server/manifests/site.pp @@ -0,0 +1,50 @@ + +# Define the bucket for backups +filebucket { main: + server => "myops.planet-lab.org" +} + +# And, specify it as the default target +File { backup => main } + +class planetlab_node { + file { "/tmp/puppet_setup_blue": + ensure => present, + mode => 644, + owner => root, + group => root, + } + + file { "/etc/planetlab/plc_config": + ensure => present, + mode => 644, + backup => main, + } + + file { "/usr/bin/cleanrpm.sh": + source => "puppet:///sample/cleanrpm.sh", + ensure => present, + mode => 755, + } + + exec { "/usr/bin/cleanrpm.sh": + onlyif => "test `pgrep \"rpm|yum\" | wc -l` -gt 0", + creates => "/tmp/cleanrpm.log", + path => ["/bin", "/usr/bin", "/usr/sbin"], + } +} + +class puppet_config { + + package { 'ruby-rdoc': + ensure => installed, + } + + file { "/etc/puppet/puppet.conf": + source => "puppet:///sample/puppet.conf", + ensure => present, + mode => 644, + } +} + + diff --git a/puppet/server/modules/sample/files/cleanrpm.sh b/puppet/server/modules/sample/files/cleanrpm.sh new file mode 100755 index 0000000..3273582 --- /dev/null +++ b/puppet/server/modules/sample/files/cleanrpm.sh @@ -0,0 +1,3 @@ +#!/bin/bash +echo `date` >> /tmp/cleanrpm.log +echo "this is a test" diff --git a/puppet/server/modules/sample/files/puppet.conf b/puppet/server/modules/sample/files/puppet.conf new file mode 100644 index 0000000..f3d8ea9 --- /dev/null +++ b/puppet/server/modules/sample/files/puppet.conf @@ -0,0 +1,33 @@ +[main] + # Where Puppet stores dynamic and growing data. + vardir = /var/lib/puppet + # The Puppet log directory. + logdir = /var/log/puppet + # Where Puppet PID files are kept. + rundir = /var/run/puppet + + # Where SSL certificates are kept. + # The default value is '$confdir/ssl'. + ssldir = $vardir/ssl + +[puppetd] + # The file in which puppetd stores a list of the classes + # associated with the retrieved configuratiion. Can be loaded in + # the separate ``puppet`` executable using the ``--loadclasses`` + # option. + # The default value is '$confdir/classes.txt'. + classfile = $vardir/classes.txt + + # Where puppetd caches the local configuration. An + # extension indicating the cache format is added automatically. + # The default value is '$confdir/localconfig'. + localconfig = $vardir/localconfig + + server = myops.planet-lab.org + ca_server = myops.planet-lab.org + report_server = myops.planet-lab.org + reportserver = myops.planet-lab.org + mkusers = true + report = true +# factsync = true + diff --git a/puppet/server/puppetmaster.conf b/puppet/server/puppetmaster.conf new file mode 100644 index 0000000..35fc045 --- /dev/null +++ b/puppet/server/puppetmaster.conf @@ -0,0 +1,3 @@ +[main] + external_nodes = /etc/puppet/bin/node_classifier + node_terminus = exec