Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
zenoamaro committed Mar 14, 2015
0 parents commit 3d4ab2f
Show file tree
Hide file tree
Showing 13 changed files with 355 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Don't commit vagrant's machine specifications,
# which are unique for each installation.
/.vagrant/

# Ignore some common junk.
*~
*.swp
*.lock
*.orig
*.retry
.DS_Store
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---

# Configuration directives for Travis CI
# --------------------------------------
# See the Travis documentation for help on writing this file.
#
# [Travis CI] http://travis-ci.org
# [configuration] http://about.travis-ci.org/docs/user/build-configuration/


language: python

python:
- "2.7"

install:
- pip install ansible

script:
# Syntax check every ansible playbook in root
# Don't check main, though, as vars_prompt still
# trigger during syntax checks, and travis fails
- find . -maxdepth 1 -type f -name '*.yml' -not -name '.*' -not -name 'main.yml' | xargs -t -n1 ansible-playbook --syntax-check -i inventory
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015, zenoamaro <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
90 changes: 90 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
io.js for Ansible
======================
A role for deploying and configuring [io.js](http://iojs.com) on unix hosts using [Ansible](http://www.ansibleworks.com).

It can additionally be used as a playbook for quickly provisioning hosts.

Vagrant machines are provided to produce a boxed install of io.js or a VM for integration testing.


Supports
--------
Supported io.js versions:
- io.js 1.x

Supported targets:
- Ubuntu 14.04 LTS "Trusty Tahr"
- Debian (untested)

Installation methods:
- Packages from [NodeSource](http://iojs.com/docs/install/)


Usage
-----
Clone this repo into your roles directory:

$ git clone https://github.com/zenoamaro/ansible-iojs.git roles/iojs

And add it to your play's roles:

- hosts: ...
roles:
- iojs
- ...

See the annotated defaults in [defaults/main.yml](defaults/main.yml) for help in configuration. All provided variables start with `iojs_`.

It is recommended that you pin your io.js version by setting `iojs_version` to something like `1.5.1`, or `1.5.*` as io.js follows semver.

You can also use the role as a playbook. You will be asked which hosts to provision, and you can further configure the play by using `--extra-vars`.

$ ansible-playbook -i inventory --extra-vars='{...}' main.yml

To provision a standalone box, start the `boxed` VM, which is a Ubuntu 14.04 box. After that, you will have iojs available as `iojs` or `node`.

$ vagrant up boxed

Run the tests by provisioning the appropriate VM:

$ vagrant up test-ubuntu-trusty

At the moment, the following test boxes are available:

- `test-ubuntu-trusty`


Still to do
-----------
- RedHat repositories


Changelog
---------
### 0.1.0
Initial version.


License
-------
The MIT License (MIT)

Copyright (c) 2015, zenoamaro <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
49 changes: 49 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure '2' do |config|


# Standalone box
# --------------

# Provision this machine to obtain a standalone box
# listening on the default ports.

config.vm.define 'boxed' do |box|
box.vm.box = "ubuntu/trusty64"
# Configure the network topology to your needs
config.vm.network :private_network, ip: "192.168.33.10"
# config.vm.network :public_network
config.vm.provision :ansible do |ansible|
ansible.playbook = './boxed.yml'
ansible.inventory_path = './inventory'
end
end


# Test machines
# -------------

# These test machines will configure the installation with all
# its extensions enabled, in order to test the validity
# of the role.

# Ubuntu machines are available:
# - "test-ubuntu-trusty"

def apply_test_ansible_defaults(ansible)
ansible.playbook = './test.yml'
ansible.inventory_path = './inventory'
end

config.vm.define 'test-ubuntu-trusty', autostart:false do |box|
box.vm.box = "ubuntu/trusty64"
config.vm.network :private_network, ip: "192.168.33.20"
config.vm.provision :ansible do |ansible|
apply_test_ansible_defaults ansible
ansible.extra_vars = {}
end
end

end
11 changes: 11 additions & 0 deletions boxed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---

# Simple, straight playbook for boxed io.js installs

- name: 'io.js boxed installation'

hosts: boxed

roles:
- '.' # This role itself

3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Pin iojs on this version.
# You can use wildcards here.
iojs_version: '1.5.*'
15 changes: 15 additions & 0 deletions inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[boxed]
192.168.33.10 ansible_ssh_private_key_file=.vagrant/machines/boxed/virtualbox/private_key

[test-ubuntu-trusty]
192.168.33.20 ansible_ssh_private_key_file=.vagrant/machines/test-ubuntu-trusty/virtualbox/private_key

[test:children]
test-ubuntu-trusty

[vagrant:children]
test
boxed

[vagrant:vars]
ansible_ssh_user=vagrant
19 changes: 19 additions & 0 deletions main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---

# Quick-provisioning playbook
# ---------------------------

# A Simple, straight playbook for quick remote installations.
# You will be asked which hosts to provision before-hand.


- name: 'io.js'

vars_prompt:
selected_hosts: Specify the hosts to provision

hosts: "{{selected_hosts}}"

roles:
- '.' # The current directory itself is the role

25 changes: 25 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---

galaxy_info:
author: zenoamaro
description: A role to install and configure io.js and NPM.
version: 0.1.0
license: MIT
min_ansible_version: 1.6

platforms:

- name: Debian
versions:
- jessie
- sid

- name: Ubuntu
versions:
- trusty

categories:
- web
- development

dependencies: []
58 changes: 58 additions & 0 deletions tasks/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---

# Targeting specific OSes or distributions:
#
# - `ansible_system` → Linux, BSD, ...
# - `ansible_os_family` → Debian, RedHat, ...
# - `ansible_distribution` → Debian, Ubuntu, RedHat, ...
# - `ansible_distribution_release` → precise, wheezy, ...
# - `ansible_pkg_mgr` → apt, yum, ...
# - `ansible_architecture` → x86_64, x86_32, ...


# Debian
# ------

- name: Adding APT repository key
when: ansible_os_family == 'Debian'
sudo: yes
apt_key:
url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
tags:
- deps
- web
- iojs

- name: Adding APT repository
when: ansible_os_family == 'Debian'
sudo: yes
apt_repository:
repo: "deb https://deb.nodesource.com/iojs_1.x {{ansible_distribution_release}} main"
tags:
- deps
- web
- iojs

- name: Installing io.js
sudo: yes
apt:
name: "iojs={{iojs_version}}"
state: present
update_cache: yes
cache_valid_time: 3600
tags:
- deps
- web
- iojs

- name: Updating NPM
sudo: yes
npm:
name: "npm"
global: yes
state: present
tags:
- deps
- web
- iojs
- npm
6 changes: 6 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---

# Delegate further configuration to subtasks
# placed in this same directory.

- include: install.yml
24 changes: 24 additions & 0 deletions test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---

# Integration testing playbook
# ----------------------------

# A playbook for testing and integration.

# It will provision the `test` hosts in the inventory,
# which will, by default, specify the provided vagrant VM.

# This playbook should aim to test the most extensive
# or comprehensive configuration possible for your role.


- name: 'Role integration tests'

hosts: test

vars:
# custom_configuration: value

roles:
- '.' # The current directory itself is the role

0 comments on commit 3d4ab2f

Please sign in to comment.