Skip to content

Commit

Permalink
Initial Vagrant and Ansible provision
Browse files Browse the repository at this point in the history
  • Loading branch information
ad-m committed Mar 21, 2017
1 parent 3f84f66 commit 57e64c9
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Vagrantfile
@@ -0,0 +1,31 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.

#!/usr/bin/env bash

Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.

# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "bento/ubuntu-16.04"

config.vm.define "mgmt" do |web|
web.vm.network "private_network", ip: "192.168.33.10"
web.vm.network :forwarded_port, guest: 22, host: 2210
web.vm.provider "virxtualbox" do |vb|
vb.memory = 1024
end
web.vm.provision :ansible do |ansible|
ansible.playbook = "vagrant_provision_ansible.yaml"
end
end

end
67 changes: 67 additions & 0 deletions vagrant_provision_ansible.yaml
@@ -0,0 +1,67 @@
---
- hosts: all
become: yes
become_user: root
vars:
db_name: feder
db_user: feder
db_pass: feder
settings: {
DJANGO_SETTINGS_MODULE: "config.local",
DATABASE_URL: "mysql://{{db_user}}:{{db_pass}}@localhost/{{db_name}}"
}
tasks:
- name: Install OS-level libraries and application
apt:
name: "{{item}}"
state: latest
with_items:
- python2.7
- mariadb-server
- git
- libmariadb-client-lgpl-dev
- virtualenv
- python-dev
- libffi-dev
- libssl-dev
- libjpeg-dev
- libpng12-dev
- libxml2-dev
- libxslt1-dev
- build-essential
- libjpeg62
- name: Install OS-level Python dependencies
pip: name={{item}} state=present
with_items:
- pip
- wheel

- name: Create a new MariaDB database
mysql_db:
name: "{{ db_name }}"
state: "present"

- name: Create a new MariaDB user
mysql_user:
name: "{{ db_user }}"
password: "{{ db_pass }}"
host: "%"
priv: '{{ db_name }}.*:ALL'
state: present

- name: Create virtualenv
pip:
requirements: "/vagrant/requirements/local.txt"
virtualenv: "env"

- name: execute database migrations
django_manage: command=migrate
app_path=/vagrant
virtualenv=env
environment: "{{ settings }}"

- name: execute collectstatic
django_manage: command=collectstatic
app_path=/vagrant
virtualenv=env
environment: "{{ settings }}"

0 comments on commit 57e64c9

Please sign in to comment.