-
-
Save brennv/281e2923dc09c25ed56a to your computer and use it in GitHub Desktop.
Hello World with Ansible and Vagrant
This file contains 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
from flask import Flask | |
app = Flask(__name__) | |
@app.route('/') | |
def index(): | |
return '<h1>Hello From Vagrant</h1>' | |
if __name__ == '__main_': | |
app.run() |
This file contains 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
--- | |
- 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=~/ |
This file contains 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
$ vagrant up --provision |
This file contains 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
# 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