diff options
-rw-r--r-- | Vagrantfile | 27 | ||||
-rwxr-xr-x | vagrant_support/bmo-checksetup.j2 | 12 | ||||
-rwxr-xr-x | vagrant_support/bmo-configured | 39 | ||||
-rw-r--r-- | vagrant_support/bmo-generate-data.j2 | 4 | ||||
-rwxr-xr-x | vagrant_support/bmo-reconfigure.j2 | 7 | ||||
-rw-r--r-- | vagrant_support/checksetup.yml | 33 | ||||
-rw-r--r-- | vagrant_support/playbook.yml | 2 |
7 files changed, 46 insertions, 78 deletions
diff --git a/Vagrantfile b/Vagrantfile index 88c68d052..642fe2f92 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -14,6 +14,19 @@ WEB_CPU = ENV.fetch "BMO_WEB_CPU", 2 VENDOR_BUNDLE_URL = ENV.fetch "BMO_BUNDLE_URL", 'https://moz-devservices-bmocartons.s3.amazonaws.com/bmo/vendor.tar.gz' +RSYNC_ARGS = [ + '--verbose', + '--archive', + '--delete', + '-z', + '--copy-links', + '--exclude=local/', + '--exclude=data/', + '--exclude=template_cache/', + '--exclude=localconfig', + '--include=.git/' +] + # 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 @@ -45,12 +58,7 @@ Vagrant.configure('2') do |config| guest: 22, auto_correct: true - db.vm.synced_folder '.', '/vagrant', type: 'rsync', - rsync__args: ['--verbose', '--archive', '--delete', '-z', '--copy-links', - '--exclude=local/', - '--exclude=data/', - '--exclude=template_cache/', - '--exclude=localconfig'] + db.vm.synced_folder '.', '/vagrant', type: 'rsync', rsync__args: RSYNC_ARGS db.vm.provider 'parallels' do |prl, override| override.vm.box = 'parallels/centos-6.8' end @@ -72,12 +80,7 @@ Vagrant.configure('2') do |config| auto_correct: true - web.vm.synced_folder '.', '/vagrant', type: 'rsync', - rsync__args: ['--verbose', '--archive', '--delete', '-z', '--copy-links', - '--exclude=local/', - '--exclude=data/', - '--exclude=template_cache/', - '--exclude=localconfig'] + web.vm.synced_folder '.', '/vagrant', type: 'rsync', rsync__args: RSYNC_ARGS web.vm.provider 'virtualbox' do |v| v.memory = WEB_MEM diff --git a/vagrant_support/bmo-checksetup.j2 b/vagrant_support/bmo-checksetup.j2 new file mode 100755 index 000000000..c35a323c3 --- /dev/null +++ b/vagrant_support/bmo-checksetup.j2 @@ -0,0 +1,12 @@ +#!/bin/bash + +cd /vagrant + +if [[ ! -f ~/localconfig || ! -f /data/params ]]; then + perl checksetup.pl /home/vagrant/checksetup_answers.txt + perl checksetup.pl /home/vagrant/checksetup_answers.txt +else + cp ~/localconfig /vagrant + perl checksetup.pl < /dev/null + cp /vagrant/localconfig ~/ +fi diff --git a/vagrant_support/bmo-configured b/vagrant_support/bmo-configured deleted file mode 100755 index 4d421577b..000000000 --- a/vagrant_support/bmo-configured +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -if [[ ! -f /vagrant/localconfig ]]; then - echo "missing localconfig" - exit 1 -fi - -if [[ ! -f /vagrant/data/params ]]; then - echo "missing data/params" - exit 1 -fi - -if grep -q "'urlbase' => ''" /vagrant/data/params; then - echo "urlbase not configured" - exit 1; -fi - -if grep -q '$db_host.*localhost' /vagrant/localconfig; then - echo "\$db_host not configured" - exit 1 -fi - -for file in /vagrant/data/params /vagrant/index.cgi; do - info="$(stat -c %U.%G "$file")" - - if [[ $info != "vagrant.apache" ]]; then - echo "wrong file owner: $info $file" - exit 1 - fi -done - -cd /vagrant -sudo -u apache perl -T index.cgi &>/tmp/index.html || exit 1 - -grep -q skin-Dusk /tmp/index.html && exit 1 - -rm /tmp/index.html - -exit 0 diff --git a/vagrant_support/bmo-generate-data.j2 b/vagrant_support/bmo-generate-data.j2 new file mode 100644 index 000000000..79798ba4d --- /dev/null +++ b/vagrant_support/bmo-generate-data.j2 @@ -0,0 +1,4 @@ +#!/bin/bash + +cd /vagrant +perl scripts/generate_bmo_data.pl 'vagrant@{{ WEB_HOSTNAME }}' diff --git a/vagrant_support/bmo-reconfigure.j2 b/vagrant_support/bmo-reconfigure.j2 deleted file mode 100755 index 77a9d2465..000000000 --- a/vagrant_support/bmo-reconfigure.j2 +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -cd /vagrant -rm localconfig data/params -perl checksetup.pl /home/vagrant/checksetup_answers.txt -perl checksetup.pl /home/vagrant/checksetup_answers.txt -perl scripts/generate_bmo_data.pl 'vagrant@{{ WEB_HOSTNAME }}' diff --git a/vagrant_support/checksetup.yml b/vagrant_support/checksetup.yml index 5bac17662..6b54ef18d 100644 --- a/vagrant_support/checksetup.yml +++ b/vagrant_support/checksetup.yml @@ -1,8 +1,14 @@ --- -- name: bmo reconfiguration script +- name: bmo checksetup script template: - src: bmo-reconfigure.j2 - dest: /usr/local/bin/bmo-reconfigure + src: bmo-checksetup.j2 + dest: /usr/local/bin/bmo-checksetup + mode: 0755 + +- name: bmo generate data script + template: + src: bmo-generate-data.j2 + dest: /usr/local/bin/bmo-generate-data mode: 0755 - name: bmo checksetup answers @@ -13,22 +19,11 @@ group: vagrant mode: 0644 -- name: copy bmo config checker script - copy: - src: bmo-configured - dest: /usr/local/bin/bmo-configured - mode: 0755 - -- name: 'check bmo config (failure is okay)' - shell: /usr/local/bin/bmo-configured - register: bmo_configured - ignore_errors: true +- name: run checksetup + become: false + shell: sg apache -c '/usr/local/bin/bmo-checksetup' -- name: configure bmo +- name: generate data become: false - shell: sg apache -c '/usr/local/bin/bmo-reconfigure' - when: bmo_configured|failed + shell: sg apache -c '/usr/local/bin/bmo-generate-data' -- name: check bmo config - shell: /usr/local/bin/bmo-configured - when: bmo_configured|failed diff --git a/vagrant_support/playbook.yml b/vagrant_support/playbook.yml index c8ebff01f..a8deeca27 100644 --- a/vagrant_support/playbook.yml +++ b/vagrant_support/playbook.yml @@ -150,7 +150,7 @@ - name: make bmo data dir file: path=/data state=directory owner=vagrant group=apache mode=0775 - - name: fix perms + - name: fix owner of /vagrant file: path=/vagrant state=directory owner=vagrant group=apache recurse=yes - name: add data symlink |