%if 0%{?_version:1} %define _verstr %{_version} %else %define _verstr 0.3.0 %endif %if 0%{?_commit:1} %define gh_commit %{_commit} %else %define gh_commit 66d344b3c16944771f3d7fcb88f6f974d8ec4814 %endif %define checkout %(date +%Y%m%d) %define gh_short %(c=%{gh_commit}; echo ${c:0:7}) %define basedir /var/www/%{name} %define wwwdir %{basedir}/www Name: puppetboard Version: %{_verstr} Release: 0.1.%{checkout}git%{gh_short}%{?dist} Summary: Web frontend for PuppetDB License: Apache v2.0 URL: https://github.com/voxpupuli/%{name} Source0: https://github.com/voxpupuli/%{name}/archive/%{gh_commit}.zip BuildRequires: httpd BuildRequires: python-virtualenv #BuildRequires: python-flask #BuildRequires: python-flask-wtf #BuildRequires: python-jinja2 #BuildRequires: python-markupsafe #BuildRequires: python-wtforms #BuildRequires: python-werkzeug #BuildRequires: python-itsdangerous #BuildRequires: python-puppetdb Requires: httpd Requires: mod_wsgi Requires: python-virtualenv #Requires: python-flask #Requires: python-flask-wtf #Requires: python-jinja2 #Requires: python-markupsafe #Requires: python-wtforms #Requires: python-werkzeug #Requires: python-itsdangerous #Requires: python-puppetdb %description Puppetboard is a web interface to PuppetDB aiming to replace the reporting functionality of Puppet Dashboard. Puppetboard relies on the pypuppetdb library to fetch data from PuppetDB and is built with the help of the Flask microframework. %package doc Summary: Documentation for %{name} Group: Documentation Requires: %{name} = %{version}-%{release} BuildArch: noarch %description doc Documentation for %{name} %prep %setup -c -q -n %{name} mv %{name}-%{gh_commit} %{name} mkdir virtenv-%{name} %build virtualenv virtenv-%{name} source virtenv-%{name}/bin/activate cd %{name} pip install -r requirements.txt sed -i 's/\/builddir\/build\/BUILD\//\/var\/www\//' ../virtenv-%{name}/bin/{a,e,pi,pa,c,f}* # disable async filter as it is not used anyways https://github.com/pallets/jinja/issues/662 / https://github.com/pallets/jinja/issues/643 # do the same what the official python-jinja2 spec does rm ../virtenv-%{name}/lib/python2.7/site-packages/jinja2/asyncfilters.py rm ../virtenv-%{name}/lib/python2.7/site-packages/jinja2/asyncsupport.py cat <wsgi.py from __future__ import absolute_import import os import sys # Needed if a settings.py file exists os.environ['PUPPETBOARD_SETTINGS'] = '/etc/puppetboard/settings.py' activate_this = '%{basedir}/virtenv-%{name}/bin/activate_this.py' execfile(activate_this, dict(__file__=activate_this)) me = '%{wwwdir}' # Add us to the PYTHONPATH/sys.path if we're not on it if not me in sys.path: sys.path.insert(0, me) from %{name}.app import app as application EOF cat <%{name}.conf WSGIDaemonProcess %{name} user=%{name} group=%{name} threads=5 maximum-requests=0 WSGIScriptAlias /%{name} %{wwwdir}/wsgi.py Alias /%{name}/static %{wwwdir}/%{name}/static WSGIProcessGroup %{name} WSGIApplicationGroup %{GLOBAL} Order deny,allow Allow from all EOF %install mkdir -p %{buildroot}%{basedir} mkdir -p %{buildroot}/etc/httpd/conf.d/ mkdir -p %{buildroot}/etc/puppetboard mv virtenv-%{name} %{buildroot}%{basedir}/ mv %{name}/%{name}.conf %{buildroot}/etc/httpd/conf.d/ mv %{name} %{buildroot}%{wwwdir} echo -e "# sample file from source, illustrating what can be configured\n" > %{buildroot}/etc/puppetboard/settings.py cat %{buildroot}%{wwwdir}/%{name}/default_settings.py >> %{buildroot}/etc/puppetboard/settings.py %files %{basedir} %config(noreplace) /etc/httpd/conf.d/%{name}.conf %dir %attr(0750,root,puppetboard) /etc/puppetboard %attr(0640,root,puppetboard) %config(noreplace) /etc/puppetboard/settings.py %exclude /etc/puppetboard/settings.pyc %exclude /etc/puppetboard/settings.pyo %files doc %{wwwdir}/CHANGELOG.rst %{wwwdir}/screenshots %{wwwdir}/README.rst %{wwwdir}/MANIFEST.in %license %{wwwdir}/LICENSE %pre getent group %{name} >/dev/null || groupadd -r %{name} getent passwd %{name} >/dev/null || \ useradd -r -g %{name} -d /var/www/%{name} -s /sbin/nologin \ -c "%{name} runner" %{name} %changelog