-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1447626
commit 798db5d
Showing
11 changed files
with
213 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
language: python | ||
python: "2.7" | ||
|
||
# Install ansible | ||
addons: | ||
apt: | ||
packages: | ||
- python-pip | ||
|
||
install: | ||
# Install ansible | ||
- pip install ansible | ||
# Check ansible version | ||
- ansible --version | ||
# Create ansible.cfg with correct roles_path | ||
- printf '[defaults]\nroles_path=../' >ansible.cfg | ||
|
||
script: | ||
# Basic role syntax check | ||
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check | ||
- ansible-playbook tests/test.yml -c local -i tests/inventory | ||
|
||
notifications: | ||
webhooks: https://galaxy.ansible.com/api/v1/notifications/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
ansible-olsrd2 | ||
============== | ||
|
||
Automatically install and upgrade olsrd2 on debian based linux distributions via ansible. | ||
|
||
Role Variables | ||
-------------- | ||
|
||
```yaml | ||
olsrd2_build_dependencies: | ||
- build-essential | ||
- libnl-3-dev | ||
- cmake | ||
- git | ||
- libnl-genl-3-dev | ||
- libnl-utils | ||
- pkg-config | ||
- doxygen | ||
- devscripts | ||
- dh-systemd | ||
olsrd2_dir: "/opt/olsrd2" | ||
olsrd2_source_repo: https://github.com/OLSR/OONF.git | ||
olsrd2_source_dir: "{{ olsrd2_dir }}/source" | ||
olsrd2_source_version: HEAD # master | ||
olsrd2_git_email: "git@{{ ansible_domain }}" | ||
olsrd2_git_name: "{{ ansible_user }}" | ||
``` | ||
Example Playbook | ||
---------------- | ||
```yaml | ||
- hosts: myserver | ||
roles: | ||
- ninux.olsrd2 | ||
vars: | ||
olsrd2_interfaces: | ||
- eth0 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
olsrd2_build_dependencies: | ||
- build-essential | ||
- libnl-3-dev | ||
- cmake | ||
- git | ||
# deb | ||
- libnl-genl-3-dev | ||
- libnl-utils | ||
- pkg-config | ||
- doxygen | ||
- devscripts | ||
- dh-systemd | ||
olsrd2_dir: "/opt/olsrd2" | ||
olsrd2_source_repo: https://github.com/OLSR/OONF.git | ||
olsrd2_source_dir: "{{ olsrd2_dir }}/source" | ||
olsrd2_source_version: HEAD # master | ||
olsrd2_git_email: "git@{{ ansible_domain }}" | ||
olsrd2_git_name: "{{ ansible_user }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
- name: restart olsrd2 | ||
become: true | ||
service: | ||
name: olsrd2 | ||
state: restarted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
|
||
dependencies: [] | ||
|
||
galaxy_info: | ||
author: Federico Capoano | ||
company: Ninux | ||
description: compile, install and upgrade olsrd2 (also known as OLSR.org Network Framework) | ||
license: BSD | ||
min_ansible_version: 2.2 | ||
platforms: | ||
- name: Debian | ||
versions: | ||
- wheezy | ||
- jessie | ||
- name: Ubuntu | ||
versions: | ||
- trusty | ||
- xenial | ||
galaxy_tags: | ||
- system | ||
- networking |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
- name: Update APT package cache | ||
become: true | ||
apt: update_cache=yes | ||
|
||
- name: Install/upgrade dependencies | ||
become: true | ||
package: | ||
name: "{{ item }}" | ||
state: latest | ||
with_items: "{{ olsrd2_build_dependencies }}" | ||
|
||
- name: "Create {{ olsrd2_dir }}" | ||
become: true | ||
file: | ||
path: "{{ olsrd2_dir }}" | ||
state: directory | ||
owner: "{{ ansible_user }}" | ||
group: sudo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
- name: Update olsrd2 git repo | ||
git: | ||
repo: "{{ olsrd2_source_repo }}" | ||
dest: "{{ olsrd2_source_dir }}" | ||
version: "{{ olsrd2_source_version }}" | ||
|
||
- name: "set git user.email to {{ olsrd2_git_email }}" | ||
git_config: | ||
name: user.email | ||
scope: global | ||
value: "{{ olsrd2_git_email }}" | ||
|
||
- name: "set git user.name to {{ olsrd2_git_name }}" | ||
git_config: | ||
name: user.name | ||
scope: global | ||
value: "{{ olsrd2_git_name }}" | ||
|
||
- shell: 'git describe --abbrev=0 | sed -e "s/^v//"' | ||
args: | ||
chdir: "{{ olsrd2_source_dir }}/files" | ||
register: _VERSION | ||
|
||
- shell: 'git rev-list v{{ _VERSION.stdout }}..HEAD --count' | ||
args: | ||
chdir: "{{ olsrd2_source_dir }}/files" | ||
register: _VERSIONCOUNT | ||
|
||
- set_fact: | ||
olsrd2_deb_file: "olsrd2_{{ _VERSION.stdout }}-{{ _VERSIONCOUNT.stdout }}_amd64.deb" | ||
|
||
- name: check if deb package has been already compiled | ||
stat: | ||
path: "{{ olsrd2_dir }}/{{ olsrd2_deb_file }}" | ||
register: deb_package | ||
|
||
- name: launch ./create_debian_package.sh | ||
when: not deb_package.stat.exists | ||
shell: ./create_debian_package.sh | ||
args: | ||
chdir: "{{ olsrd2_source_dir }}/files" | ||
|
||
- name: "move deb package to {{ olsrd2_dir }}" | ||
when: not deb_package.stat.exists | ||
shell: "mv *.deb {{ olsrd2_dir }}" | ||
args: | ||
chdir: "{{ olsrd2_source_dir }}" | ||
|
||
- name: "install {{ olsrd2_deb_file }}" | ||
when: not deb_package.stat.exists | ||
become: true | ||
apt: | ||
deb: "{{ olsrd2_dir }}/{{ olsrd2_deb_file }}" | ||
notify: [restart olsrd2] | ||
|
||
- name: configure olsrd2 | ||
become: true | ||
template: | ||
src: olsrd2.conf.j2 | ||
dest: /etc/olsrd2/olsrd2.conf | ||
notify: [restart olsrd2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
- name: Ensure not executing as root | ||
fail: | ||
msg: "Cannot compile olsrd2 as root" | ||
when: ansible_user == "root" | ||
tags: [olsrd2, dependencies] | ||
|
||
# installs build dependencies and retrieves source code | ||
- include: 1-dependencies.yml | ||
tags: [olsrd2, dependencies] | ||
|
||
# generates debian package and installs or upgrades it if necessary | ||
- include: 2-install.yml | ||
tags: [olsrd2, install] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[olsrv2] | ||
{% for interface in olsrd2_interfaces %} | ||
[interface={{ interface }}] | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
localhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
- hosts: localhost | ||
remote_user: root | ||
roles: | ||
- olsrd2 |