From 3d4ab2f074252d6f1382ff36b55d80c0892608ac Mon Sep 17 00:00:00 2001 From: zenoamaro Date: Sat, 14 Mar 2015 23:48:04 +0100 Subject: [PATCH] Initial commit. --- .gitignore | 11 ++++++ .travis.yml | 23 ++++++++++++ LICENSE.md | 21 +++++++++++ README.md | 90 +++++++++++++++++++++++++++++++++++++++++++++++ Vagrantfile | 49 ++++++++++++++++++++++++++ boxed.yml | 11 ++++++ defaults/main.yml | 3 ++ inventory | 15 ++++++++ main.yml | 19 ++++++++++ meta/main.yml | 25 +++++++++++++ tasks/install.yml | 58 ++++++++++++++++++++++++++++++ tasks/main.yml | 6 ++++ test.yml | 24 +++++++++++++ 13 files changed, 355 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 Vagrantfile create mode 100644 boxed.yml create mode 100644 defaults/main.yml create mode 100644 inventory create mode 100644 main.yml create mode 100644 meta/main.yml create mode 100644 tasks/install.yml create mode 100644 tasks/main.yml create mode 100644 test.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3da3df0 --- /dev/null +++ b/.gitignore @@ -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 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..cba3066 --- /dev/null +++ b/.travis.yml @@ -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 diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..5ca1126 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015, zenoamaro + +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. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..dc7fbe7 --- /dev/null +++ b/README.md @@ -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 + +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. \ No newline at end of file diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..c263a4d --- /dev/null +++ b/Vagrantfile @@ -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 diff --git a/boxed.yml b/boxed.yml new file mode 100644 index 0000000..407fd83 --- /dev/null +++ b/boxed.yml @@ -0,0 +1,11 @@ +--- + +# Simple, straight playbook for boxed io.js installs + +- name: 'io.js boxed installation' + + hosts: boxed + + roles: + - '.' # This role itself + diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..984f4aa --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,3 @@ +# Pin iojs on this version. +# You can use wildcards here. +iojs_version: '1.5.*' diff --git a/inventory b/inventory new file mode 100644 index 0000000..83cb6e2 --- /dev/null +++ b/inventory @@ -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 \ No newline at end of file diff --git a/main.yml b/main.yml new file mode 100644 index 0000000..168027e --- /dev/null +++ b/main.yml @@ -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 + diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..aefc96d --- /dev/null +++ b/meta/main.yml @@ -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: [] diff --git a/tasks/install.yml b/tasks/install.yml new file mode 100644 index 0000000..db80cbc --- /dev/null +++ b/tasks/install.yml @@ -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 diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..f3cdd8f --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,6 @@ +--- + +# Delegate further configuration to subtasks +# placed in this same directory. + +- include: install.yml diff --git a/test.yml b/test.yml new file mode 100644 index 0000000..bafe03e --- /dev/null +++ b/test.yml @@ -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 +