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: ...@@ -9,13 +9,10 @@ env:
- VBOX_MEMORY=2048 - VBOX_MEMORY=2048
- VBOX_HWVIRTEX=off - VBOX_HWVIRTEX=off
matrix: matrix:
- TOXENV=openbsd60
- TOXENV=xenial - TOXENV=xenial
- TOXENV=trusty - TOXENV=trusty
- TOXENV=precise
- &stretch TOXENV=stretch - &stretch TOXENV=stretch
- &jessie TOXENV=jessie - &jessie TOXENV=jessie
- TOXENV=wheezy
cache: cache:
- pip - pip
......
Example Node.js
####### #######
.. image:: https://travis-ci.org/adarnimrod/example.svg?branch=master .. image:: https://travis-ci.org/adarnimrod/nodejs.svg?branch=master
:target: https://travis-ci.org/adarnimrod/example :target: https://travis-ci.org/adarnimrod/nodejs
An (empty) example Ansible role complete with working tests out of the box. For Install Node.js on Debian or Ubuntu from packages in NodeSource' repository.
more information read the `blog post
<https://www.shore.co.il/blog/ansible-example-role/>`_.
Requirements Requirements
------------ ------------
......
--- ---
# defaults file for example # defaults file for nodejs
nodejs_version: 8 # or 6.
--- ---
# handlers file for example # handlers file for nodejs
galaxy_info: galaxy_info:
author: Nimrod Adar author: Nimrod Adar
description: An example Ansible role description: Install Node.js on Debian or Ubuntu from packages in NodeSource' repository
company: Shore technologies company: Shore technologies
license: MIT license: MIT
min_ansible_version: 2.3 min_ansible_version: 2.3
platforms: platforms:
- name: OpenBSD
versions:
- 6.0
- name: Ubuntu - name: Ubuntu
versions: versions:
- xenial - xenial
- trusty - trusty
- precise
- name: Debian - name: Debian
versions: versions:
- stretch - stretch
- jessie - jessie
- wheezy galaxy_tags: [ nodejs ]
galaxy_tags: [ ansible ]
dependencies: [] dependencies: []
...@@ -35,7 +35,7 @@ vagrant: ...@@ -35,7 +35,7 @@ vagrant:
- name: wheezy - name: wheezy
box: bmorg/debian-wheezy-i386 box: bmorg/debian-wheezy-i386
instances: instances:
- name: example - name: nodejs
options: options:
append_platform_to_hostname: yes append_platform_to_hostname: yes
raw_config_args: raw_config_args:
......
--- ---
# tasks file for example # tasks file for nodejs
- name: Assertions - name: Assertions
assert: assert:
that: that:
- ansible_os_family in ['OpenBSD', 'Debian'] - ansible_os_family == 'Debian'
- ansible_distribution_release in ['xenial', 'trusty', 'precise', 'stretch', 'jessie', 'wheezy'] or ansible_distribution_version in ['6.0'] - 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 gather_facts: false
roles: roles:
- openbsd-bootstrap - openbsd-bootstrap
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
users_use_sudo: True users_use_sudo: True
users_lock_root_ssh: False users_lock_root_ssh: False
- hosts: [example-xenial, example-wheezy] - hosts: [nodejs-xenial, nodejs-wheezy]
gather_facts: false gather_facts: false
roles: roles:
- debian-bootstrap - debian-bootstrap
...@@ -19,4 +19,4 @@ ...@@ -19,4 +19,4 @@
- hosts: all - hosts: all
roles: 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] [tox]
skip_install = True skip_install = True
skipsdist = True skipsdist = True
envlist = openbsd60,xenial,trusty,precise,stretch,jessie,wheezy envlist = xenial,trusty,stretch,jessie
[testenv] [testenv]
envdir = {toxinidir}/.tox/molecule 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