From 4ee77ce0263370535b4d99c294445740977727ad Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Fri, 18 Aug 2017 11:46:17 +0200 Subject: [PATCH 1/6] Add an RPM spec file and customize ansible roles_path Install roles under /usr/local/share/kubespray/roles, playbooks - /usr/local/share/kubespray/playbooks/, ansible.cfg and inventory group vars - into /etc/kubespray. Ship README and an example inventory as the package docs. Update the ansible.cfg to consume the roles from the given path, including virtualenvs prefix, if defined. Signed-off-by: Bogdan Dobrelya --- ansible.cfg | 1 + contrib/ansible-kubespray.spec | 57 ++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 contrib/ansible-kubespray.spec diff --git a/ansible.cfg b/ansible.cfg index d1741836a..aecb198a0 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -10,3 +10,4 @@ fact_caching_connection = /tmp stdout_callback = skippy library = ./library callback_whitelist = profile_tasks +roles_path = roles:$VIRTUAL_ENV/usr/local/share/kubespray/roles:$VIRTUAL_ENV/usr/local/share/ansible/roles diff --git a/contrib/ansible-kubespray.spec b/contrib/ansible-kubespray.spec new file mode 100644 index 000000000..53a67898f --- /dev/null +++ b/contrib/ansible-kubespray.spec @@ -0,0 +1,57 @@ +%global srcname ansible_kubespray + +%{!?upstream_version: %global upstream_version %{version}%{?milestone}} + +Name: ansible-kubespray +Version: XXX +Release: XXX +Summary: Ansible modules for installing Kubernetes clusters + +Group: System Environment/Base +License: ASL 2.0 +URL: https://github.com/kubernetes-incubator/kubespray +Source0: https://github.com/kubernetes-incubator/kubespray/archive/%{upstream_version}.tar.gz + +BuildArch: noarch +BuildRequires: git +BuildRequires: python2-devel +BuildRequires: python-setuptools +BuildRequires: python-d2to1 +BuildRequires: python-pbr + +Requires: ansible +Requires: python-jinja2 +Requires: python-netaddr + +%description + +Ansible-kubespray is a set of Ansible modules and playbooks for installing +a Kubernetes cluster. + +%prep +%autosetup -n %{name}-%{upstream_version} -S git + + +%build +%{__python2} setup.py build + + +%install +export PBR_VERSION=%{version} +export SKIP_PIP_INSTALL=1 +%{__python2} setup.py install --skip-build --root %{buildroot} + + +%files +%doc README.md +%doc inventory/inventory.example +%config /etc/kubespray/ansible.cfg +%config /etc/kubespray/inventory/group_vars/all.yml +%config /etc/kubespray/inventory/group_vars/k8s-cluster.yml +%license LICENSE +%{python2_sitelib}/%{srcname}-%{version}-py%{python2_version}.egg-info +/usr/local/share/kubespray/roles/ +/usr/local/share/kubespray/playbooks/ + + +%changelog From 31d357284af9872cfa83527a002d26b0bba7c70c Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Fri, 18 Aug 2017 11:58:07 +0200 Subject: [PATCH 2/6] Update gitignore to prepare for a package build Signed-off-by: Bogdan Dobrelya --- .gitignore | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 76 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index f4c7d990a..8d5d5088b 100644 --- a/.gitignore +++ b/.gitignore @@ -8,12 +8,85 @@ temp .tox .cache *.bak -*.egg-info -*.pyc -*.pyo *.tfstate *.tfstate.backup **/*.sw[pon] /ssh-bastion.conf **/*.sw[pon] vagrant/ + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# IPython Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# dotenv +.env + +# virtualenv +venv/ +ENV/ From 8058cdbc0e8d68757abec51592eff31210ceb5d6 Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Fri, 18 Aug 2017 12:02:32 +0200 Subject: [PATCH 3/6] Add pbr build configuration Required for an RPM package builds with the contrib/ansible-kubespray.spec Signed-off-by: Bogdan Dobrelya --- requirements.txt | 1 + setup.cfg | 41 +++++++++++++++++++++++++++++++++++++++++ setup.py | 19 +++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 setup.cfg create mode 100644 setup.py diff --git a/requirements.txt b/requirements.txt index 6458113ac..31181e7ac 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +pbr>=1.6 ansible>=2.3.0 netaddr jinja2>=2.9.6 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 000000000..c5d83fd63 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,41 @@ +[metadata] +name = ansible-kubespray +summary = Ansible modules for installing Kubernetes +description-file = + README.md +author = Kubespray +author-email = smainklh@gmail.com +home-page = https://github.com/kubernetes-incubator/kubespray +classifier = + License :: OSI Approved :: Apache Software License + Development Status :: 4 - Beta + Intended Audience :: Developers + Intended Audience :: System Administrators + Intended Audience :: Information Technology + Topic :: Utilities + +[global] +setup-hooks = + pbr.hooks.setup_hook + +[files] +data_files = + /usr/local/share/kubespray/playbooks/ = + cluster.yml + upgrade-cluster.yml + scale.yml + reset.yml + extra_playbooks/upgrade-only-k8s.yml + /etc/kubespray/inventory/ = + inventory/group_vars/all.yml + inventory/group_vars/k8s-cluster.yml + /etc/kubespray/ = + ansible.cfg + /usr/local/share/kubespray/roles = roles/* + +[wheel] +universal = 1 + +[pbr] +skip_authors = True +skip_changelog = True diff --git a/setup.py b/setup.py new file mode 100644 index 000000000..6a931a61c --- /dev/null +++ b/setup.py @@ -0,0 +1,19 @@ +# Copyright Red Hat, Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import setuptools + +setuptools.setup( + setup_requires=['pbr'], + pbr=True) From db121049b315fa524a80ce9ef1f055a9665b1641 Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Fri, 18 Aug 2017 13:59:27 +0200 Subject: [PATCH 4/6] Move the spec file Signed-off-by: Bogdan Dobrelya --- contrib/{ => packaging/rpm}/ansible-kubespray.spec | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename contrib/{ => packaging/rpm}/ansible-kubespray.spec (100%) diff --git a/contrib/ansible-kubespray.spec b/contrib/packaging/rpm/ansible-kubespray.spec similarity index 100% rename from contrib/ansible-kubespray.spec rename to contrib/packaging/rpm/ansible-kubespray.spec From 48edf1757baabbb79249db8ae891b111d43672f5 Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Fri, 18 Aug 2017 14:09:55 +0200 Subject: [PATCH 5/6] Adjust the rpm spec data Signed-off-by: Bogdan Dobrelya --- contrib/packaging/rpm/ansible-kubespray.spec | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/contrib/packaging/rpm/ansible-kubespray.spec b/contrib/packaging/rpm/ansible-kubespray.spec index 53a67898f..1876e0c35 100644 --- a/contrib/packaging/rpm/ansible-kubespray.spec +++ b/contrib/packaging/rpm/ansible-kubespray.spec @@ -5,11 +5,12 @@ Name: ansible-kubespray Version: XXX Release: XXX -Summary: Ansible modules for installing Kubernetes clusters +Summary: Ansible modules for installing Kubernetes -Group: System Environment/Base +Group: System Environment/Libraries License: ASL 2.0 -URL: https://github.com/kubernetes-incubator/kubespray +Vendor: Kubespray +Url: https://github.com/kubernetes-incubator/kubespray Source0: https://github.com/kubernetes-incubator/kubespray/archive/%{upstream_version}.tar.gz BuildArch: noarch @@ -25,8 +26,9 @@ Requires: python-netaddr %description -Ansible-kubespray is a set of Ansible modules and playbooks for installing -a Kubernetes cluster. +Ansible-kubespray is a set of Ansible modules and playbooks for +installing a Kubernetes cluster. If you have questions, join us +on the https://slack.k8s.io, channel '#kubespray'. %prep %autosetup -n %{name}-%{upstream_version} -S git @@ -52,6 +54,7 @@ export SKIP_PIP_INSTALL=1 %{python2_sitelib}/%{srcname}-%{version}-py%{python2_version}.egg-info /usr/local/share/kubespray/roles/ /usr/local/share/kubespray/playbooks/ +%defattr(-,root,root) %changelog From 668d02846d5f2a61c3d3e2b6e18671a00972d93a Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Fri, 18 Aug 2017 16:04:48 +0200 Subject: [PATCH 6/6] Align pbr config data with the spec file Signed-off-by: Bogdan Dobrelya --- setup.cfg | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index c5d83fd63..3e147d6b8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -26,12 +26,16 @@ data_files = scale.yml reset.yml extra_playbooks/upgrade-only-k8s.yml + /usr/local/share/kubespray/roles = roles/* +doc_files = + README.md + inventory/inventory.example +config_files = + /etc/kubespray/ = + ansible.cfg /etc/kubespray/inventory/ = inventory/group_vars/all.yml inventory/group_vars/k8s-cluster.yml - /etc/kubespray/ = - ansible.cfg - /usr/local/share/kubespray/roles = roles/* [wheel] universal = 1 @@ -39,3 +43,10 @@ universal = 1 [pbr] skip_authors = True skip_changelog = True + +[bdist_rpm] +group = "System Environment/Libraries" +requires = + ansible + python-jinja2 + python-netaddr