Skip to content

Commit

Permalink
Merge pull request #47 from mbukatov/issue_40
Browse files Browse the repository at this point in the history
RPM build for tendrl-ansible
  • Loading branch information
mbukatov committed Sep 27, 2017
2 parents 5600db3 + 8debad6 commit 29c6d57
Show file tree
Hide file tree
Showing 6 changed files with 231 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ site.yml
# ansible password lookup files
etcd_root_passwd
grafana_admin_passwd
# rpm build artefacts (created via Makefile)
*.tar.gz
*.rpm
tendrl-ansible-*
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
language: python
python:
- "2.7"
before_install:
- sudo apt-get -qq update
# - sudo apt-get install -y rpmlint
install:
- pip install yamllint
script:
- yamllint .
# - rpmlint tendrl-ansible.spec
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# based on Makefile of tendrl-commons

NAME = tendrl-ansible
VERSION = 1.5.3
COMMIT := $(shell git rev-parse HEAD)
SHORTCOMMIT := $(shell echo $(COMMIT) | cut -c1-7)

all: srpm

clean:
rm -rf $(NAME)-$(VERSION)
rm -rf $(NAME)-$(VERSION).tar.gz
rm -rf $(NAME)-$(VERSION)-*.el7.src.rpm

dist:
mkdir $(NAME)-$(VERSION)
cp -r roles $(NAME)-$(VERSION)
cp .yamllint $(NAME)-$(VERSION)
cp LICENSE $(NAME)-$(VERSION)
cp README.md $(NAME)-$(VERSION)
cp README.rpm.md $(NAME)-$(VERSION)
cp site.yml.sample $(NAME)-$(VERSION)
cp prechecks.yml $(NAME)-$(VERSION)
cp workaround.disable-firewall.yml $(NAME)-$(VERSION)
cp workaround.disable-selinux.yml $(NAME)-$(VERSION)
tar caf $(NAME)-$(VERSION).tar.gz $(NAME)-$(VERSION)

srpm: dist
fedpkg --dist epel7 srpm

rpm: dist
mock -r epel-7-x86_64 rebuild $(NAME)-$(VERSION)-*.src.rpm --resultdir=. --define "dist .el7"

gitversion:
# Set version and release to the latest values from Git
sed -i $(NAME).spec \
-e "/^Release:/cRelease: $(shell date +"%Y%m%dT%H%M%S").$(SHORTCOMMIT)"

snapshot: gitversion srpm


.PHONY: dist rpm srpm gitversion snapshot
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
tendrl-ansible
==============

Ansible playbook for [Tendrl](http://tendrl.org/)!
Ansible roles and playbooks for [Tendrl](http://tendrl.org/)!

Clone me:

Expand Down
77 changes: 77 additions & 0 deletions README.rpm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
tendrl-ansible
==============

Ansible roles and playbooks for [Tendrl](http://tendrl.org/)!


## What does it do?

There are ansible roles for installation of [Tendrl](http://tendrl.org/), based
on upstream Tendrl documentation. You should check this documentation to have
basic understanding of various machine roles in Tendrl cluster before using
tendrl-ansible.

To list all available roles, see directories prefixed with `tendrl-ansible.`
in `/usr/share/ansible/roles/`. Each role has it's own `README.md` file, where
you can find all details about it's usage.

To understand how all this fits together, see sample ansible playbook file
`/usr/share/doc/tendrl-ansible-VERSION/site.yml.sample`.

Also note that the sample playbook includes
`/usr/share/doc/tendrl-ansible-VERSION/prechecks.yml`, which you can run
directly as well to check if minimal requirements and setup for Tendrl are
satisfied. Any problem with the pre checks will make sample site.yml file
immediately fail, pointing you to a particular requirement or problem with
configuration before the installation itself (preventing you to spare time
with unnecessary debugging after installation).

## Basic setup

1) Install tendrl-ansible:

```
# yum install tendrl-ansible
```

2) Create Ansible inventory file with groups for `tendrl-server`
and `gluster-servers`. Here is an example of inventory
file for 4 node cluster with Gluster:

```
[gluster-servers]
gl1.example.com
gl2.example.com
gl3.example.com
gl4.example.com
[tendrl-server]
tendrl.example.com
```

3) Create `site.yml` file based on `site.yml.sample` and make sure to
define all ansible variables in the playbook to suit:

```
$ cp /usr/share/doc/tendrl-ansible-VERSION/site.yml.sample site.yml
$ vim site.yml
```

4) Then we are ready to run ansible to install Tendrl:

```
$ ansible-playbook -i inventory_file site.yml
```

Assuming we have deployed ssh keys on the machines and have a cluster
already installed and running there.

5) Log in to your tendrl server at ``http://ip.of.tendrl.server`` with
``admin`` user and the default password ``adminuser``.


## License

Distributed under the terms of the [GNU LGPL, version
2.1](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html) license,
tendrl-ansible is free and open source software.
103 changes: 103 additions & 0 deletions tendrl-ansible.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# This rpm spec file is based on packaging approach used by linux-system-roles
# project, as there are no Fedora packaging guidelines for ansible or better
# examples to follow. Target OS is RHEL or CentOS 7.

Name: tendrl-ansible
Version: 1.5.3
Release: 1%{?dist}
Summary: Ansible roles and playbooks for Tendrl

License: LGPLv2.1
Url: https://github.com/Tendrl/tendrl-ansible
Source0: %{name}-%{version}.tar.gz
BuildArch: noarch

Requires: ansible
Requires: python-dns
BuildRequires: yamllint

# All ansible roles from tendrl-ansible will have this prefix added into the
# name of the role (name of the directory with the role) to prevent conflicts.
%global roleprefix %{name}.

%description
Ansible roles and playbooks for installation of Tendrl, based on upstream
Tendrl documentation.


%prep
%setup -q

%build
# reference roles by prefixed name in sample playbook file
sed -i 's/- \(ceph-installer\)/- %{roleprefix}\1/g' site.yml.sample
sed -i 's/- \(gluster-gdeploy-copr\)/- %{roleprefix}\1/g' site.yml.sample
sed -i 's/- \(grafana-repo\)/- %{roleprefix}\1/g' site.yml.sample
sed -i 's/- \(tendrl-copr\)/- %{roleprefix}\1/g' site.yml.sample
sed -i 's/- \(tendrl-server\)/- %{roleprefix}\1/g' site.yml.sample
sed -i 's/- \(tendrl-storage-node\)/- %{roleprefix}\1/g' site.yml.sample

# reference playbooks by full paths in sample playbook file
sed -i 's!prechecks.yml!%{_pkgdocdir}/&!g' site.yml.sample
sed -i 's!workaround.disable-firewall.yml!%{_pkgdocdir}/&!g' site.yml.sample
sed -i 's!workaround.disable-selinux.yml!%{_pkgdocdir}/&!g' site.yml.sample

%install
mkdir -p $RPM_BUILD_ROOT%{_datadir}/ansible/roles

# install ansible roles
cp -pR roles/ceph-installer $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}ceph-installer
cp -pR roles/gluster-gdeploy-copr $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}gluster-gdeploy-copr
cp -pR roles/grafana-repo $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}grafana-repo
cp -pR roles/tendrl-copr $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}tendrl-copr
cp -pR roles/tendrl-server $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}tendrl-server
cp -pR roles/tendrl-storage-node $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}tendrl-storage-node

mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/

# install playbooks
install -p -m 644 site.yml.sample $RPM_BUILD_ROOT%{_pkgdocdir}/site.yml.sample
install -p -m 644 prechecks.yml $RPM_BUILD_ROOT%{_pkgdocdir}/prechecks.yml
install -p -m 644 workaround.disable-firewall.yml $RPM_BUILD_ROOT%{_pkgdocdir}/workaround.disable-firewall.yml
install -p -m 644 workaround.disable-selinux.yml $RPM_BUILD_ROOT%{_pkgdocdir}/workaround.disable-selinux.yml

# install readme and license files
install -p -m 644 README.rpm.md $RPM_BUILD_ROOT%{_pkgdocdir}/README.md
install -p -m 644 LICENSE $RPM_BUILD_ROOT%{_pkgdocdir}/LICENSE

%check
yamlint $RPM_BUILD_ROOT && rm .yamlint

%files
%{_datadir}/ansible/roles/%{roleprefix}ceph-installer
%{_datadir}/ansible/roles/%{roleprefix}gluster-gdeploy-copr
%{_datadir}/ansible/roles/%{roleprefix}grafana-repo
%{_datadir}/ansible/roles/%{roleprefix}tendrl-copr
%{_datadir}/ansible/roles/%{roleprefix}tendrl-server
%{_datadir}/ansible/roles/%{roleprefix}tendrl-storage-node

# mark readme files in ansible roles as documentation
%doc %{_datadir}/ansible/roles/%{roleprefix}ceph-installer/README.md
%doc %{_datadir}/ansible/roles/%{roleprefix}gluster-gdeploy-copr/README.md
%doc %{_datadir}/ansible/roles/%{roleprefix}grafana-repo/README.md
%doc %{_datadir}/ansible/roles/%{roleprefix}tendrl-copr/README.md
%doc %{_datadir}/ansible/roles/%{roleprefix}tendrl-server/README.md
%doc %{_datadir}/ansible/roles/%{roleprefix}tendrl-storage-node/README.md

# mark example site.yml file as documentation
%doc %{_pkgdocdir}/site.yml.sample

# playbooks (referenced in site.yml.sample) in doc dir (temporary HACK)
%doc %{_pkgdocdir}/prechecks.yml
%doc %{_pkgdocdir}/workaround.disable-firewall.yml
%doc %{_pkgdocdir}/workaround.disable-selinux.yml

# readme and license files
%doc %{_pkgdocdir}/README.md
%license %{_pkgdocdir}/LICENSE

%changelog
* Wed Sep 27 2017 Martin Bukatovič <mbukatov@redhat.com> - 1.5.3-1
- First release with tendrl-ansible provided in rpm package.
- Initial specfile based on rhel-system-roles packaging style.

0 comments on commit 29c6d57

Please sign in to comment.