Name:                ansible-runner-service
Version:             1.0.7
Release:             1
License:             ASL 2.0
Summary:             RESTful API for ansible/ansible_runner execution
Source0:             https://github.com/ansible/%{name}/archive/%{name}-%{version}.tar.gz
Patch0:              ovirt_log.patch
Patch1:              wsgi.patch
BuildArch:           noarch
BuildRequires:       systemd python3-devel python3-setuptools

%global _description %{expand:
This package provides the Ansible Runner Service source files. Ansible runner service exposes a REST API interface on top of the functionality provided by ansible and ansible_runner.
The Ansible Runner Service provided in this packages is intended to be used as uwgsi app exposed by Nginx in a Container.
Dependencies, and configuration tasks must be performed in the container.
Ansible Runner Service listens on https://localhost:5001 by default for playbook or ansible inventory requests. For developers interested in using the API, all the available endpoints are documented at https://localhost:5001/api.
In addition to the API endpoints, the daemon also provides a /metrics endpoint for prometheus integration. A sample Grafana dashboard is provided within /usr/share/doc/ansible-runner-service}
%description %_description

%prep
%autosetup -n %{name}-%{version} -p1

%build
%py3_build

%install
%py3_install
mkdir -p %{buildroot}%{_sysconfdir}/ansible-runner-service
install -m 644 ./config.yaml %{buildroot}%{_sysconfdir}/ansible-runner-service
install -m 644 ./logging.yaml %{buildroot}%{_sysconfdir}/ansible-runner-service
mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d
install -m 644 ./misc/packaging/logrotate/ansible-runner-service %{buildroot}%{_sysconfdir}/logrotate.d/ansible-runner-service
install -m 644 ./ansible_runner_service.py %{buildroot}%{python3_sitelib}/runner_service
mkdir -p %{buildroot}%{_var}/www/runnner
install -m 644 ./wsgi.py %{buildroot}%{_var}/www/runnner/runner.wsgi

%post
semanage fcontext -a -t httpd_log_t -s system_u /var/log/ovirt-engine/ansible-runner-service.log 2> /dev/null || semanage fcontext -m -t httpd_log_t -s system_u /var/log/ovirt-engine/ansible-runner-service.log || true
[[ -f /var/log/ovirt-engine/ansible-runner-service.log ]] && restorecon -rF /var/log/ovirt-engine/ansible-runner-service.log || true

%files -n ansible-runner-service
%{_bindir}/ansible_runner_service
%{python3_sitelib}/*
%{_sysconfdir}/logrotate.d/ansible-runner-service
%config(noreplace) %{_sysconfdir}/ansible-runner-service/*
%{_var}/www/runnner/runner.wsgi
%license LICENSE.md
%doc README.md

%changelog
* Wed Aug 25 2021 huanghaitao <huanghaitao8@huawei.com> - 1.0.7-1
- package init
