From: dklawren Date: Wed, 11 Dec 2019 22:21:19 +0000 (-0500) Subject: Bug 1602566 - Update vagrant config and docs to allow using Windows Hyper-V VMs X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41727787bde93af43e1b67be7b2fdf2d9f2d4b77;p=thirdparty%2Fbugzilla.git Bug 1602566 - Update vagrant config and docs to allow using Windows Hyper-V VMs --- diff --git a/README.rst b/README.rst index b59eaaad1..51a2cef4a 100644 --- a/README.rst +++ b/README.rst @@ -73,6 +73,65 @@ Run `vagrant ssh web`, that should put you in the `/vagrant` directory. While there run `openssl req -newkey rsa:2048 -sha256 -nodes -keyout bmo-web.vm-key.pem -x509 -days 365 -out bmo-web.vm.pem`. Restart morbo and you should now be able to visit https://bmo-web.vm. +Vagrant and Windows Hyper-Vagrant +--------------------------------- + +Enable hyperv support in Windows 10 + +- Right click on the Windows button and select ‘Apps and Features’. +- Select Turn Windows Features on or off. +- Select Hyper-V and click OK. +- May need to reboot. + +Run PowerShell as Administrator + +- Press the Windows key. +- Type `powershell` in the search field. +- In the search results, select `Run as administrator`. + +Create NAT Switch with IP address of 192.168.3.1/24 + +.. code-block:: powershell + + New-VMSwitch -SwitchName “VagrantSwitch” -SwitchType Internal + New-NetIPAddress -IPAddress 192.168.3.1 -PrefixLength 24 -InterfaceAlias “vEthernet (VagrantSwitch)” + New-NetNAT -Name “NATNetwork” -InternalIPInterfaceAddressPrefix 192.168.3.0/24 + +Install DHCP Servor for Windows + +- http://www.dhcpserver.de/cms/ +- Configure to serve IP addresses to the NAT Switch network above. +- Set the IP range to be 100-254 + +Install Vagrant for Windows + +Install Git for Windows + +Set some environment variables to use for Vagrant + +.. code-block:: powershell + + [System.Environment]::SetEnvironmentVariable('HYPERV', '1') + +Update hosts file in Windows + +- Press the Windows key. +- Type `notepad` in the search field. +- In the search results, select `Run as administrator`. +- From Notepad, open the following file: ``C:\Windows\System32\Drivers\etc\hosts``. +- Add ``192.168.3.43 bmo-web.vm`` to the end of the file. +- Select File > Save to save your changes. + +Git clone BMO repo ``git clone https://github.com/mozilla-bteam/bmo bmo`` + +.. code-block:: bash + + cd bmo + vagrant up --provider hyperv + +When requested (twice), select the NAT Switch that was created earlier. You will need to atart the mojo server to access BMO from the browser +using ``vagrant ssh web -c 'start_morbo'``. In your browser go to: ``http://bmo-web.vm``. + Making Changes and Seeing them ------------------------------ @@ -106,6 +165,7 @@ script that runs a webserver and implements the auth delegation protocol. Provided you have `Mojolicious`_ installed: .. code-block:: bash + perl auth-test-app daemon Then just browse to `localhost:3000`_ to test creating API keys. @@ -461,7 +521,7 @@ changing the mail_delivery_method to either 'Test' or 'Sendmail'. Afterwards res ``vagrant reload``. With docker, only the default 'Test' option is supported. 'Test' option (Default for Docker) -~~~~~~~~~~~~~~~~~~~~~~~ +---------------------------------- With this option, all mail will be appended to a ``mailer.testfile``. @@ -469,7 +529,7 @@ With this option, all mail will be appended to a ``mailer.testfile``. - Using vagrant, run ``vagrant ssh web`` and then navigate to ``/vagrant/data/mailer.testfile``. 'Sendmail' option (Default for Vagrant) -~~~~~~~~~~~~~~~~~ +--------------------------------------- This option is useful if you want to preview email using a real mail client. An imap server is running on bmo-web.vm on port 143 and you can connect to it with diff --git a/Vagrantfile b/Vagrantfile index bc3da0585..d0a608476 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -3,14 +3,17 @@ DB_IP = ENV.fetch "BMO_DB_IP", '192.168.3.42' WEB_IP = ENV.fetch "BMO_WEB_IP", '192.168.3.43' +GATEWAY_IP = ENV.fetch "GATEWAY_IP", '192.168.3.1' +DNS_IP = ENV.fetch "DNS_IP", '8.8.8.8' DB_HOSTNAME = ENV.fetch "BMO_DB_HOST", 'bmo-db.vm' WEB_HOSTNAME = ENV.fetch "BMO_WEB_HOST", 'bmo-web.vm' DB_PORT = ENV.fetch "BMO_DB_PORT", 2221 WEB_PORT = ENV.fetch "BMO_WEB_PORT", 2222 -DB_MEM = ENV.fetch "BMO_DB_MEM", 512 +DB_MEM = ENV.fetch "BMO_DB_MEM", 512 WEB_MEM = ENV.fetch "BMO_WEB_MEM", 2048 -DB_CPU = ENV.fetch "BMO_DB_CPU", 1 +DB_CPU = ENV.fetch "BMO_DB_CPU", 1 WEB_CPU = ENV.fetch "BMO_WEB_CPU", 2 +HYPERV = ENV.fetch "HYPERV", 0 # this is for centos 6 / el 6 VENDOR_BUNDLE_URL = ENV.fetch "BMO_BUNDLE_URL", @@ -66,6 +69,9 @@ Vagrant.configure('2') do |config| WEB_HOSTNAME: WEB_HOSTNAME, DB_HOSTNAME: DB_HOSTNAME, VENDOR_BUNDLE_URL: VENDOR_BUNDLE_URL, + GATEWAY_IP: GATEWAY_IP, + DNS_IP: DNS_IP, + HYPERV: HYPERV } end @@ -123,7 +129,6 @@ Vagrant.configure('2') do |config| guest: 22, auto_correct: true - web.vm.synced_folder '.', '/vagrant', type: 'rsync', rsync__args: RSYNC_ARGS web.vm.provider 'virtualbox' do |v| diff --git a/vagrant_support/hyperv-static-ip-db.j2 b/vagrant_support/hyperv-static-ip-db.j2 new file mode 100644 index 000000000..49ee158b9 --- /dev/null +++ b/vagrant_support/hyperv-static-ip-db.j2 @@ -0,0 +1,8 @@ +DEVICE=eth0:0 +TYPE=Ethernet +ONBOOT=yes +BOOTPROTO=none +IPADDR={{DB_IP}} +PREFIX=24 +GATEWAY={{GATEWAY_IP}} +DNS1={{DNS_IP}} diff --git a/vagrant_support/hyperv-static-ip-web.j2 b/vagrant_support/hyperv-static-ip-web.j2 new file mode 100644 index 000000000..a7c8e58c1 --- /dev/null +++ b/vagrant_support/hyperv-static-ip-web.j2 @@ -0,0 +1,8 @@ +DEVICE=eth0:0 +TYPE=Ethernet +ONBOOT=yes +BOOTPROTO=none +IPADDR={{WEB_IP}} +PREFIX=24 +GATEWAY={{GATEWAY_IP}} +DNS1={{DNS_IP}} diff --git a/vagrant_support/playbook.yml b/vagrant_support/playbook.yml index 2de67b77b..28bab9924 100644 --- a/vagrant_support/playbook.yml +++ b/vagrant_support/playbook.yml @@ -88,6 +88,20 @@ - hosts: db become: true tasks: + - name: Add an Ethernet alias with static IP configuration (hyperv only) + template: + src: hyperv-static-ip-db.j2 + dest: /etc/sysconfig/network-scripts/ifcfg-eth0:0 + mode: 0644 + when: HYPERV == 1 + + - name: Restart network service for interface eth0:0 + service: + name: network + state: restarted + args: eth0:0 + when: HYPERV == 1 + - name: fetch ius-release.rpm get_url: url: https://moz-devservices-bmocartons.s3.amazonaws.com/third-party/ius-release.rpm @@ -128,12 +142,26 @@ - name: create bugs_bmo shell: |- mysqladmin -u root create bugs_bmo - mysql -u root -e 'GRANT ALL ON bugs_bmo.* TO bugs@"{{WEB_IP}}" IDENTIFIED BY "bugs"' + mysql -u root -e "GRANT ALL ON bugs_bmo.* TO 'bugs'@'%' IDENTIFIED BY 'bugs'" when: bugs_bmo is failed - hosts: web become: true tasks: + - name: Add an Ethernet alias with static IP configuration (hyperv only) + template: + src: hyperv-static-ip-web.j2 + dest: /etc/sysconfig/network-scripts/ifcfg-eth0:0 + mode: 0644 + when: HYPERV == 1 + + - name: Restart network service for interface eth0:0 (hyperv only) + service: + name: network + state: restarted + args: eth0:0 + when: HYPERV == 1 + - name: install web-specific packages yum: name={{item}} state=present with_items: @@ -189,11 +217,11 @@ src: '{{VENDOR_BUNDLE_URL}}' dest: /opt remote_src: true - when: opt_bmo|failed + when: opt_bmo is failed - name: check /opt/bmo shell: test -d /opt/bmo && test -f /opt/bmo/local/lib/perl5/Plack.pm - when: opt_bmo|failed + when: opt_bmo is failed - name: add local symlink file: path=/vagrant/local src=/opt/bmo/local state=link force=true