Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vagrant Support #1

Merged
merged 1 commit into from
Jul 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
./dist
/dist

# Created by https://www.gitignore.io/api/node

Expand Down Expand Up @@ -64,3 +64,7 @@ typings/


# End of https://www.gitignore.io/api/node

# Vagrant
/.vagrant
/.ansible-roles
34 changes: 34 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# vi: set ft=ruby :

require 'shellwords'

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "bento/centos-7.3"
config.vm.hostname = "devel"

# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", type: "dhcp"

# Tweak the VMs configuration.
config.vm.provider "virtualbox" do |vb|
vb.memory = 1024
vb.linked_clone = true
end

# Configure the VM using Ansible
config.vm.provision "ansible_local" do |ansible|
ansible.galaxy_role_file = "requirements.yml"
ansible.galaxy_roles_path = ".ansible-roles"
ansible.provisioning_path = "/vagrant"
ansible.playbook = "vagrant.yml"
# allow passing ansible args from environment variable
ansible.raw_arguments = Shellwords::shellwords(ENV.fetch("ANSIBLE_ARGS", ""))
end
end
2 changes: 2 additions & 0 deletions ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[defaults]
retry_files_enabled = false
3 changes: 3 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- name: vagrant-base
src: naftulikay.vagrant-base
69 changes: 69 additions & 0 deletions vagrant.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
- hosts: all
become: true
vars:
node_version: "6.11.0"
roles: [vagrant-base]
tasks:
- name: check if node is installed
command: ls /usr/local/node-{{ node_version }}/bin
register: node_result
failed_when: false
changed_when: false

- name: set node facts
set_fact:
node_installed: "{{ node_result.rc == 0 | bool }}"
node_shared_dir: /usr/local/node
node_install_dir: "/usr/local/node-{{ node_version }}"

- name: create node installation directory
file: path={{ node_install_dir }} state=directory mode=0755 owner=root group=root

- name: download node
unarchive:
src: https://nodejs.org/dist/v{{ node_version }}/node-v{{ node_version }}-linux-x64.tar.xz
remote_src: true
dest: "{{ node_install_dir}}"
extra_opts: ["--strip-components", "1"]
when: not node_installed

- name: create node installation symlink
file:
src: "{{ node_install_dir }}"
dest: "{{ node_shared_dir }}"
owner: root
group: root
state: link

- name: create node executable symlinks
file:
src: "{{ node_install_dir }}/bin/{{ item }}"
dest: "/usr/local/bin/{{ item }}"
owner: root
group: root
state: link
with_items:
- node
- npm

- name: create environment profile for node
copy:
content: |
#!/usr/bin/env bash
export PATH="$PATH:{{ node_shared_dir }}/bin"
dest: /etc/profile.d/99-node.sh
owner: root
group: root
mode: 0755

- name: install ruby
package: name={{ item }} state=present
with_items:
- ruby
- ruby-devel
- make
- gcc

- name: install fpm
gem: name=fpm state=present user_install=no