Skip to content

Instantly share code, notes, and snippets.

@brennv
Forked from drgarcia1986/Vagrantfile
Created January 27, 2016 04:34
Show Gist options
  • Save brennv/281e2923dc09c25ed56a to your computer and use it in GitHub Desktop.
Save brennv/281e2923dc09c25ed56a to your computer and use it in GitHub Desktop.
Hello World with Ansible and Vagrant
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return '<h1>Hello From Vagrant</h1>'
if __name__ == '__main_':
app.run()
---
- hosts: all
sudo: true
tasks:
- name: download get-pip.py
get_url: url=https://bootstrap.pypa.io/get-pip.py dest=/tmp/get-pip.py
- name: install pip
command: python /tmp/get-pip.py
- name: install gunicorn and flask
pip: name={{ item }}
with_items:
- gunicorn
- flask
- name: copy app file to host
copy: src=app.py dest=~/app.py
- name: run server
command: gunicorn app:app -D -b 0.0.0.0:8000 chdir=~/
$ vagrant up --provision
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "forwarded_port", guest: 8000, host: 8000
config.vm.provision :ansible do |ansible|
ansible.playbook = "playbook.yml"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment