├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── Vagrantfile ├── circle.yml ├── defaults └── main.yml ├── files └── nodesource.gpg.key ├── meta └── main.yml ├── tasks ├── main.yml ├── set-role-variables.yml ├── use-apt.yml └── use-yum.yml ├── test.yml └── test ├── Dockerfile-centos6 ├── Dockerfile-centos7 ├── Dockerfile-debian7 ├── Dockerfile-debian8 ├── Dockerfile-ubuntu12.04 └── Dockerfile-ubuntu14.04 /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: true 2 | services: 3 | - docker 4 | 5 | before_install: 6 | - docker info 7 | - docker version 8 | 9 | - docker build -f test/Dockerfile-ubuntu14.04 -t nodejs_trusty . 10 | - docker build -f test/Dockerfile-ubuntu12.04 -t nodejs_precise . 11 | - docker build -f test/Dockerfile-debian8 -t nodejs_jessie . 12 | - docker build -f test/Dockerfile-debian7 -t nodejs_wheezy . 13 | - docker build -f test/Dockerfile-centos7 -t nodejs_centos7 . 14 | - docker build -f test/Dockerfile-centos6 -t nodejs_centos6 . 15 | 16 | script: 17 | - docker run -i nodejs_trusty > result-ubuntu14.04 18 | - docker run -i nodejs_precise > result-ubuntu12.04 19 | - docker run -i nodejs_jessie > result-debian8 20 | - docker run -i nodejs_wheezy > result-debian7 21 | - docker run -i nodejs_centos7 > result-centos7 22 | - docker run -i nodejs_centos6 > result-centos6 23 | 24 | - echo "==> Validating the test results..." 25 | - sh -c "[ -s result-ubuntu14.04 ]" 26 | - sh -c "[ -s result-ubuntu12.04 ]" 27 | - sh -c "[ -s result-debian8 ]" 28 | - sh -c "[ -s result-debian7 ]" 29 | - sh -c "[ -s result-centos7 ]" 30 | - sh -c "[ -s result-centos6 ]" 31 | 32 | notifications: 33 | webhooks: https://galaxy.ansible.com/api/v1/notifications/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-2016 William Yeh 4 | 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | williamyeh.nodejs for Ansible Galaxy 3 | ============ 4 | 5 | [![Build Status](https://travis-ci.org/William-Yeh/ansible-nodejs.svg?branch=master)](https://travis-ci.org/William-Yeh/ansible-nodejs) [![Circle CI](https://circleci.com/gh/William-Yeh/ansible-nodejs.svg?style=shield)](https://circleci.com/gh/William-Yeh/ansible-nodejs) 6 | 7 | 8 | ## Summary 9 | 10 | Role name in Ansible Galaxy: **[williamyeh.nodejs](https://galaxy.ansible.com/williamyeh/nodejs/)** 11 | 12 | This Ansible role has the following features for [Node.js](http://nodejs.org/): 13 | 14 | - Install specific version of Node.js ([io.js](https://iojs.org/) is only supported under Debian/Ubuntu). 15 | 16 | 17 | 18 | 19 | ## Role Variables 20 | 21 | ### Mandatory variables 22 | 23 | None. 24 | 25 | 26 | 27 | ### Optional variables 28 | 29 | Pick one version to install: 30 | 31 | ```yaml 32 | # Node.js version; e.g., "5", "4.0", "0.12", "0.12.7" 33 | # Both numeric and string forms are ok. 34 | nodejs_version 35 | 36 | 37 | # io.js version; e.g., "3.3" 38 | # NOTE: only available under Debian/Ubuntu. 39 | iojs_version 40 | ``` 41 | 42 | If neither `nodejs_version` nor `iojs_version` is defined, `nodejs_version` is defined automatically by `tasks/set-role-variables.yml` according to `defaults/main.yml` settings: 43 | 44 | - `nodejs_default_in_apt` for Debian/Ubuntu. 45 | - `nodejs_default_in_yum` for CentOS. 46 | 47 | 48 | 49 | Other user-configurable defaults: 50 | 51 | ```yaml 52 | # install tools for compiling native addons from npm? 53 | nodejs_compile: True 54 | ``` 55 | 56 | 57 | ## Usage 58 | 59 | 60 | ### Step 1: add role 61 | 62 | Add role name `williamyeh.nodejs` to your playbook file. 63 | 64 | 65 | ### Step 2: add variables 66 | 67 | Set vars in your playbook file. 68 | 69 | Simple example: 70 | 71 | ```yaml 72 | --- 73 | # file: simple-playbook.yml 74 | 75 | - hosts: all 76 | become: True 77 | 78 | roles: 79 | - williamyeh.nodejs 80 | 81 | vars: 82 | nodejs_version: 4.0 83 | ``` 84 | 85 | 86 | ## Dependencies 87 | 88 | None. 89 | 90 | 91 | ## License 92 | 93 | Licensed under the MIT License. See the [LICENSE file](LICENSE) for details. 94 | 95 | 96 | ## History 97 | 98 | 99 | - 1.0 : Use Ansible 2.0 syntax; support up to Node.js 5.x. 100 | 101 | - Initial commit (2015-05-08): From now on, the role installs Node.js from [NodeSource](https://github.com/nodesource/distributions) binary distributions. 102 | 103 | 104 | 105 | Older versions are based on NVM: 106 | 107 | - Rewritten from my pre-Galaxy version [server-config-template](https://github.com/William-Yeh/server-config-template) and Galaxy version [ansible-nvm-nodejs](https://github.com/William-Yeh/ansible-nvm-nodejs). 108 | 109 | - During refactoring, some roles on Ansible Galaxy also inspired me: 110 | 111 | - [leonidas.nvm](https://galaxy.ansible.com/list#/roles/694) forks, especially [ahmednuaman.nvm-ahmed](https://galaxy.ansible.com/list#/roles/2298) and then [g-div/ansible-nvm](https://github.com/g-div/ansible-nvm) 112 | 113 | 114 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant.configure(2) do |config| 2 | 3 | # main & default: normal OS series... 4 | config.vm.define "main", primary: true do |node| 5 | node.vm.box = "ubuntu/trusty64" 6 | #node.vm.box = "ubuntu/precise64" 7 | #node.vm.box = "debian/jessie64" 8 | #node.vm.box = "debian/wheezy64" 9 | #node.vm.box = "bento/centos-7.2" 10 | #node.vm.box = "bento/centos-6.7" 11 | 12 | node.vm.provision "ansible" do |ansible| 13 | ansible.playbook = "test.yml" 14 | end 15 | end 16 | 17 | 18 | # docker: for auto build & testing (e.g., Travis CI) 19 | config.vm.define "docker" do |node| 20 | node.vm.box = "williamyeh/ubuntu-trusty64-docker" 21 | 22 | node.vm.provision "shell", inline: <<-SHELL 23 | cd /vagrant 24 | docker build -f test/Dockerfile-ubuntu14.04 -t nodejs_trusty . 25 | docker build -f test/Dockerfile-ubuntu12.04 -t nodejs_precise . 26 | docker build -f test/Dockerfile-debian8 -t nodejs_jessie . 27 | docker build -f test/Dockerfile-debian7 -t nodejs_wheezy . 28 | docker build -f test/Dockerfile-centos7 -t nodejs_centos7 . 29 | docker build -f test/Dockerfile-centos6 -t nodejs_centos6 . 30 | SHELL 31 | end 32 | 33 | end 34 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | machine: 2 | services: 3 | - docker 4 | 5 | dependencies: 6 | override: 7 | - docker info 8 | - docker version 9 | 10 | - docker build -f test/Dockerfile-ubuntu14.04 -t nodejs_trusty . 11 | - docker build -f test/Dockerfile-ubuntu12.04 -t nodejs_precise . 12 | - docker build -f test/Dockerfile-debian8 -t nodejs_jessie . 13 | - docker build -f test/Dockerfile-debian7 -t nodejs_wheezy . 14 | - docker build -f test/Dockerfile-centos7 -t nodejs_centos7 . 15 | - docker build -f test/Dockerfile-centos6 -t nodejs_centos6 . 16 | 17 | test: 18 | override: 19 | - docker run -i nodejs_trusty > result-ubuntu14.04 20 | - docker run -i nodejs_precise > result-ubuntu12.04 21 | - docker run -i nodejs_jessie > result-debian8 22 | - docker run -i nodejs_wheezy > result-debian7 23 | - docker run -i nodejs_centos7 > result-centos7 24 | - docker run -i nodejs_centos6 > result-centos6 25 | 26 | - echo "==> Validating the test results..." 27 | - sh -c "[ -s result-ubuntu14.04 ]" 28 | - sh -c "[ -s result-ubuntu12.04 ]" 29 | - sh -c "[ -s result-debian8 ]" 30 | - sh -c "[ -s result-debian7 ]" 31 | - sh -c "[ -s result-centos7 ]" 32 | - sh -c "[ -s result-centos6 ]" 33 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # 4 | # variables needed to be defined in user's playbook 5 | # 6 | 7 | 8 | 9 | # 10 | # user-configurable defaults 11 | # 12 | 13 | nodejs_compile: True # install tools for compiling native addons from npm 14 | 15 | 16 | nodejs_default_in_apt: "0.12" 17 | nodejs_default_in_yum: "0.10" 18 | -------------------------------------------------------------------------------- /files/nodesource.gpg.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | Version: GnuPG v1 3 | Comment: GPGTools - https://gpgtools.org 4 | 5 | mQINBFObJLYBEADkFW8HMjsoYRJQ4nCYC/6Eh0yLWHWfCh+/9ZSIj4w/pOe2V6V+ 6 | W6DHY3kK3a+2bxrax9EqKe7uxkSKf95gfns+I9+R+RJfRpb1qvljURr54y35IZgs 7 | fMG22Np+TmM2RLgdFCZa18h0+RbH9i0b+ZrB9XPZmLb/h9ou7SowGqQ3wwOtT3Vy 8 | qmif0A2GCcjFTqWW6TXaY8eZJ9BCEqW3k/0Cjw7K/mSy/utxYiUIvZNKgaG/P8U7 9 | 89QyvxeRxAf93YFAVzMXhoKxu12IuH4VnSwAfb8gQyxKRyiGOUwk0YoBPpqRnMmD 10 | Dl7SdmY3oQHEJzBelT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eZjnTGwhN1DnCDy1I66hUTgehONsfVanuP1 42 | PZKoL38EAxsMzdYgkYH6T9a4wJH/IPt+uuFTFFy3o8TKMvKaJk98+Jsp2X/QuNxh 43 | qpcIGaVbtQ1bn7m+k5Qe/fz+bFuUeXPivafLLlGc6KbdgMvSW9EVMO7yBy/2JE15 44 | ZJgl7lXKLQ31VQPAHT3an5IV2C/ie12eEqZWlnCiHV/wT+zhOkSpWdrheWfBT+ac 45 | hR4jDH80AS3F8jo3byQATJb3RoCYUCVc3u1ouhNZa5yLgYZ/iZkpk5gKjxHPudFb 46 | DdWjbGflN9k17VCf4Z9yAb9QMqHzHwIGXrb7ryFcuROMCLLVUp07PrTrRxnO9A/4 47 | xxECi0l/BzNxeU1gK88hEaNjIfviPR/h6Gq6KOcNKZ8rVFdwFpjbvwHMQBWhrqfu 48 | G3KaePvbnObKHXpfIKoAM7X2qfO+IFnLGTPyhFTcrl6vZBTMZTfZiC1XDQLuGUnd 49 | sckuXINIU3DFWzZGr0QrqkuE/jyr7FXeUJj9B7cLo+s/TXo+RaVfi3kOc9BoxIvy 50 | /qiNGs/TKy2/Ujqp/affmIMoMXSozKmga81JSwkADO1JMgUy6dApXz9kP4EE3g== 51 | =CLGF 52 | -----END PGP PUBLIC KEY BLOCK----- 53 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # nodejs/meta/main.yml 3 | 4 | galaxy_info: 5 | author: williamyeh 6 | description: Install and configure Node.js 7 | license: MIT 8 | min_ansible_version: 2.0 9 | 10 | platforms: 11 | - name: Ubuntu 12 | versions: 13 | - precise 14 | - trusty 15 | - name: Debian 16 | versions: 17 | - wheezy 18 | - jessie 19 | - name: EL 20 | versions: 21 | - 6 22 | - 7 23 | 24 | galaxy_tags: 25 | - development 26 | - nodejs 27 | - node 28 | - javascript 29 | 30 | dependencies: [] 31 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # file: tasks/main.yml 3 | # Top-level installer for Node.js. 4 | # 5 | # @see https://github.com/nodesource/distributions 6 | # 7 | 8 | 9 | - name: set role variables, if necessary 10 | include: set-role-variables.yml 11 | 12 | 13 | - name: delegate to APT system for installation 14 | include: use-apt.yml 15 | when: ansible_pkg_mgr == "apt" 16 | 17 | - name: delegate to YUM system for installation 18 | include: use-yum.yml 19 | when: ansible_pkg_mgr == "yum" 20 | -------------------------------------------------------------------------------- /tasks/set-role-variables.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # file: tasks/set-role-variables.yml 3 | # set necessary role variables. 4 | # 5 | 6 | - name: set nodejs_version, if neither version variables are defined 7 | set_fact: 8 | nodejs_version: "{{ nodejs_default_in_apt }}" 9 | when: nodejs_version is not defined and iojs_version is not defined and ansible_pkg_mgr == "apt" 10 | 11 | 12 | - name: set nodejs_version, if neither version variables are defined 13 | set_fact: 14 | nodejs_version: "{{ nodejs_default_in_yum }}" 15 | when: nodejs_version is not defined and iojs_version is not defined and ansible_pkg_mgr == "yum" -------------------------------------------------------------------------------- /tasks/use-apt.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # file: tasks/use-apt.yml 3 | # 4 | # Configure Node.js from APT repository. 5 | # 6 | # @see https://github.com/nodesource/distributions 7 | # 8 | 9 | - name: install add-apt-repository and https binaries for Ansible to work 10 | apt: name={{ item }} state=present update_cache=yes 11 | with_items: 12 | - python-software-properties 13 | - apt-transport-https 14 | 15 | - name: install tools for compiling native addons from npm 16 | apt: name={{ item }} state=present 17 | with_items: 18 | - build-essential 19 | when: nodejs_compile 20 | 21 | 22 | 23 | - name: add NodeSource key 24 | apt_key: data="{{ lookup('file', 'nodesource.gpg.key') }}" state=present 25 | 26 | 27 | - block: 28 | 29 | - name: add NodeSource repository for Node.js 6.0 30 | apt_repository: repo='{{ item }} https://deb.nodesource.com/node_6.x {{ ansible_distribution_release|lower }} main' state=present 31 | with_items: 32 | - deb 33 | - deb-src 34 | when: (nodejs_version|string) | match('^6.*$') 35 | 36 | - name: add NodeSource repository for Node.js 5.0 37 | apt_repository: repo='{{ item }} https://deb.nodesource.com/node_5.x {{ ansible_distribution_release|lower }} main' state=present 38 | with_items: 39 | - deb 40 | - deb-src 41 | when: (nodejs_version|string) | match('^5.*$') 42 | #when: nodejs_version|version_compare('5.0', '>=') 43 | 44 | 45 | - name: add NodeSource repository for Node.js 4.0 46 | apt_repository: repo='{{ item }} https://deb.nodesource.com/node_4.x {{ ansible_distribution_release|lower }} main' state=present 47 | with_items: 48 | - deb 49 | - deb-src 50 | when: (nodejs_version|string) | match('^4.*$') 51 | #when: nodejs_version|version_compare('4.0', '>=') 52 | 53 | 54 | - name: add NodeSource repository for Node.js 0.12 55 | apt_repository: repo='{{ item }} https://deb.nodesource.com/node_0.12 {{ ansible_distribution_release|lower }} main' state=present 56 | with_items: 57 | - deb 58 | - deb-src 59 | when: (nodejs_version|string) | match('^0.12.*$') 60 | 61 | 62 | - name: add NodeSource repository for Node.js 0.10 63 | apt_repository: repo='{{ item }} https://deb.nodesource.com/node_0.10 {{ ansible_distribution_release|lower }} main' state=present 64 | with_items: 65 | - deb 66 | - deb-src 67 | when: (nodejs_version|string) | match('^0.10.*$') 68 | 69 | 70 | - name: install Node.js with specific version 71 | apt: name="nodejs={{ nodejs_version }}*" update_cache=yes state=present force=yes 72 | 73 | when: nodejs_version is defined 74 | 75 | 76 | 77 | - block: 78 | 79 | - name: add NodeSource repository for io.js 3.x 80 | apt_repository: repo='{{ item }} https://deb.nodesource.com/iojs_3.x {{ ansible_distribution_release|lower }} main' state=present 81 | with_items: 82 | - deb 83 | - deb-src 84 | 85 | - name: add NodeSource repository for io.js 2.x (deb) 86 | apt_repository: repo='{{ item }} https://deb.nodesource.com/iojs_2.x {{ ansible_distribution_release|lower }} main' state=present 87 | with_items: 88 | - deb 89 | - deb-src 90 | 91 | - name: add NodeSource repository for io.js 1.x 92 | apt_repository: repo='{{ item }} https://deb.nodesource.com/iojs_1.x {{ ansible_distribution_release|lower }} main' state=present 93 | with_items: 94 | - deb 95 | - deb-src 96 | 97 | - name: install io.js with specific version 98 | apt: name="iojs={{ iojs_version }}*" update_cache=yes state=present force=yes 99 | 100 | when: iojs_version is defined 101 | -------------------------------------------------------------------------------- /tasks/use-yum.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # file: tasks/use-yum.yml 3 | # 4 | # Configure Node.js from YUM repository. 5 | # 6 | # @see https://github.com/nodesource/distributions 7 | # 8 | 9 | - name: install libselinux-python binary for Ansible to work 10 | yum: name=libselinux-python state=present 11 | 12 | - name: install tools for compiling native addons from npm 13 | yum: name={{ item }} state=present 14 | with_items: 15 | - gcc-c++ 16 | - make 17 | when: nodejs_compile 18 | 19 | 20 | 21 | - block: 22 | 23 | - name: add NodeSource repository for Node.js 6.0 24 | yum: name=https://rpm.nodesource.com/pub_6.x/el/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/nodesource-release-el{{ ansible_distribution_major_version }}-1.noarch.rpm state=present 25 | when: (nodejs_version|string) | match('^6.*$') 26 | 27 | - name: add NodeSource repository for Node.js 5.0 28 | yum: name=https://rpm.nodesource.com/pub_5.x/el/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/nodesource-release-el{{ ansible_distribution_major_version }}-1.noarch.rpm state=present 29 | when: (nodejs_version|string) | match('^5.*$') 30 | 31 | - name: add NodeSource repository for Node.js 4.0 32 | yum: name=https://rpm.nodesource.com/pub_4.x/el/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/nodesource-release-el{{ ansible_distribution_major_version }}-1.noarch.rpm state=present 33 | when: (nodejs_version|string) | match('^4.*$') 34 | 35 | - name: add NodeSource repository for Node.js 0.xx 36 | yum: name=https://rpm.nodesource.com/pub/el/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/nodesource-release-el{{ ansible_distribution_major_version }}-1.noarch.rpm state=present 37 | when: (nodejs_version|string) | match('^0.*$') 38 | 39 | - name: install Node.js with specific version 40 | yum: name="nodejs-{{ nodejs_version }}*" update_cache=yes state=present 41 | 42 | when: nodejs_version is defined 43 | 44 | 45 | - fail: msg="io.js not supported for CentOS/RHEL." 46 | when: iojs_version is defined 47 | -------------------------------------------------------------------------------- /test.yml: -------------------------------------------------------------------------------- 1 | - hosts: all 2 | become: True 3 | tasks: 4 | - include: 'tasks/main.yml' 5 | vars_files: 6 | - 'defaults/main.yml' 7 | 8 | vars: 9 | nodejs_version: "6.0.0" 10 | #nodejs_version: "5" 11 | #nodejs_version: "5.7.0" 12 | #nodejs_version: 5.7.0 13 | #nodejs_version: "4" 14 | #nodejs_version: "4.3" 15 | #nodejs_version: "4.3.1" 16 | #nodejs_version: "4.0.0" 17 | #nodejs_version: "0.10" 18 | #nodejs_version: 0.12 19 | #iojs_version: "3.3" 20 | -------------------------------------------------------------------------------- /test/Dockerfile-centos6: -------------------------------------------------------------------------------- 1 | # Dockerfile for building image that contains software stack provisioned by Ansible. 2 | # 3 | # USAGE: 4 | # $ docker build . 5 | # 6 | # Version 1.0 7 | # 8 | 9 | 10 | # pull base image 11 | FROM williamyeh/ansible:centos6-onbuild 12 | 13 | MAINTAINER William Yeh 14 | 15 | 16 | # 17 | # build phase 18 | # 19 | 20 | ENV PLAYBOOK test.yml 21 | RUN ansible-playbook-wrapper -vvv 22 | 23 | 24 | 25 | # 26 | # test phase 27 | # 28 | 29 | CMD ["node", "--version"] 30 | -------------------------------------------------------------------------------- /test/Dockerfile-centos7: -------------------------------------------------------------------------------- 1 | # Dockerfile for building image that contains software stack provisioned by Ansible. 2 | # 3 | # USAGE: 4 | # $ docker build . 5 | # 6 | # Version 1.0 7 | # 8 | 9 | 10 | # pull base image 11 | FROM williamyeh/ansible:centos7-onbuild 12 | 13 | MAINTAINER William Yeh 14 | 15 | 16 | # 17 | # build phase 18 | # 19 | 20 | ENV PLAYBOOK test.yml 21 | RUN ansible-playbook-wrapper -vvv 22 | 23 | 24 | 25 | # 26 | # test phase 27 | # 28 | 29 | CMD ["node", "--version"] 30 | -------------------------------------------------------------------------------- /test/Dockerfile-debian7: -------------------------------------------------------------------------------- 1 | # Dockerfile for building image that contains software stack provisioned by Ansible. 2 | # 3 | # USAGE: 4 | # $ docker build . 5 | # 6 | # Version 1.0 7 | # 8 | 9 | 10 | # pull base image 11 | FROM williamyeh/ansible:debian7-onbuild 12 | 13 | MAINTAINER William Yeh 14 | 15 | 16 | # 17 | # build phase 18 | # 19 | 20 | ENV PLAYBOOK test.yml 21 | RUN ansible-playbook-wrapper 22 | 23 | 24 | 25 | # 26 | # test phase 27 | # 28 | 29 | CMD ["node", "--version"] 30 | -------------------------------------------------------------------------------- /test/Dockerfile-debian8: -------------------------------------------------------------------------------- 1 | # Dockerfile for building image that contains software stack provisioned by Ansible. 2 | # 3 | # USAGE: 4 | # $ docker build . 5 | # 6 | # Version 1.0 7 | # 8 | 9 | 10 | # pull base image 11 | FROM williamyeh/ansible:debian8-onbuild 12 | 13 | MAINTAINER William Yeh 14 | 15 | 16 | # 17 | # build phase 18 | # 19 | 20 | ENV PLAYBOOK test.yml 21 | RUN ansible-playbook-wrapper 22 | 23 | 24 | 25 | # 26 | # test phase 27 | # 28 | 29 | CMD ["node", "--version"] 30 | -------------------------------------------------------------------------------- /test/Dockerfile-ubuntu12.04: -------------------------------------------------------------------------------- 1 | # Dockerfile for building image that contains software stack provisioned by Ansible. 2 | # 3 | # USAGE: 4 | # $ docker build . 5 | # 6 | # Version 1.0 7 | # 8 | 9 | 10 | # pull base image 11 | FROM williamyeh/ansible:ubuntu12.04-onbuild 12 | 13 | MAINTAINER William Yeh 14 | 15 | 16 | # 17 | # build phase 18 | # 19 | 20 | ENV PLAYBOOK test.yml 21 | RUN ansible-playbook-wrapper 22 | 23 | 24 | 25 | # 26 | # test phase 27 | # 28 | 29 | CMD ["node", "--version"] 30 | -------------------------------------------------------------------------------- /test/Dockerfile-ubuntu14.04: -------------------------------------------------------------------------------- 1 | # Dockerfile for building image that contains software stack provisioned by Ansible. 2 | # 3 | # USAGE: 4 | # $ docker build . 5 | # 6 | # Version 1.0 7 | # 8 | 9 | 10 | # pull base image 11 | FROM williamyeh/ansible:ubuntu14.04-onbuild 12 | 13 | MAINTAINER William Yeh 14 | 15 | 16 | # 17 | # build phase 18 | # 19 | 20 | ENV PLAYBOOK test.yml 21 | RUN ansible-playbook-wrapper 22 | 23 | 24 | 25 | # 26 | # test phase 27 | # 28 | 29 | CMD ["node", "--version"] 30 | --------------------------------------------------------------------------------