first pass at getting vagrant/ansible working for prod

pull/1/head
Raymond Yee 2016-05-09 14:11:49 -07:00
parent 1222d677dc
commit 8211e5d3af
8 changed files with 82 additions and 1 deletions

3
deploy/setup-just.sh Normal file
View File

@ -0,0 +1,3 @@
cd /opt/regluit
source ENV/bin/activate
export DJANGO_SETTINGS_MODULE=regluit.settings.just

3
deploy/setup-please.sh Normal file
View File

@ -0,0 +1,3 @@
cd /opt/regluit
source ENV/bin/activate
export DJANGO_SETTINGS_MODULE=regluit.settings.please

3
deploy/setup-prod.sh Normal file
View File

@ -0,0 +1,3 @@
cd /opt/regluit
source ENV/bin/activate
export DJANGO_SETTINGS_MODULE=regluit.settings.prod

View File

@ -13,6 +13,7 @@ WebOb==1.2.3
WebTest==1.4.0
amqplib==1.0.2
anyjson==0.3.3
awscli==1.10.26
billiard==2.7.3.12
boto==2.8.0
#git+ssh://git@github.com/Gluejar/boto.git@2.3.0

56
vagrant/Vagrantfile vendored
View File

@ -188,7 +188,63 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
end
config.vm.define "prod" do |node|
node.vm.box = "ubuntu/trusty64"
node.vm.network "private_network", type: "dhcp"
#node.vm.network "private_network", ip: "192.168.33.10"
node.ssh.forward_agent = true
node.vm.provision 'ansible' do |ansible|
ansible.playbook = 'dev.yml'
ansible.verbose = "vv"
# ansible.inventory_path = '.vagrant/provisioners/ansible/inventory/'
ansible.raw_arguments = [
"--inventory-file=.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory",
"--limit=prod,127.0.0.1",
"-e vname=prod",
"-e class=prod",
"-e hostname=unglue.it",
"-e setdns=false",
"-e do_migrate=true",
"-e branch=sysadmin"
]
end
node.vm.provider "virtualbox" do |v|
v.memory = 1024
v.cpus = 2
end
node.vm.provider :aws do |aws, override|
aws.access_key_id = ENV['AWS_ACCESS_KEY_ID']
aws.secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
aws.keypair_name = "ry-laptop"
# Ubuntu 12.04 LTS Precise / PV EBS-SSD boot
# alestic 2015.05.05
aws.instance_type="c1.medium"
aws.region = "us-east-1"
aws.availability_zone = "us-east-1c"
aws.ami = "ami-d8132bb0"
aws.security_groups = ["web-production"]
aws.tags = {
'Name' => 'prod_vagrant'
}
override.vm.box = "dummy"
override.ssh.username = "ubuntu"
override.ssh.private_key_path = "/Users/raymondyee/.ssh/id_rsa"
end
end
config.vm.define "localvm" do |node|

View File

@ -5,6 +5,7 @@
aws_secret_key: "{{ lookup('env','AWS_SECRET_ACCESS_KEY') }}"
target: '{{vname}}'
dev_ssh_host: "{{ hostvars[target]['ansible_ssh_host'] }}"
migrate: "{{do_migrate | default('true')}}"
tasks:
@ -119,7 +120,7 @@
args:
github_auth_key: "{{github_auth_key}}"
repo_name: Gluejar/regluit
key_name: "{{hostname}} {{ ansible_date_time.date }}"
key_name: "{{hostname}} {{ ansible_date_time.iso8601 }}"
key_path: /home/{{user}}/.ssh/id_rsa.pub
- name: postfix install
@ -218,6 +219,8 @@
#run('django-admin.py syncdb --migrate --noinput --settings regluit.settings.please')
#Run syncdb on the application
# TO DO: syncdb might be deprecated
# http://stackoverflow.com/a/29683785
- name: django syncdb
django_manage: >
@ -225,6 +228,7 @@
app_path=/opt/regluit/
settings="regluit.settings.{{class}}"
virtualenv=/opt/regluit/ENV
when: migrate
notify:
- restart apache2
@ -234,6 +238,7 @@
app_path=/opt/regluit/
settings="regluit.settings.{{class}}"
virtualenv=/opt/regluit/ENV
when: migrate
notify:
- restart apache2
@ -423,6 +428,16 @@
state=present
when: class in ['just']
- name: set up script file to load environment for interactive use
command: cp "/opt/regluit/deploy/setup-{{class}}.sh" /home/{{user}}/setup.sh
- name: set up script to dump database
command: cp "/opt/regluit/deploy/dump_db_{{class}}.sh" /home/{{user}}/dump.sh
when: class in ['prod']
- name: put an empty file in main dir to help identify this instance
command: touch "/home/{{user}}/{{class}}_{{ ansible_date_time.iso8601 }}"
handlers:
- name: restart apache2