1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
%define release_date %(date "+%a %b %e %Y")
# Disable shebang munging for specific paths. These files are data files.
# ansible-test munges the shebangs itself.
%global __brp_mangle_shebangs_exclude_from /usr/lib/python[0-9]+\.[0-9]+/site-packages/ansible_test/_data/.*
%if 0%{?fedora} || 0%{?rhel} >= 8
%global with_python2 0
%global with_python3 1
%else
%global with_python2 1
%global with_python3 0
%endif
Name: ansible
Summary: SSH-based configuration management, deployment, and task execution system
Version: %{rpmversion}
Release: %{rpmrelease}%{?dist}%{?repotag}
Group: Development/Libraries
License: GPLv3+
Source0: https://releases.ansible.com/ansible/%{name}-%{upstream_version}.tar.gz
Url: http://ansible.com
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
%{!?python2_sitelib: %global python_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python3_sitelib: %global python_sitelib %(%{__python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
# Bundled provides
Provides: bundled(python-backports-ssl_match_hostname) = 3.7.0.1
Provides: bundled(python-distro) = 1.4.0
Provides: bundled(python-ipaddress) = 1.0.22
Provides: bundled(python-selectors2) = 1.1.1
Provides: bundled(python-six) = 1.12.0
%if 0%{?rhel} >= 8
# Bundled provides
Provides: bundled(python-backports-ssl_match_hostname) = 3.7.0.1
Provides: bundled(python-distro) = 1.4.0
Provides: bundled(python-ipaddress) = 1.0.22
Provides: bundled(python-selectors2) = 1.1.1
Provides: bundled(python-six) = 1.12.0
BuildRequires: python3-devel
BuildRequires: python3-setuptools
# man pages
BuildRequires: python3-docutils
# Tests
BuildRequires: python3-jinja2
BuildRequires: python3-PyYAML
BuildRequires: python3-cryptography
BuildRequires: python3-six
BuildRequires: python3-pytest
BuildRequires: python3-pytest-xdist
BuildRequires: python3-pytest-mock
BuildRequires: python3-requests
BuildRequires: python3-coverage
BuildRequires: python3-mock
BuildRequires: python3-boto3
BuildRequires: python3-botocore
BuildRequires: python3-systemd
BuildRequires: git-core
Requires: python3-jinja2
Requires: python3-PyYAML
Requires: python3-cryptography
Requires: python3-six
Requires: sshpass
%else
%if 0%{?rhel} >= 7
# RHEL 7
BuildRequires: python2-devel
BuildRequires: python-setuptools
# For building docs
BuildRequires: python-sphinx
# Tests
BuildRequires: python-jinja2
BuildRequires: PyYAML
BuildRequires: python2-cryptography
BuildRequires: python-six
# rhel7 does not have python-pytest but has pytest
BuildRequires: pytest
#BuildRequires: python-pytest-xdist
#BuildRequires: python-pytest-mock
BuildRequires: python-requests
BuildRequires: python-coverage
BuildRequires: python-mock
BuildRequires: python-boto3
#BuildRequires: python-botocore
BuildRequires: git
BuildRequires: python-paramiko
BuildRequires: python-jmespath
BuildRequires: python-passlib
Requires: python-jinja2
Requires: PyYAML
Requires: python2-cryptography
Requires: python-six
Requires: sshpass
Requires: python-passlib
Requires: python-paramiko
Requires: python2-jmespath
# The ansible-doc package is no longer provided as of Ansible Engine 2.6.0
Obsoletes: ansible-doc < 2.6.0
%endif # Requires for RHEL 7
%endif # Requires for RHEL 8
# FEDORA >= 29
%if 0%{?fedora} >= 29
BuildRequires: python3-devel
BuildRequires: python3-setuptools
Requires: python3-PyYAML
Requires: python3-paramiko
Requires: python3-jinja2
Requires: python3-httplib2
Requires: python3-setuptools
Requires: python3-six
Requires: sshpass
%endif
# SUSE/openSUSE
%if 0%{?suse_version}
BuildRequires: python-devel
BuildRequires: python-setuptools
Requires: python-paramiko
Requires: python-jinja2
Requires: python-yaml
Requires: python-httplib2
Requires: python-setuptools
Requires: python-six
Requires: sshpass
%endif
%description
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.
%package -n ansible-test
Summary: Tool for testing ansible plugin and module code
Requires: %{name}-%{version}-%{release}
%if 0%{?rhel} >= 8
# Will use the python3 stdlib venv
#Requires: python3-virtualenv
#BuildRequires: python3-virtualenv
%else
%if 0%{?rhel} >= 7
Requires: python-virtualenv
BuildRequires: python-virtualenv
%endif # Requires for RHEL 7
%endif # Requires for RHEL 8
# SUSE/openSUSE
%if 0%{?suse_version}
Requires: python-virtualenv
BuildRequires: python-virtualenv
%endif
%description -n ansible-test
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 the ansible-test command for testing modules and plugins
developed for ansible.
%prep
%setup -q -n %{name}-%{upstream_version}
%build
%if %{with_python2}
%{__python2} setup.py build
%endif
%if %{with_python3}
%py3_build
%endif
%install
%if %{with_python2}
%{__python2} setup.py install --root=%{buildroot}
for i in %{buildroot}/%{_bindir}/{ansible,ansible-console,ansible-doc,ansible-galaxy,ansible-playbook,ansible-pull,ansible-vault} ; do
mv $i $i-%{python2_version}
ln -s %{_bindir}/$(basename $i)-%{python2_version} $i
ln -s %{_bindir}/$(basename $i)-%{python2_version} $i-2
done
%endif
%if %{with_python3}
%{__python3} setup.py install --root=%{buildroot}
%endif
# Amazon Linux doesn't install to dist-packages but python_sitelib expands to
# that location and the python interpreter expects things to be there.
if expr x'%{python_sitelib}' : 'x.*dist-packages/\?' ; then
DEST_DIR='%{buildroot}%{python_sitelib}'
SOURCE_DIR=$(echo "$DEST_DIR" | sed 's/dist-packages/site-packages/g')
if test -d "$SOURCE_DIR" -a ! -d "$DEST_DIR" ; then
mv $SOURCE_DIR $DEST_DIR
fi
fi
# Create system directories that Ansible defines as default locations in
# ansible/config/base.yml
DATADIR_LOCATIONS='%{_datadir}/ansible/collections
%{_datadir}/ansible/plugins/doc_fragments
%{_datadir}/ansible/plugins/action
%{_datadir}/ansible/plugins/become
%{_datadir}/ansible/plugins/cache
%{_datadir}/ansible/plugins/callback
%{_datadir}/ansible/plugins/cliconf
%{_datadir}/ansible/plugins/connection
%{_datadir}/ansible/plugins/filter
%{_datadir}/ansible/plugins/httpapi
%{_datadir}/ansible/plugins/inventory
%{_datadir}/ansible/plugins/lookup
%{_datadir}/ansible/plugins/modules
%{_datadir}/ansible/plugins/module_utils
%{_datadir}/ansible/plugins/netconf
%{_datadir}/ansible/roles
%{_datadir}/ansible/plugins/strategy
%{_datadir}/ansible/plugins/terminal
%{_datadir}/ansible/plugins/test
%{_datadir}/ansible/plugins/vars'
UPSTREAM_DATADIR_LOCATIONS=$(grep -ri default lib/ansible/config/base.yml| tr ':' '\n' | grep '/usr/share/ansible')
if [ "$SYSTEM_LOCATIONS" != "$UPSTREAM_SYSTEM_LOCATIONS" ] ; then
echo "The upstream Ansible datadir locations have changed. Spec file needs to be updated"
exit 1
fi
mkdir -p %{buildroot}%{_datadir}/ansible/plugins/
for location in $DATADIR_LOCATIONS ; do
mkdir %{buildroot}"$location"
done
mkdir -p %{buildroot}%{_sysconfdir}/ansible/
mkdir -p %{buildroot}%{_sysconfdir}/ansible/roles/
cp examples/hosts %{buildroot}%{_sysconfdir}/ansible/
cp examples/ansible.cfg %{buildroot}%{_sysconfdir}/ansible/
mkdir -p %{buildroot}/%{_mandir}/man1/
cp -v docs/man/man1/*.1 %{buildroot}/%{_mandir}/man1/
cp -pr docs/docsite/rst .
%clean
rm -rf %{buildroot}
%check
# We need pytest-4.5.0 or greater
%if 0%{?fedora} >= 31
ln -s /usr/bin/pytest-3 bin/pytest
%{__python3} bin/ansible-test units -v --python %{python3_version}
%endif
%files
%defattr(-,root,root)
%{_bindir}/ansible*
%config(noreplace) %{_sysconfdir}/ansible/
%doc README.rst PKG-INFO COPYING changelogs/CHANGELOG*.rst
%doc %{_mandir}/man1/ansible*
%{_datadir}/ansible/
%if %{with_python3}
%{python3_sitelib}/ansible*
%exclude %{python3_sitelib}/ansible_test
%endif
%if %{with_python2}
%{python2_sitelib}/ansible*
%exclude %{python2_sitelib}/ansible_test
%endif
%files -n ansible-test
%{_bindir}/ansible-test
%if %{with_python3}
%{python3_sitelib}/ansible_test
%endif
%if %{with_python2}
%{python2_sitelib}/ansible_test
%endif
%changelog
* %{release_date} Ansible, Inc. <info@ansible.com> - %{rpmversion}-%{rpmrelease}
- Release %{rpmversion}-%{rpmrelease}
|