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

- Forked from the example role.

- Seems done.
parent 2fd72d97
No related branches found
No related tags found
No related merge requests found
......@@ -9,13 +9,10 @@ env:
- VBOX_MEMORY=2048
- VBOX_HWVIRTEX=off
matrix:
- TOXENV=openbsd60
- TOXENV=xenial
- TOXENV=trusty
- TOXENV=precise
- &stretch TOXENV=stretch
- &jessie TOXENV=jessie
- TOXENV=wheezy
cache:
- pip
......
Example
Node.js
#######
.. image:: https://travis-ci.org/adarnimrod/example.svg?branch=master
:target: https://travis-ci.org/adarnimrod/example
.. image:: https://travis-ci.org/adarnimrod/nodejs.svg?branch=master
:target: https://travis-ci.org/adarnimrod/nodejs
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/>`_.
Install Node.js on Debian or Ubuntu from packages in NodeSource' repository.
Requirements
------------
......
---
# defaults file for example
# defaults file for nodejs
nodejs_version: 8 # or 6.
---
# handlers file for example
# handlers file for nodejs
galaxy_info:
author: Nimrod Adar
description: An example Ansible role
description: Install Node.js on Debian or Ubuntu from packages in NodeSource' repository
company: Shore technologies
license: MIT
min_ansible_version: 2.3
platforms:
- name: OpenBSD
versions:
- 6.0
- name: Ubuntu
versions:
- xenial
- trusty
- precise
- name: Debian
versions:
- stretch
- jessie
- wheezy
galaxy_tags: [ ansible ]
galaxy_tags: [ nodejs ]
dependencies: []
......@@ -35,7 +35,7 @@ vagrant:
- name: wheezy
box: bmorg/debian-wheezy-i386
instances:
- name: example
- name: nodejs
options:
append_platform_to_hostname: yes
raw_config_args:
......
---
# tasks file for example
# tasks file for nodejs
- name: Assertions
assert:
that:
- ansible_os_family in ['OpenBSD', 'Debian']
- ansible_distribution_release in ['xenial', 'trusty', 'precise', 'stretch', 'jessie', 'wheezy'] or ansible_distribution_version in ['6.0']
- ansible_os_family == 'Debian'
- ansible_lsb.codename in ['buster', 'jessie', 'sid', 'stretch', 'trusty', 'xenial', 'yakkety', 'zesty']
- nodejs_version in [6, 8]
- name: APT install prerequisites
apt:
name: apt-transport-https
state: present
update_cache: True
cache_valid_time: 3600
- name: Add APT repository key
apt_key:
url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
state: present
- name: Add APT repository
apt_repository:
repo: |
deb https://deb.nodesource.com/node_{{ nodejs_version }}.x {{ ansible_lsb.codename }} main
state: present
update_cache: True
- name: APT install
apt:
name: nodejs
state: present
update_cache: True
cache_valid_time: 3600
---
- hosts: example-openbsd*
- hosts: nodejs-openbsd*
gather_facts: false
roles:
- openbsd-bootstrap
......@@ -8,7 +8,7 @@
users_use_sudo: True
users_lock_root_ssh: False
- hosts: [example-xenial, example-wheezy]
- hosts: [nodejs-xenial, nodejs-wheezy]
gather_facts: false
roles:
- debian-bootstrap
......@@ -19,4 +19,4 @@
- hosts: all
roles:
- role: example
- role: nodejs
from testinfra.utils.ansible_runner import AnsibleRunner
testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all')
def test_nodejs(host):
assert host.run('node --version').rc == 0
assert host.run('nodejs --version').rc == 0
def test_root(host):
assert host.run('npm --version').rc == 0
[tox]
skip_install = True
skipsdist = True
envlist = openbsd60,xenial,trusty,precise,stretch,jessie,wheezy
envlist = xenial,trusty,stretch,jessie
[testenv]
envdir = {toxinidir}/.tox/molecule
......
---
# vars file for example
# vars file for nodejs
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment