Skip to content
Snippets Groups Projects
Commit 468bd332 authored by nimrod's avatar nimrod
Browse files

- Forked from the example role.

- Works fine, passes tests in Docker.
- Need to find working Vagrant boxes (these don't work properly).
parent 6785200a
Branches
No related tags found
No related merge requests found
......@@ -14,6 +14,7 @@ install:
- pip install -r tests/requirements.txt | cat
- ansible-galaxy install git+file://$(pwd),$(git rev-parse --abbrev-ref HEAD) -p .molecule/roles
- molecule dependency
- for version in 14.07 15.05; do docker pull xdrum/openwrt:$version; done
script:
- pre-commit run --all-files
......
Example
#######
OpenWRT bootstrap
#################
.. image:: https://travis-ci.org/adarnimrod/example.svg?branch=master
:target: https://travis-ci.org/adarnimrod/example
.. image:: https://travis-ci.org/adarnimrod/openwrt-bootstrap.svg?branch=master
:target: https://travis-ci.org/adarnimrod/openwrt-bootstrap
An (empty) example Ansible role complete with working tests out of the box. For
more information read the `blog post
<https://www.shore.co.il/blog/ansible-example-role/>`_.
Bootstrap an OpenWRT instance (allow Ansible to provision the instance).
Requirements
------------
......@@ -61,3 +59,8 @@ Nimrod Adar, `contact me <nimrod@shore.co.il>`_ or visit my `website
<https://www.shore.co.il/>`_. Patches are welcome via `git send-email
<http://git-scm.com/book/en/v2/Git-Commands-Email>`_. The repository is located
at: https://www.shore.co.il/git/.
TODO
----
- Working tests using Vagrant.
---
# defaults file for example
# defaults file for openwrt-bootstrap
---
# handlers file for example
# handlers file for openwrt-bootstrap
galaxy_info:
author: Nimrod Adar
description: An example Ansible role
description: Bootstrap an OpenWRT instance (allow Ansible to provision the instance)
company: Shore technologies
license: MIT
min_ansible_version: 2.0
platforms:
- name: OpenBSD
- name: OpenWRT
versions:
- 6.0
- name: Ubuntu
versions:
- xenial
galaxy_tags: [ ansible ]
- 14.07
- 15.05
galaxy_tags: [ ansible, openwrt ]
dependencies: []
......@@ -14,12 +14,12 @@ vagrant:
- name: virtualbox
type: virtualbox
platforms:
- name: openbsd
box: kaorimatz/openbsd-6.0-amd64
- name: xenial
box: ubuntu/xenial64
- name: '14.07'
box: qqshfox/openwrt-barrier_breaker
- name: '15.05'
box: lifeeth/openwrt-15.05-x86
instances:
- name: example
- name: openwrt-bootstrap
options:
append_platform_to_hostname: yes
raw_config_args:
......@@ -29,15 +29,11 @@ vagrant:
- 'landrush_ip.override = false'
docker:
build_image: False
containers:
- name: example-xenial
image: ubuntu
image_version: xenial
command: /sbin/init
privileged: True
volume_mounts:
- /sys/fs/cgroup:/sys/fs/cgroup
- /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket
environment:
DEBIAN_FRONTEND: noninteractive
container: docker
- name: openwrt-bootstrap-15.05
image: xdrum/openwrt
image_version: 15.05
- name: openwrt-bootstrap-14.07
image: xdrum/openwrt
image_version: 14.07
---
# tasks file for example
# tasks file for openwrt-bootstrap
- name: Assertions
assert:
that:
- ansible_os_family in ['OpenBSD', 'Debian']
- ansible_distribution_release in ['6.0', 'xenial']
- name: Update opkg package lists
raw: opkg update
changed_when: False
- name: opkg install python
raw: opkg install python
register: openwrt_bootstrap_install_python
changed_when: "'Downloading' in openwrt_bootstrap_install_python.stdout"
- name: opkg install ip
opkg:
name: ip
state: present
---
- hosts: example-openbsd
gather_facts: false
roles: [openbsd-bootstrap]
- hosts: example-xenial
gather_facts: false
roles: [debian-bootstrap]
- hosts: all
gather_facts: False
strategy: free
roles:
- role: example
- role: openwrt-bootstrap
post_tasks:
- name: Test gathering facts
setup:
- name: Assertions
assert:
that:
- ansible_default_ipv4 is defined
......@@ -5,8 +5,3 @@ testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all')
def test_example(Command):
assert Command('uname').rc == 0
def test_root(Command, Sudo):
with Sudo():
assert Command('whoami').stdout.strip() == 'root'
from testinfra.utils.ansible_runner import AnsibleRunner
testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all')
def test_python(Command):
python = Command('python --version')
assert python.rc == 0
assert '2.7' in python.stderr
---
# vars file for example
# vars file for openwrt-bootstrap
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment