]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1602566 - Update vagrant config and docs to allow using Windows Hyper-V VMs
authordklawren <dklawren@users.noreply.github.com>
Wed, 11 Dec 2019 22:21:19 +0000 (17:21 -0500)
committerGitHub <noreply@github.com>
Wed, 11 Dec 2019 22:21:19 +0000 (17:21 -0500)
README.rst
Vagrantfile
vagrant_support/hyperv-static-ip-db.j2 [new file with mode: 0644]
vagrant_support/hyperv-static-ip-web.j2 [new file with mode: 0644]
vagrant_support/playbook.yml

index b59eaaad143a8b1aa69f392ac0ce11ef3182bdb9..51a2cef4accaffcbdd9a14e57970aabffe2db304 100644 (file)
@@ -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
index bc3da0585321c17bba6c0b3b087560bf3f27edb2..d0a6084766a25f90b8db27f33a032a04843b63a5 100644 (file)
@@ -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 (file)
index 0000000..49ee158
--- /dev/null
@@ -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 (file)
index 0000000..a7c8e58
--- /dev/null
@@ -0,0 +1,8 @@
+DEVICE=eth0:0
+TYPE=Ethernet
+ONBOOT=yes
+BOOTPROTO=none
+IPADDR={{WEB_IP}}
+PREFIX=24
+GATEWAY={{GATEWAY_IP}}
+DNS1={{DNS_IP}}
index 2de67b77be4c96abd7507f16126808a7b9ca01b4..28bab99248d12bfd12b7b490a038b98b0cdf56a0 100644 (file)
 - 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
     - 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:
         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