Last active
April 26, 2016 12:25
-
-
Save karantir/1d75d2bf65931e74a61052a92996d765 to your computer and use it in GitHub Desktop.
Vagrant environment for bower based frontend
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[all] | |
127.0.0.1 | |
[all:vars] | |
project_root = /vagrant | |
upstart_criteria = vagrant-mounted | |
project_url = localhost | |
ansible_sudo = true | |
ansible_ssh_user = vagrant | |
ansible_ssh_port = 2222 | |
ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name localhost; | |
location / { | |
root /vagrant/src; | |
sendfile off; | |
} | |
# Sample config for WebSocket connections | |
# | |
# location /api { | |
# proxy_pass http://localhost:8080/; | |
# proxy_http_version 1.1; | |
# proxy_set_header Upgrade $http_upgrade; | |
# proxy_set_header Connection $http_connection; | |
# proxy_set_header Host $host; | |
# proxy_cache_bypass $http_upgrade; | |
# } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# A playbook to provision hosts. | |
# | |
# Run manually: | |
# ansible-playbook -i vagrant provision.yml | |
- hosts: all | |
sudo: true | |
tasks: | |
- name: install system packages | |
apt: name={{ item }} update_cache=yes | |
with_items: | |
- curl | |
- git | |
- nginx | |
tags: [apt] | |
- name: install nginx config | |
template: src=.vagrant.nginx.conf dest=/etc/nginx/sites-enabled/default | |
tags: [nginx] | |
notify: | |
- restart nginx | |
- name: check nodejs is installed | |
shell: dpkg -s nodejs | |
register: result | |
ignore_errors: True | |
tags: [node, npm] | |
- name: setup nodejs repository | |
shell: curl -sL https://deb.nodesource.com/setup | bash - | |
when: result.rc == 1 | |
tags: [node, npm] | |
- name: install nodejs | |
apt: name=nodejs update_cache=yes | |
when: result.rc == 1 | |
tags: [node, npm] | |
- name: install npm global packages | |
npm: name={{ item }} global=yes | |
tags: [node, npm] | |
with_items: | |
- bower | |
- name: install bower packages | |
shell: "cd {{ project_root }} && bower install --no-interactive --allow-root" | |
tags: [bower] | |
handlers: | |
- name: restart nginx | |
service: name=nginx state=restarted |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure("2") do |config| | |
config.vm.box = "ubuntu/trusty64" | |
config.vm.box_check_update = false | |
config.vm.network :forwarded_port, guest: 80, host: 8000 | |
config.vm.network :forwarded_port, guest: 22, host: 2222, id: "ssh" | |
config.vm.hostname = "box01" | |
config.vm.provider "virtualbox" do |v| | |
v.memory = 512 | |
end | |
config.ssh.private_key_path = "~/.vagrant.d/insecure_private_key" | |
config.ssh.insert_key = false | |
config.vm.provision "ansible" do |ansible| | |
ansible.playbook = ".vagrant.provision.yml" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment