%global with_docs 0
%global common_desc \
	Ansible is a radically simple model-driven configuration management,\
	multi-node deployment, and remote task execution system. Ansible works \
	over SSH and does not require any software or daemons to be installed \
	on remote nodes. Extension modules can be written in any language and \
	are transferred to managed machines automatically. \
	This package installs versions of ansible that execute on Python3.

Name:                ansible
Summary:             SSH-based configuration management, deployment, and task execution system
Version:             2.9.27
Release:             6
License:             Python-2.0 and MIT and GPL+
Url:                 http://ansible.com
Source0: 	     https://releases.ansible.com/ansible/%{name}-%{version}.tar.gz
Patch0:              hostname-module-support-openEuler.patch
Patch1:              CVE-2024-0690.patch
Patch2:              CVE-2024-8775.patch
Patch3:              CVE-2024-9902.patch
Patch4:              CVE-2022-3697.patch
Patch5:              CVE-2023-5115.patch
BuildArch:           noarch
Provides:            ansible-fireball = %{version}-%{release}
Obsoletes:           ansible-fireball < 1.2.4
BuildRequires:       python3-jinja2 python3-devel python3-packaging python3-pyyaml  python3-setuptools
BuildRequires:       python3-PyYAML python3-paramiko python3-cryptography
BuildRequires:       python3-pexpect python3-pywinrm git-core
BuildRequires:       python3-six python3-pytest python3-pytest-xdist
BuildRequires:       python3-pytest-mock python3-requests python3-coverage python3-mock
BuildRequires:       python3-boto3 python3-botocore python3-passlib
Requires:            python3-PyYAML python3-cryptography python3-paramiko
Requires:            python3-setuptools python3-six sshpass python3-httplib2
Requires:            python3-jmespath python3-jinja2 
Recommends:          %{name}-help = %{version}-%{release}

Provides:            ansible-python3 = %{version}-%{release}
Obsoletes:           ansible-python3 < %{version}-%{release}
%if %with_docs
BuildRequires:       python3-sphinx python3-sphinx-theme-alabaster asciidoc
%endif
%description
%{common_desc}


%package -n ansible-help
Summary:             Documentation for Ansible
Provides:            %{name}-doc = %{name}-%{release}
Obsoletes:           %{name}-doc < %{name}-%{release}
%description -n ansible-help
%{common_desc}

%prep
%autosetup -p1
rm -rf %{py3dir}
cp -a . %{py3dir}

%build
pushd %{py3dir}
%py3_build
%if %with_docs
  pathfix.py -i %{__python3} -p docs/bin test/runner
  make PYTHON=/usr/bin/python3 SPHINXBUILD=sphinx-build-3 webdocs
%endif
popd

%install
pushd %{py3dir}
%{__python3} setup.py install --root=$RPM_BUILD_ROOT
popd
for i in $RPM_BUILD_ROOT/%{_bindir}/ansible* ; do
    if [ $(basename $i) = "ansible-connection" -o $(basename $i) = "ansible" ] ; then
            ln -s $(basename $i) $i-%{python3_version}
        ln -s %{_bindir}/$(basename $i)-%{python3_version} $i-3
    fi
done
mkdir -p $RPM_BUILD_ROOT/etc/ansible/
mkdir -p $RPM_BUILD_ROOT/etc/ansible/roles/
cp examples/hosts $RPM_BUILD_ROOT/etc/ansible/
cp examples/ansible.cfg $RPM_BUILD_ROOT/etc/ansible/
mkdir -p $RPM_BUILD_ROOT/%{_mandir}/man1
cp -v docs/man/man1/*.1 $RPM_BUILD_ROOT/%{_mandir}/man1/
cp -pr docs/docsite/rst .
%if %with_docs
  pushd %{py3dir}
  cp -pr docs/docsite/_build/html %{_builddir}/%{name}-%{version}/html
  popd
%endif

%check

%files
%defattr(-,root,root)
%{_bindir}/ansible*
%config(noreplace) %{_sysconfdir}/ansible/
%doc %{_mandir}/man1/ansible*
%{python3_sitelib}/ansible*

%files -n ansible-help
%doc rst
%if %with_docs
%doc html
%endif

%changelog
* Sat Feb 08 2025 wangkai <13474090681@163.com> - 2.9.27-6
- Fix CVE-2022-3697 CVE-2023-5115

* Mon Dec 02 2024 yaoxin <yao_xin001@hoperun.com> - 2.9.27-5
- Fix CVE-2024-8775 and CVE-2024-9902

* Mon Feb 05 2024 wangkai <13474090681@163.com> - 2.9.27-4
- Fix CVE-2024-0690

* Wed Apr 19 2023 liyanan <thistleslyn@163.com> - 2.9.27-3
- Remove with_python3 macros and python3-nose buildRequire 

* Fri Mar 18 2022 huangtianhua <huangtianhua@huawei.com> - 2.9.27-2
- Remove require python-keyczar and modify require crypto to cryptography

* Tue Mar 01 2022 wangkai <wangkai385@huawei.com> - 2.9.27-1
- Hostname module support openEuler

* Wed Jan 12 2022 wulei <wulei80@huawei.com> - 2.9.27-0
- Package update

* Thu Oct 28 2021 liwu <liwu13@huawei.com> - 2.9.24-3
- The upstream community rolls back the patch

* Sat Sep 18 2021 houyingchao <houyingchao@huawei.com> - 2.9.24-2
- Fix CVE-2020-1736 CVE-2020-1738

* Fri Sep 17 2021 houyingchao <houyingchao@huawei.com> - 2.9.24-1
- update to 2.9.24

* Mon Jul 12 2021 liksh <liks11@chinaunicom.cn> - 2.9.0-1
- update to 2.9.0

* Tue Jan 12 2021 yanan li <liyanan32@huawei.com> - 2.5.5-1
- Package init

