Created
September 23, 2014 00:34
-
-
Save Spredzy/177175f914368273aae3 to your computer and use it in GitHub Desktop.
puppet.spec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Augeas and SELinux requirements may be disabled at build time by passing | |
# --without augeas and/or --without selinux to rpmbuild or mock | |
# Fedora 17 ships with ruby 1.9, RHEL 7 with ruby 2.0, which use vendorlibdir instead | |
# of sitelibdir. Adjust our target if installing on f17 or rhel7. | |
%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 || 0%{?amzn} >= 1 | |
%global puppet_libdir %(ruby -rrbconfig -e 'puts RbConfig::CONFIG["vendorlibdir"]') | |
%else | |
%global puppet_libdir %(ruby -rrbconfig -e 'puts RbConfig::CONFIG["sitelibdir"]') | |
%endif | |
%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 | |
%global _with_systemd 1 | |
%else | |
%global _with_systemd 0 | |
%endif | |
# VERSION is subbed out during rake srpm process | |
%global realversion 3.7.1 | |
%global rpmversion 3.7.1 | |
%global confdir ext/redhat | |
%global pending_upgrade_path %{_localstatedir}/lib/rpm-state/puppet | |
%global pending_upgrade_file %{pending_upgrade_path}/upgrade_pending | |
Name: puppet | |
Version: %{rpmversion} | |
Release: 1%{?dist} | |
Vendor: %{?_host_vendor} | |
Summary: A network tool for managing many disparate systems | |
License: ASL 2.0 | |
URL: http://puppetlabs.com | |
Source0: http://puppetlabs.com/downloads/%{name}/%{name}-%{realversion}.tar.gz | |
Group: System Environment/Base | |
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) | |
BuildRequires: facter >= 1:1.7.0 | |
# Puppet 3.x drops ruby 1.8.5 support and adds ruby 1.9 support | |
BuildRequires: ruby >= 1.8.7 | |
BuildRequires: hiera >= 1.0.0 | |
BuildArch: noarch | |
Requires: ruby >= 1.8 | |
Requires: ruby-shadow | |
Requires: rubygem-json | |
# Pull in ruby selinux bindings where available | |
%if 0%{?fedora} || 0%{?rhel} >= 6 | |
%{!?_without_selinux:Requires: ruby(selinux), libselinux-utils} | |
%else | |
%if ( 0%{?rhel} && 0%{?rhel} == 5 ) || 0%{?amzn} >= 1 | |
%{!?_without_selinux:Requires: libselinux-ruby, libselinux-utils} | |
%endif | |
%endif | |
Requires: facter >= 1:1.7.0 | |
# Puppet 3.x drops ruby 1.8.5 support and adds ruby 1.9 support | |
# Ruby 1.8.7 available for el5 at: yum.puppetlabs.com/el/5/devel/$ARCH | |
Requires: ruby >= 1.8.7 | |
Requires: hiera >= 1.0.0 | |
Obsoletes: hiera-puppet < 1.0.0 | |
Provides: hiera-puppet >= 1.0.0 | |
%{!?_without_augeas:Requires: ruby-augeas} | |
# Required for %%pre | |
Requires: shadow-utils | |
%if 0%{?_with_systemd} | |
# Required for %%post, %%preun, %%postun | |
Requires: systemd | |
%if 0%{?fedora} >= 18 || 0%{?rhel} >= 7 | |
BuildRequires: systemd | |
%else | |
BuildRequires: systemd-units | |
%endif | |
%else | |
# Required for %%post and %%preun | |
Requires: chkconfig | |
# Required for %%preun and %%postun | |
Requires: initscripts | |
%endif | |
%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. | |
%package server | |
Group: System Environment/Base | |
Summary: Server for the puppet system management tool | |
Requires: puppet = %{version}-%{release} | |
# chkconfig (%%post, %%preun) and initscripts (%%preun %%postun) are required for non systemd | |
# and systemd (%%post, %%preun, and %%postun) are required for systems with systemd as default | |
# They come along transitively with 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. | |
%prep | |
%setup -q -n %{name}-%{realversion} | |
%build | |
for f in external/nagios.rb relationship.rb; do | |
sed -i -e '1d' lib/puppet/$f | |
done | |
find examples/ -type f | xargs --no-run-if-empty chmod a-x | |
%install | |
rm -rf %{buildroot} | |
ruby install.rb --destdir=%{buildroot} --quick --no-rdoc --sitelibdir=%{puppet_libdir} | |
install -d -m0755 %{buildroot}%{_sysconfdir}/puppet/environments/example_env/manifests | |
install -d -m0755 %{buildroot}%{_sysconfdir}/puppet/environments/example_env/modules | |
install -d -m0755 %{buildroot}%{_sysconfdir}/puppet/manifests | |
install -d -m0755 %{buildroot}%{_datadir}/%{name}/modules | |
install -d -m0755 %{buildroot}%{_localstatedir}/lib/puppet | |
install -d -m0755 %{buildroot}%{_localstatedir}/lib/puppet/state | |
install -d -m0755 %{buildroot}%{_localstatedir}/lib/puppet/reports | |
install -d -m0755 %{buildroot}%{_localstatedir}/run/puppet | |
# As per redhat bz #495096 | |
install -d -m0750 %{buildroot}%{_localstatedir}/log/puppet | |
%if 0%{?_with_systemd} | |
# Systemd for fedora >= 17 or el 7 | |
%{__install} -d -m0755 %{buildroot}%{_unitdir} | |
install -Dp -m0644 ext/systemd/puppet.service %{buildroot}%{_unitdir}/puppet.service | |
ln -s %{_unitdir}/puppet.service %{buildroot}%{_unitdir}/puppetagent.service | |
install -Dp -m0644 ext/systemd/puppetmaster.service %{buildroot}%{_unitdir}/puppetmaster.service | |
%else | |
# Otherwise init.d for fedora < 17 or el 5, 6 | |
install -Dp -m0644 %{confdir}/client.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/puppet | |
install -Dp -m0755 %{confdir}/client.init %{buildroot}%{_initrddir}/puppet | |
install -Dp -m0644 %{confdir}/server.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/puppetmaster | |
install -Dp -m0755 %{confdir}/server.init %{buildroot}%{_initrddir}/puppetmaster | |
install -Dp -m0755 %{confdir}/queue.init %{buildroot}%{_initrddir}/puppetqueue | |
%endif | |
install -Dp -m0644 %{confdir}/fileserver.conf %{buildroot}%{_sysconfdir}/puppet/fileserver.conf | |
install -Dp -m0644 %{confdir}/puppet.conf %{buildroot}%{_sysconfdir}/puppet/puppet.conf | |
install -Dp -m0644 %{confdir}/logrotate %{buildroot}%{_sysconfdir}/logrotate.d/puppet | |
install -Dp -m0644 ext/README.environment %{buildroot}%{_sysconfdir}/puppet/environments/example_env/README.environment | |
# Install the ext/ directory to %%{_datadir}/%%{name} | |
install -d %{buildroot}%{_datadir}/%{name} | |
cp -a ext/ %{buildroot}%{_datadir}/%{name} | |
# emacs and vim bits are installed elsewhere | |
rm -rf %{buildroot}%{_datadir}/%{name}/ext/{emacs,vim} | |
# remove misc packaging artifacts not applicable to rpms | |
rm -rf %{buildroot}%{_datadir}/%{name}/ext/{gentoo,freebsd,solaris,suse,windows,osx,ips,debian} | |
rm -f %{buildroot}%{_datadir}/%{name}/ext/redhat/*.init | |
rm -f %{buildroot}%{_datadir}/%{name}/ext/{build_defaults.yaml,project_data.yaml} | |
# Rpmlint fixup | |
chmod 755 %{buildroot}%{_datadir}/%{name}/ext/regexp_nodes/regexp_nodes.rb | |
chmod 755 %{buildroot}%{_datadir}/%{name}/ext/puppet-load.rb | |
# Install emacs mode files | |
emacsdir=%{buildroot}%{_datadir}/emacs/site-lisp | |
install -Dp -m0644 ext/emacs/puppet-mode.el $emacsdir/puppet-mode.el | |
install -Dp -m0644 ext/emacs/puppet-mode-init.el \ | |
$emacsdir/site-start.d/puppet-mode-init.el | |
# Install vim syntax files | |
vimdir=%{buildroot}%{_datadir}/vim/vimfiles | |
install -Dp -m0644 ext/vim/ftdetect/puppet.vim $vimdir/ftdetect/puppet.vim | |
install -Dp -m0644 ext/vim/syntax/puppet.vim $vimdir/syntax/puppet.vim | |
%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7 | |
# Setup tmpfiles.d config | |
mkdir -p %{buildroot}%{_sysconfdir}/tmpfiles.d | |
echo "D /var/run/%{name} 0755 %{name} %{name} -" > \ | |
%{buildroot}%{_sysconfdir}/tmpfiles.d/%{name}.conf | |
%endif | |
# Create puppet modules directory for puppet module tool | |
mkdir -p %{buildroot}%{_sysconfdir}/%{name}/modules | |
# Install a NetworkManager dispatcher script to pickup changes to | |
# # /etc/resolv.conf and such (https://bugzilla.redhat.com/532085). | |
mkdir -p %{buildroot}%{_sysconfdir}/NetworkManager/dispatcher.d | |
cp -pr ext/puppet-nm-dispatcher \ | |
%{buildroot}%{_sysconfdir}/NetworkManager/dispatcher.d/98-%{name} | |
%files | |
%defattr(-, root, root, 0755) | |
%doc LICENSE README.md examples | |
%{_bindir}/puppet | |
%{_bindir}/extlookup2hiera | |
%{puppet_libdir}/* | |
%dir %{_sysconfdir}/NetworkManager | |
%dir %{_sysconfdir}/NetworkManager/dispatcher.d | |
%{_sysconfdir}/NetworkManager/dispatcher.d/98-puppet | |
%if 0%{?_with_systemd} | |
%{_unitdir}/puppet.service | |
%{_unitdir}/puppetagent.service | |
%else | |
%{_initrddir}/puppet | |
%config(noreplace) %{_sysconfdir}/sysconfig/puppet | |
%endif | |
%dir %{_sysconfdir}/puppet | |
%dir %{_sysconfdir}/%{name}/modules | |
%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7 | |
%config(noreplace) %{_sysconfdir}/tmpfiles.d/%{name}.conf | |
%endif | |
%config(noreplace) %{_sysconfdir}/puppet/puppet.conf | |
%config(noreplace) %{_sysconfdir}/puppet/auth.conf | |
%config(noreplace) %{_sysconfdir}/logrotate.d/puppet | |
# We don't want to require emacs or vim, so we need to own these dirs | |
%{_datadir}/emacs | |
%{_datadir}/vim | |
%{_datadir}/%{name} | |
# man pages | |
%{_mandir}/man5/puppet.conf.5.gz | |
%{_mandir}/man8/puppet.8.gz | |
%{_mandir}/man8/puppet-agent.8.gz | |
%{_mandir}/man8/puppet-apply.8.gz | |
%{_mandir}/man8/puppet-catalog.8.gz | |
%{_mandir}/man8/puppet-describe.8.gz | |
%{_mandir}/man8/puppet-ca.8.gz | |
%{_mandir}/man8/puppet-cert.8.gz | |
%{_mandir}/man8/puppet-certificate.8.gz | |
%{_mandir}/man8/puppet-certificate_request.8.gz | |
%{_mandir}/man8/puppet-certificate_revocation_list.8.gz | |
%{_mandir}/man8/puppet-config.8.gz | |
%{_mandir}/man8/puppet-device.8.gz | |
%{_mandir}/man8/puppet-doc.8.gz | |
%{_mandir}/man8/puppet-facts.8.gz | |
%{_mandir}/man8/puppet-file.8.gz | |
%{_mandir}/man8/puppet-filebucket.8.gz | |
%{_mandir}/man8/puppet-help.8.gz | |
%{_mandir}/man8/puppet-inspect.8.gz | |
%{_mandir}/man8/puppet-instrumentation_data.8.gz | |
%{_mandir}/man8/puppet-instrumentation_listener.8.gz | |
%{_mandir}/man8/puppet-instrumentation_probe.8.gz | |
%{_mandir}/man8/puppet-key.8.gz | |
%{_mandir}/man8/puppet-kick.8.gz | |
%{_mandir}/man8/puppet-man.8.gz | |
%{_mandir}/man8/puppet-module.8.gz | |
%{_mandir}/man8/puppet-node.8.gz | |
%{_mandir}/man8/puppet-parser.8.gz | |
%{_mandir}/man8/puppet-plugin.8.gz | |
%{_mandir}/man8/puppet-queue.8.gz | |
%{_mandir}/man8/puppet-report.8.gz | |
%{_mandir}/man8/puppet-resource.8.gz | |
%{_mandir}/man8/puppet-resource_type.8.gz | |
%{_mandir}/man8/puppet-secret_agent.8.gz | |
%{_mandir}/man8/puppet-status.8.gz | |
%{_mandir}/man8/extlookup2hiera.8.gz | |
# These need to be owned by puppet so the server can | |
# write to them. The separate %defattr's are required | |
# to work around RH Bugzilla 681540 | |
%defattr(-, puppet, puppet, 0755) | |
%{_localstatedir}/run/puppet | |
%defattr(-, puppet, puppet, 0750) | |
%{_localstatedir}/log/puppet | |
%{_localstatedir}/lib/puppet | |
%{_localstatedir}/lib/puppet/state | |
%{_localstatedir}/lib/puppet/reports | |
# Return the default attributes to 0755 to | |
# prevent incorrect permission assignment on EL6 | |
%defattr(-, root, root, 0755) | |
%files server | |
%defattr(-, root, root, 0755) | |
%if 0%{?_with_systemd} | |
%{_unitdir}/puppetmaster.service | |
%else | |
%{_initrddir}/puppetmaster | |
%{_initrddir}/puppetqueue | |
%config(noreplace) %{_sysconfdir}/sysconfig/puppetmaster | |
%endif | |
%config(noreplace) %{_sysconfdir}/puppet/fileserver.conf | |
%dir %{_sysconfdir}/puppet/manifests | |
%dir %{_sysconfdir}/puppet/environments | |
%dir %{_sysconfdir}/puppet/environments/example_env | |
%dir %{_sysconfdir}/puppet/environments/example_env/manifests | |
%dir %{_sysconfdir}/puppet/environments/example_env/modules | |
%{_sysconfdir}/puppet/environments/example_env/README.environment | |
%{_mandir}/man8/puppet-ca.8.gz | |
%{_mandir}/man8/puppet-master.8.gz | |
# Fixed uid/gid were assigned in bz 472073 (Fedora), 471918 (RHEL-5), | |
# and 471919 (RHEL-4) | |
%pre | |
getent group puppet &>/dev/null || groupadd -r puppet -g 52 &>/dev/null | |
getent passwd puppet &>/dev/null || \ | |
useradd -r -u 52 -g puppet -d %{_localstatedir}/lib/puppet -s /sbin/nologin \ | |
-c "Puppet" puppet &>/dev/null | |
# ensure that old setups have the right puppet home dir | |
if [ $1 -gt 1 ] ; then | |
usermod -d %{_localstatedir}/lib/puppet puppet &>/dev/null | |
fi | |
exit 0 | |
%post | |
%if 0%{?_with_systemd} | |
/bin/systemctl daemon-reload >/dev/null 2>&1 || : | |
if [ "$1" -ge 1 ]; then | |
# The pidfile changed from 0.25.x to 2.6.x, handle upgrades without leaving | |
# the old process running. | |
oldpid="%{_localstatedir}/run/puppet/puppetd.pid" | |
newpid="%{_localstatedir}/run/puppet/agent.pid" | |
if [ -s "$oldpid" -a ! -s "$newpid" ]; then | |
(kill $(< "$oldpid") && rm -f "$oldpid" && \ | |
/bin/systemctl start puppet.service) >/dev/null 2>&1 || : | |
fi | |
fi | |
%else | |
/sbin/chkconfig --add puppet || : | |
if [ "$1" -ge 1 ]; then | |
# The pidfile changed from 0.25.x to 2.6.x, handle upgrades without leaving | |
# the old process running. | |
oldpid="%{_localstatedir}/run/puppet/puppetd.pid" | |
newpid="%{_localstatedir}/run/puppet/agent.pid" | |
if [ -s "$oldpid" -a ! -s "$newpid" ]; then | |
(kill $(< "$oldpid") && rm -f "$oldpid" && \ | |
/sbin/service puppet start) >/dev/null 2>&1 || : | |
fi | |
# If an old puppet process (one whose binary is located in /sbin) is running, | |
# kill it and then start up a fresh with the new binary. | |
if [ -e "$newpid" ]; then | |
if ps aux | grep `cat "$newpid"` | grep -v grep | awk '{ print $12 }' | grep -q sbin; then | |
(kill $(< "$newpid") && rm -f "$newpid" && \ | |
/sbin/service puppet start) >/dev/null 2>&1 || : | |
fi | |
fi | |
fi | |
%endif | |
%post server | |
%if 0%{?_with_systemd} | |
/bin/systemctl daemon-reload >/dev/null 2>&1 || : | |
if [ "$1" -ge 1 ]; then | |
# The pidfile changed from 0.25.x to 2.6.x, handle upgrades without leaving | |
# the old process running. | |
oldpid="%{_localstatedir}/run/puppet/puppetmasterd.pid" | |
newpid="%{_localstatedir}/run/puppet/master.pid" | |
if [ -s "$oldpid" -a ! -s "$newpid" ]; then | |
(kill $(< "$oldpid") && rm -f "$oldpid" && \ | |
/bin/systemctl start puppetmaster.service) > /dev/null 2>&1 || : | |
fi | |
fi | |
%else | |
/sbin/chkconfig --add puppetmaster || : | |
if [ "$1" -ge 1 ]; then | |
# The pidfile changed from 0.25.x to 2.6.x, handle upgrades without leaving | |
# the old process running. | |
oldpid="%{_localstatedir}/run/puppet/puppetmasterd.pid" | |
newpid="%{_localstatedir}/run/puppet/master.pid" | |
if [ -s "$oldpid" -a ! -s "$newpid" ]; then | |
(kill $(< "$oldpid") && rm -f "$oldpid" && \ | |
/sbin/service puppetmaster start) >/dev/null 2>&1 || : | |
fi | |
fi | |
%endif | |
%preun | |
%if 0%{?_with_systemd} | |
if [ "$1" -eq 0 ] ; then | |
# Package removal, not upgrade | |
/bin/systemctl --no-reload disable puppetagent.service > /dev/null 2>&1 || : | |
/bin/systemctl --no-reload disable puppet.service > /dev/null 2>&1 || : | |
/bin/systemctl stop puppetagent.service > /dev/null 2>&1 || : | |
/bin/systemctl stop puppet.service > /dev/null 2>&1 || : | |
/bin/systemctl daemon-reload >/dev/null 2>&1 || : | |
fi | |
if [ "$1" == "1" ]; then | |
/bin/systemctl is-enabled puppetagent.service > /dev/null 2>&1 | |
if [ "$?" == "0" ]; then | |
/bin/systemctl --no-reload disable puppetagent.service > /dev/null 2>&1 ||: | |
/bin/systemctl stop puppetagent.service > /dev/null 2>&1 ||: | |
/bin/systemctl daemon-reload >/dev/null 2>&1 ||: | |
if [ ! -d %{pending_upgrade_path} ]; then | |
mkdir -p %{pending_upgrade_path} | |
fi | |
if [ ! -e %{pending_upgrade_file} ]; then | |
touch %{pending_upgrade_file} | |
fi | |
fi | |
fi | |
%else | |
if [ "$1" = 0 ] ; then | |
/sbin/service puppet stop > /dev/null 2>&1 | |
/sbin/chkconfig --del puppet || : | |
fi | |
%endif | |
%preun server | |
%if 0%{?_with_systemd} | |
if [ $1 -eq 0 ] ; then | |
# Package removal, not upgrade | |
/bin/systemctl --no-reload disable puppetmaster.service > /dev/null 2>&1 || : | |
/bin/systemctl stop puppetmaster.service > /dev/null 2>&1 || : | |
/bin/systemctl daemon-reload >/dev/null 2>&1 || : | |
fi | |
%else | |
if [ "$1" = 0 ] ; then | |
/sbin/service puppetmaster stop > /dev/null 2>&1 | |
/sbin/chkconfig --del puppetmaster || : | |
fi | |
%endif | |
%postun | |
%if 0%{?_with_systemd} | |
if [ $1 -ge 1 ] ; then | |
if [ -e %{pending_upgrade_file} ]; then | |
/bin/systemctl --no-reload enable puppet.service > /dev/null 2>&1 ||: | |
/bin/systemctl start puppet.service > /dev/null 2>&1 ||: | |
/bin/systemctl daemon-reload >/dev/null 2>&1 ||: | |
rm %{pending_upgrade_file} | |
fi | |
# Package upgrade, not uninstall | |
/bin/systemctl try-restart puppetagent.service >/dev/null 2>&1 || : | |
fi | |
%else | |
if [ "$1" -ge 1 ]; then | |
/sbin/service puppet condrestart >/dev/null 2>&1 || : | |
fi | |
%endif | |
%postun server | |
%if 0%{?_with_systemd} | |
if [ $1 -ge 1 ] ; then | |
# Package upgrade, not uninstall | |
/bin/systemctl try-restart puppetmaster.service >/dev/null 2>&1 || : | |
fi | |
%else | |
if [ "$1" -ge 1 ]; then | |
/sbin/service puppetmaster condrestart >/dev/null 2>&1 || : | |
fi | |
%endif | |
%clean | |
rm -rf %{buildroot} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment