Konfigurationsmanagement PuppetSpec
From NJH-Wiki
Spec Datei um Puppet als Client mit Init Script zu installieren. Die auskommentierten Zeilen dienen hauptsächlich um Puppet als Server zu installieren:
%{!?ruby_sitelibdir: %define ruby_sitelibdir %(ruby -rrbconfig -e 'puts Config::CONFIG["sitelibdir"]')}
%define pbuild %{_builddir}/%{name}-%{version}
%define confdir conf/redhat
%define has_ruby_abi 0%{?fedora:%fedora} >= 5 || 0%{?rhel:%rhel} >= 5
%define has_ruby_noarch %has_ruby_abi
Wir definieren, dass wir nur den Client installieren wollen:
%define _with_server 0
Nun eine Zusammenfassung um welches Programm es eigentlich geht. Das Release habe ich auf zwei gesetzt, damit deutlich wird, dass Änderungen seit dem vorherigen Release vorgenommen wurden.
Summary: A Network Tool for Managing Many Disparate Systems
Name: puppet
Version: 0.22.3
Release: 2%{?dist}
License: GPL
Group: System Environment/Base
Hier habe ich das Init Script als neue Quelle hinzugefügt:
URL: http://reductivelabs.com/projects/puppet/
Source: http://reductivelabs.com/downloads/puppet/%{name}-%{version}.tgz
Source1: puppet.init
Das wird vom Paket benötigt:
Requires: ruby >= 1.8.1
%if %has_ruby_abi
Requires: ruby(abi) = 1.8
%endif
Requires: facter >= 1.1.4
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-build
%if %has_ruby_noarch
BuildArchitectures: noarch
%endif
BuildRequires: ruby >= 1.8.1
%description
Puppet lets you centrally manage every important aspect of your system using a
cross-platform specification language that manages all the separate elements
normally aggregated in different files, like users, cron jobs, and hosts,
along with obviously discrete elements like packages, services, and files.
%if "%{_with_server}" == "1"
%package server
Group: System Environment/Base
Summary: Server for the puppet system management tool
Requires: puppet = %{version}-%{release}
%description server
Provides the central puppet server daemon which provides manifests to clients.
The server can also function as a certificate authority and file server.
%endif
%prep
%setup -q
%build
for f in bin/* ; do
sed -i -e '1c#!/usr/bin/ruby' $f
done
Der eigentliche Installationsprozess beginnt:
%install
%{__rm} -rf %{buildroot}
%{__install} -d -m0755 %{buildroot}%{_sbindir}
%{__install} -d -m0755 %{buildroot}%{_bindir}
%{__install} -d -m0755 %{buildroot}%{ruby_sitelibdir}
%if "%{_with_server}" == "1"
%{__install} -d -m0755 %{buildroot}%{_sysconfdir}/%{name}/manifests
%endif
%{__install} -d -m0755 %{buildroot}%{_docdir}/%{name}-%{version}
%{__install} -d -m0755 %{buildroot}%{_localstatedir}/lib/%{name}
%{__install} -d -m0755 %{buildroot}%{_localstatedir}/run/%{name}
%{__install} -d -m0755 %{buildroot}%{_localstatedir}/log/%{name}
%{__install} -Dp -m0755 %{pbuild}/bin/* %{buildroot}%{_sbindir}
%{__mv} %{buildroot}%{_sbindir}/%{name} %{buildroot}%{_bindir}/%{name}
%if "%{_with_server}" == "1"
%{__mv} %{buildroot}%{_sbindir}/puppetrun %{buildroot}%{_bindir}/puppetrun
%endif
%{__install} -Dp -m0644 %{pbuild}/lib/puppet.rb %{buildroot}%{ruby_sitelibdir}/puppet.rb
%{__cp} -a %{pbuild}/lib/puppet %{buildroot}%{ruby_sitelibdir}
find %{buildroot}%{ruby_sitelibdir} -type f -perm +ugo+x -print0 | xargs -0 -r %{__chmod} a-x
%{__install} -Dp -m0644 %{confdir}/client.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/%{name}
Das sind die Anweisungen um das Init Script auch zu installieren:
# installation of external init script
%{__install} -d -m0755 %{buildroot}%{_initrddir}
%{__install} -Dp -m0755 %SOURCE1 %{buildroot}%{_initrddir}/%{name}
Und der Installationsprozess geht weiter:
%if "%{_with_server}" == "1"
%{__install} -Dp -m0644 %{confdir}/server.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/puppetmaster
%{__install} -Dp -m0755 %{confdir}/server.init %{buildroot}%{_initrddir}/puppetmaster
%{__install} -Dp -m0644 %{confdir}/fileserver.conf %{buildroot}%{_sysconfdir}/puppet/fileserver.conf
%endif
%{__install} -Dp -m0644 %{confdir}/puppetd.conf %{buildroot}%{_sysconfdir}/puppet/puppetd.conf
%if "%{_with_server}" == "1"
%{__ln_s} puppetd.conf %{buildroot}%{_sysconfdir}/puppet/puppetmasterd.conf
%{__ln_s} puppetd.conf %{buildroot}%{_sysconfdir}/puppet/puppetca.conf
%endif
%{__install} -Dp -m0644 %{confdir}/logrotate %{buildroot}%{_sysconfdir}/logrotate.d/puppet
Hier stehen die Dateien, die Paket verbaut sind:
%files
%defattr(-, root, root, 0755)
%{_bindir}/puppet
%{_sbindir}/puppetd
%{ruby_sitelibdir}/*
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/puppetd.conf
%config(noreplace) %{_initrddir}/%{name}
%doc CHANGELOG COPYING LICENSE README TODO examples
%exclude %{_sbindir}/puppetdoc
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
# These need to be owned by puppet so the server can
# write to them
%attr(-, puppet, puppet) %{_localstatedir}/run/%{name}
%attr(-, puppet, puppet) %{_localstatedir}/log/%{name}
%attr(-, puppet, puppet) %{_localstatedir}/lib/%{name}
Die Dateien für den Server sind auskommentiert:
%if "%{_with_server}" == "1"
%files server
%defattr(-, root, root, 0755)
%{_sbindir}/puppetmasterd
%{_bindir}/puppetrun
%{_initrddir}/puppetmaster
%config(noreplace) %{_sysconfdir}/%{name}/*
%config(noreplace) %{_sysconfdir}/sysconfig/puppetmaster
%{_sbindir}/puppetca
%endif
Vor der Installation:
%pre
/usr/sbin/groupadd -r puppet 2>/dev/null || :
/usr/sbin/useradd -g puppet -c "Puppet" \
-s /sbin/nologin -r -d /var/lib/puppet puppet 2> /dev/null || :
if [ $1 -gt 1 ] ; then
/usr/sbin/usermod -d /var/lib/puppet puppet || :
fi
Nach der Installation:
%post
%{fillup_and_insserv puppet}
#/sbin/chkconfig --add puppet
#exit 0
%if "%{_with_server}" == "1"
%post server
/sbin/chkconfig --add puppetmaster
%endif
Vor der Deinstallation:
%preun %stop_on_removal puppet #if [ "$1" = 0 ] ; then # /sbin/service puppet stop > /dev/null 2>&1 # /sbin/chkconfig --del puppet #fi
Nach der Deinstallation:
%postun %restart_on_update puppet %insserv_cleanup
%if "%{_with_server}" == "1"
%preun server
if [ "$1" = 0 ] ; then
/sbin/service puppetmaster stop > /dev/null 2>&1
/sbin/chkconfig --del puppetmaster
fi
%postun server
if [ "$1" -ge 1 ]; then
/sbin/service puppetmaster condrestart > /dev/null 2>&1
fi
%endif
%clean
%{__rm} -rf %{buildroot}
Und zum Schluss der Changelog:
%changelog * Tue Apr 03 2007 Frank Proessdorf <frank.proessdorf@ibb.de> - 0.22.3-2 - Commented lines for puppet server out - Changed format to fit SLES10 - Added init script for SLES10 * Mon Mar 19 2007 David Lutterkort <dlutter@redhat.com> - 0.22.2-1 - Set puppet's homedir to /var/lib/puppet, not /var/puppet - Remove no-lockdir patch, not needed anymore * Mon Feb 12 2007 David Lutterkort <dlutter@redhat.com> - 0.22.1-2 - Fix bogus config parameter in puppetd.conf * Sat Feb 3 2007 David Lutterkort <dlutter@redhat.com> - 0.22.1-1 - New version * Fri Jan 5 2007 David Lutterkort <dlutter@redhat.com> - 0.22.0-1 - New version * Mon Nov 20 2006 David Lutterkort <dlutter@redhat.com> - 0.20.1-2 - Make require ruby(abi) and buildarch: noarch conditional for fedora 5 or later to allow building on older fedora releases * Mon Nov 13 2006 David Lutterkort <dlutter@redhat.com> - 0.20.1-1 - New version * Mon Oct 23 2006 David Lutterkort <dlutter@redhat.com> - 0.20.0-1 - New version * Tue Sep 26 2006 David Lutterkort <dlutter@redhat.com> - 0.19.3-1 - New version * Mon Sep 18 2006 David Lutterkort <dlutter@redhat.com> - 0.19.1-1 - New version * Thu Sep 7 2006 David Lutterkort <dlutter@redhat.com> - 0.19.0-1 - New version * Tue Aug 1 2006 David Lutterkort <dlutter@redhat.com> - 0.18.4-2 - Use /usr/bin/ruby directly instead of /usr/bin/env ruby in executables. Otherwise, initscripts break since pidof can't find the right process * Tue Aug 1 2006 David Lutterkort <dlutter@redhat.com> - 0.18.4-1 - New version * Fri Jul 14 2006 David Lutterkort <dlutter@redhat.com> - 0.18.3-1 - New version * Wed Jul 5 2006 David Lutterkort <dlutter@redhat.com> - 0.18.2-1 - New version * Wed Jun 28 2006 David Lutterkort <dlutter@redhat.com> - 0.18.1-1 - Removed lsb-config.patch and yumrepo.patch since they are upstream now * Mon Jun 19 2006 David Lutterkort <dlutter@redhat.com> - 0.18.0-1 - Patch config for LSB compliance (lsb-config.patch) - Changed config moves /var/puppet to /var/lib/puppet, /etc/puppet/ssl to /var/lib/puppet, /etc/puppet/clases.txt to /var/lib/puppet/classes.txt, /etc/puppet/localconfig.yaml to /var/lib/puppet/localconfig.yaml * Fri May 19 2006 David Lutterkort <dlutter@redhat.com> - 0.17.2-1 - Added /usr/bin/puppetrun to server subpackage - Backported patch for yumrepo type (yumrepo.patch) * Wed May 3 2006 David Lutterkort <dlutter@redhat.com> - 0.16.4-1 - Rebuilt * Fri Apr 21 2006 David Lutterkort <dlutter@redhat.com> - 0.16.0-1 - Fix default file permissions in server subpackage - Run puppetmaster as user puppet - rebuilt for 0.16.0 * Mon Apr 17 2006 David Lutterkort <dlutter@redhat.com> - 0.15.3-2 - Don't create empty log files in post-install scriptlet * Fri Apr 7 2006 David Lutterkort <dlutter@redhat.com> - 0.15.3-1 - Rebuilt for new version * Wed Mar 22 2006 David Lutterkort <dlutter@redhat.com> - 0.15.1-1 - Patch0: Run puppetmaster as root; running as puppet is not ready for primetime * Mon Mar 13 2006 David Lutterkort <dlutter@redhat.com> - 0.15.0-1 - Commented out noarch; requires fix for bz184199 * Mon Mar 6 2006 David Lutterkort <dlutter@redhat.com> - 0.14.0-1 - Added BuildRequires for ruby * Wed Mar 1 2006 David Lutterkort <dlutter@redhat.com> - 0.13.5-1 - Removed use of fedora-usermgmt. It is not required for Fedora Extras and makes it unnecessarily hard to use this rpm outside of Fedora. Just allocate the puppet uid/gid dynamically * Sun Feb 19 2006 David Lutterkort <dlutter@redhat.com> - 0.13.0-4 - Use fedora-usermgmt to create puppet user/group. Use uid/gid 24. Fixed problem with listing fileserver.conf and puppetmaster.conf twice * Wed Feb 8 2006 David Lutterkort <dlutter@redhat.com> - 0.13.0-3 - Fix puppetd.conf * Wed Feb 8 2006 David Lutterkort <dlutter@redhat.com> - 0.13.0-2 - Changes to run puppetmaster as user puppet * Mon Feb 6 2006 David Lutterkort <dlutter@redhat.com> - 0.13.0-1 - Don't mark initscripts as config files * Mon Feb 6 2006 David Lutterkort <dlutter@redhat.com> - 0.12.0-2 - Fix BuildRoot. Add dist to release * Tue Jan 17 2006 David Lutterkort <dlutter@redhat.com> - 0.11.0-1 - Rebuild * Thu Jan 12 2006 David Lutterkort <dlutter@redhat.com> - 0.10.2-1 - Updated for 0.10.2 Fixed minor kink in how Source is given * Wed Jan 11 2006 David Lutterkort <dlutter@redhat.com> - 0.10.1-3 - Added basic fileserver.conf * Wed Jan 11 2006 David Lutterkort <dlutter@redhat.com> - 0.10.1-1 - Updated. Moved installation of library files to sitelibdir. Pulled initscripts into separate files. Folded tools rpm into server * Wed Jan 11 2006 David Lutterkort <dlutter@redhat.com> - 0.10.1-1 - Updated. Moved installation of library files to sitelibdir. Pulled initscripts into separate files. Folded tools rpm into server * Thu Nov 24 2005 Duane Griffin <d.griffin@psenterprise.com> - Added init scripts for the client * Wed Nov 23 2005 Duane Griffin <d.griffin@psenterprise.com> - First packaging

