From dd5fcbbfbd4d116752a873860983b7e9c436e23b Mon Sep 17 00:00:00 2001 From: Luke Sneeringer Date: Thu, 12 Jun 2014 16:51:48 -0500 Subject: [PATCH] Vagrant Local Development This commit adds playbooks and files necessary to do local development from within Vagrant. These playbooks start with a fresh Ubuntu 12.04 machine and: - Install Ansible - Install the Tower nightly - Install all components to exactly mirror production, except Apache - Install uwsgi and nginx for local development (since Apache lacks a working auto-reload) This isn't entirely perfect -- in particular, developing on task code is probably challenging until I figure out how to get celery not to read from the install, but it is a very easy way to get 90% of the way there very, very quickly. --- .gitignore | 3 +-- Vagrantfile | 41 +++++++++++++++++++++++++++++++++++++ ansible.cfg | 15 ++++++++++++++ awx/settings/development.py | 3 +++ 4 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 Vagrantfile create mode 100644 ansible.cfg diff --git a/.gitignore b/.gitignore index bc8c451f61..d6fbb456b7 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,5 @@ pep8.txt nohup.out reports package.json -Vagrantfile -ansible.cfg +tools/vagrant/local.yml *~ diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000000..bc42d085c4 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,41 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.require_version '>= 1.5.1' + +Vagrant.configure('2') do |config| + config.vm.define 'tower-precise', primary: true do |precise| + precise.vm.box = "precise-server-cloudimg-amd64" + precise.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box" + + precise.vm.hostname = 'tower-precise' + + precise.vm.network :private_network, ip: '33.33.33.13' + precise.vm.network :forwarded_port, guest: 80, host: 8013 + precise.vm.network :forwarded_port, guest: 8080, host: 8080 + precise.vm.network :forwarded_port, guest: 15672, host: 15013 + precise.vm.network :forwarded_port, guest: 24013, host: 24013 + + precise.vm.synced_folder '.', '/var/ansible/tower/', + :mount_options => [ 'gid=5853', 'dmode=2775' ] + + precise.vm.provider :virtualbox do |vb| + vb.customize ["modifyvm", :id, "--memory", "512"] + end + end + + config.ssh.forward_agent = true + + config.vm.provision 'ansible' do |ansible| + ansible.extra_vars = { + 'development' => true, + 'target_hosts' => 'vagrant', + 'target_user' => 'vagrant', + 'vagrant' => true, + 'vagrant_host_user' => ENV['USER'], + } + ansible.inventory_path = 'tools/vagrant/inventory' + ansible.playbook = 'tools/vagrant/playbook.yml' + ansible.verbose = 'v' + end +end diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000000..32ffcc5216 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,15 @@ +[defaults] + +# Connections +host_key_checking = False +record_host_keys = False +pipelining = True + + +# Command-line specific +module_name = shell + + +# Paths +roles_path = setup/roles:tools/vagrant/roles + diff --git a/awx/settings/development.py b/awx/settings/development.py index 43fe6c1d74..ba6cb1362f 100644 --- a/awx/settings/development.py +++ b/awx/settings/development.py @@ -47,6 +47,9 @@ if 'django_jenkins' in INSTALLED_APPS: JSHINT_CHECKED_FILES = [os.path.join(BASE_DIR, 'ui/static/js'), os.path.join(BASE_DIR, 'ui/static/lib/ansible'),] +# If there is an `/etc/awx/settings.py`, include it. +include(optional('/etc/awx/settings.py'), scope=locals()) + # If any local_*.py files are present in awx/settings/, use them to override # default settings for development. If not present, we can still run using # only the defaults.