Difference between revisions of "MediaWiki-Vagrant"

From Freephile Wiki
Jump to navigation Jump to search
(add login info)
(Created page with "File:MediaWiki-Vagrant.png Using wp:MediaWiki-Vagrant, you can setup a development instance of MediaWiki in a snap. Specifically tuned for development of the MediaWi...")
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[File:MediaWiki-Vagrant.png]]
 
[[File:MediaWiki-Vagrant.png]]
  
Using [[mw:MediaWiki-Vagrant]], you can setup a development instance of MediaWiki in a snap.  Specifically tuned for development of the MediaWiki software, you get all the tools needed to dive right in to coding and patching.  To make it even easier to use, you can start off with https://github.com/dan-nl/mw-vagrant-prep
+
Using [[wp:MediaWiki-Vagrant]], you can setup a development instance of MediaWiki in a snap.  Specifically tuned for development of the MediaWiki software, you get all the tools needed to dive right in to coding and patching.
 
 
MediaWiki-Vagrant uses [[Puppet]] for configuration management and automation (not [[Ansible]]).
 
  
 
You'll notice in the screenshot that the VM comes pre-configured with shared folders to the host system so that you do not even need to SSH to the VM to see the puppet modules and logs.  You can work right on these from your host system.
 
You'll notice in the screenshot that the VM comes pre-configured with shared folders to the host system so that you do not even need to SSH to the VM to see the puppet modules and logs.  You can work right on these from your host system.
  
 
[[File:MediaWiki-Vagrant.screenshot.png | thumb | screenshot showing aspects of the MediaWiki-Vagrant system]]
 
[[File:MediaWiki-Vagrant.screenshot.png | thumb | screenshot showing aspects of the MediaWiki-Vagrant system]]
 
== Engineering / Architecture ==
 
MediaWiki-Vagrant runs on <strike>HHVM</strike><ref>[[mw:HHVM]]</ref><ref>Facecrook announced in Sept. 2017 that HHVM would not aim for PHP compatibility in the future.[https://hhvm.com/blog/2017/09/18/the-future-of-hhvm.html 1] After discussion[https://lists.wikimedia.org/pipermail/wikitech-l/2017-September/088784.html 2] WMF adopted a plan to [https://phabricator.wikimedia.org/T176370 migrate the WMF production cluster to PHP 7], first [https://phabricator.wikimedia.org/T174431 migrating appservers from Jessie to Stretch]. Once that's done, HHVM support will likely be dropped from MediaWiki (exact details tbd). See [https://phabricator.wikimedia.org/T176209 task T176209].</ref> PHP7-FPM with Apache etc. Of course it all relies on [[Vagrant]] and [[VirtualBox]]
 
 
Meanwhile, current versions of [[VirtualBox]] have [https://www.virtualbox.org/ticket/17490 problems with running Guest Additions on Linux]. This is but one ticket. There are tons of examples of breakage, and fixes haven't landed yet in a stable release.  Current solution: run development? (I'm checking on compatibility)
 
 
== Quick Tips ==
 
Be sure to check the documentation at [[mw:MediaWiki-Vagrant]]
 
 
* wiki login is 'Admin' 'vagrant'
 
* local shell user is 'vagrant' 'vagrant'
 
* ssh: <code>vagrant ssh</code>
 
 
<code>vagrant roles list</code> To enable certain roles in your MediaWiki Vagrant: <code>vagrant roles enable <role> -- provision</code>  Once you do this, and visit http://localhost:8080/wiki/Special:Version, you can check the product box showing the currently running versions of 'MediaWiki, PHP, MySQL, ICU' and extensions.
 
 
== DNS ==
 
MediaWiki Vagrant docs will tell you to visit http://dev.wiki.local.wmftest.net:8080/wiki which is fine, because this specific domain routes to 127.0.0.1 (your local host). There's nothing you have to do with DNS. All three of the following are equivalent.
 
* http://localhost:8080/wiki/Special:Version
 
* http://127.0.0.1:8080/wiki/Special:Version
 
* http://dev.wiki.local.wmftest.net:8080/wiki/Special:Version
 
 
== Deploy MediaWiki-Vagrant to Amazon ==
 
 
How to Deploy your MediaWiki-Vagrant instance to Amazon Web Services (AWS)
 
 
There is [http://www.iheavy.com/2014/01/16/how-to-deploy-on-amazon-ec2-with-vagrant/ this article] that explains how to do this, but I didn't want to create a separate VagrantFile.  After not succeeding, I should probably go back and try that approach.
 
 
Using multiple [http://docs.vagrantup.com/v2/plugins/providers.html providers] (AWS, Rackspace, VirtualBox, VMWare) ''with the same virtual machine'' is not a feature of Vagrant.  Supposedly this limitation will be removed in a future version of Vagrant.  But there is a work-around that you can use to accomplish this -- by creating a multi-machine environment.  We are describing that work-around.  There are some "cheap" solutions that tell you to either delete, or rename the hidden <code>.virtualbox</code> directory in your project source.  Don't do that.  That's just deleting the information that you'd need for using the existing provider.  Or, only do that if you are trying to permanently switch the provider used in your project -- which is not the case here.  To get a fully compatible MediaWiki-Vagrant setup that works for both localhost VirtualBox deployments and cloud Amazon AWS deployments, then read on.
 
 
=== Caveats ===
 
The MediaWiki-Vagrant setup is designed for local development and NOT for security, so it may not be suitable for running in the cloud.
 
 
The MediaWiki-Vagrant box is setup with NFS shares.  The Vagrant-aws plugin has nominal support for shared folders using rsync, so sharing the ~/vagrant folder might work, but it's unkown how well this works.  And it's unknown exactly how to disable the [http://docs.vagrantup.com/v2/synced-folders/basic_usage.html synced folders] in <code>Vagrantfile-extra.rb</code> that is defined in the Vagrantfile
 
 
=== Pre-requisites ===
 
 
==== AWS Account ====
 
You obviously need an AWS account, which you can get for free.  So head over to Amazon and create one.  You'll need to create a IAM user and a set of "Access" and "Secret" keys for this user at https://console.aws.amazon.com  (Dashboard -> Users -> User Actions -> Manage Access Keys)  Hint: if you want another user "Bob" to be able to login to your Amazon Console, they can't just use their email address.  You'll want to create a "Login Alias" which is a custom URL for accessing Amazon e.g.  https://example.signin.aws.amazon.com/console  You also must assign Bob a password in IAM.  Then Bob can signin at the Login Alias using the password that you gave him in IAM.
 
 
==== Console Tools ====
 
It may be helpful to have the command line tools for Elastic Cloud installed so that you can test your connection ability.  For Ubuntu,
 
<source lang="bash">
 
sudo apt-get install ec2-api-tools
 
ec2-describe-regions -v --auth-dry-run --aws-access-key KEY --aws-secret-key KEY
 
</source>
 
Rather than specifying your keys on the command line, you may want to set them in <code>~/.bashrc</code> and <code>source</code> the file to bring them into your current shell session. <ref>For some reason, this didn't work for me the first time, so I regenerated keys, and it worked.</ref>
 
 
<source lang="bash">
 
export AWS_ACCESS_KEY=THISISJUSTANEXAMPLE
 
export AWS_SECRET_KEY=ThisIsNotARealSecretEnterYourSecretHere
 
</source>
 
 
 
==== Vagrant-AWS Plugin ====
 
You need the vagrant-aws plugin (https://github.com/mitchellh/vagrant-aws)
 
<source lang="bash">
 
cd ~/vagrant
 
vagrant plugin install vagrant-aws
 
</source>
 
 
== Status ==
 
When you do a <code>vagrant status</code> check of your current MediaWiki-Vagrant setup, you'll see something like this:
 
 
<pre>
 
Current machine states:
 
default                  poweroff (virtualbox)
 
The VM is powered off. To restart the VM, simply run `vagrant up`
 
</pre>
 
 
The machine is called '''default''' and the provider is '''virtualbox'''.
 
 
If your virtual machine is not powered off, then do so with <code>vagrant halt</code>
 
 
== Boxes ==
 
The base box that is used at this time is [https://vagrantcloud.com/debian/boxes/contrib-stretch64/versions/9.4.0/providers/virtualbox.box Debian stretch] (see also https://app.vagrantup.com/debian). If you <code>vagrant up --provision</code> an old box based on Ubuntu, then it will prompt you to destroy the existing box (so that it can re-provision with the right OS) <code>vagrant destroy -f; vagrant up</code>
 
 
Each '[http://docs.vagrantup.com/v2/providers/basic_usage.html box]' in vagrant is specific to a provider, so we'll need to get a new box that will run on AWS.
 
 
 
<source lang="bash">
 
vagrant box add dummy https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box
 
vagrant box list
 
</source>
 
 
You need to create a custom stanza in <code>Vagrantfile-extra.rb</code><ref>Don't edit Vagrantfile since that is distributed by MediaWiki-Vagrant and you won't be able to upgrade your environment</ref>
 
 
The items you'll need are:
 
# aws.access_key_id
 
# aws.secret_access_key
 
# aws.keypair_name
 
# aws.ami
 
 
To get the access_key_id and secret_access_key, you login to your AWS account.  Here are the instructions http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSGettingStartedGuide/AWSCredentials.html
 
 
To get the keypair_name, you need to create (or upload) a keypair into your AWS Console for the region.  It's easy to create a keypair in the AWS console, and as soon as you do, it will prompt you to download the .pem file.  Save the .pem file to your ~/.ssh/ directory, and ensure the file mode is 400
 
<source lang="bash">
 
chmod 400 ~/.ssh/my-aws-keys.pem
 
</source>
 
 
Need to find the image (AMI) you want.  You can search for Ubuntu images at http://cloud-images.ubuntu.com/locator/ec2/ The latest Ubuntu version used in MediaWiki-Vagrant as of March 2015 is Trusty-Tahr (or 14.04 LTS) You need to choose the region that you want to host in.  So for example if you want to host in Oregon state, then you want the "US West" region for Amazon. Searching for "trusty 64 west" we can see several options for the AMD64 architecture
 
 
<pre>Instance Type hvm:ebs AMI-ID ami-a6b8e7ce</pre>
 
 
 
 
== Customize Vagrantfile-extra.rb ==
 
 
 
I tried to customize the Vagrantfile-extra.rb but couldn't quite understand the required structure
 
<source lang=ruby line>
 
# -*- mode: ruby -*-
 
# vi: set ft=ruby :
 
#
 
# Sample 'extra' configuration file for MediaWiki-Vagrant
 
# -------------------------------------------------------
 
# http://www.mediawiki.org/wiki/Mediawiki-Vagrant
 
#
 
# This file contains examples of some customizations you may wish to
 
# apply to your virtual machine. To use it, copy this file to its parent
 
# directory (i.e., the repository root directory).
 
#
 
# To apply a customization, uncomment its line by removing the leading
 
# '#'. Then save the file and run 'vagrant halt' followed by 'vagrant up'.
 
#
 
# Useful details about the structure and content of this file can be
 
# found in the Vagrant documentation, at:
 
# <http://docs.vagrantup.com/v2/vagrantfile/index.html>.
 
#
 
VAGRANTFILE_API_VERSION = "2"
 
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
 
 
 
    config.vm.provider :virtualbox do |vb|
 
        # For a full list of options you can pass to 'modifyvm', see
 
        # <http://www.virtualbox.org/manual/ch08.html>.
 
 
        # Boot the VM in graphical mode:
 
        # vb.gui = true
 
 
        # Increase memory allocation from 768MB to 1GB:
 
        # vb.customize ['modifyvm', :id, '--memory', '1024']
 
        vb.customize ['modifyvm', :id, '--memory', '2048']
 
 
        # But limit the virtual machine to 1 CPU core:
 
        # vb.customize ['modifyvm', :id, '--cpus', '1']
 
 
        # Fix dns resolution problem
 
        vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'off']
 
        vb.customize ['modifyvm', :id, '--natdnsproxy1', 'off']
 
    end
 
   
 
    # override the box used for MediaWiki-Vagrant with a box for AWS
 
    # we added this box at the command-line with
 
    # vagrant box add dummy https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box
 
    config.vm.define "default_virtualbox"
 
    config.vm.define "default_aws", autostart:false do |default_aws|
 
      default_aws.vm.box = "dummy"
 
    end
 
   
 
    supported_providers = %w(virtualbox aws)
 
    active_provider = ENV['VAGRANT_ACTIVE_PROVIDER'] # it'd be better to get this from the CLI --provider option
 
    supported_providers.each do |provider|
 
      next unless active_provider.nil? || active_provider == provider
 
      config.vm.define "default_#{provider}" do |box|
 
        box.vm.provider :aws do |aws, override|
 
          aws.access_key_id = 'RedactedSecret'
 
          aws.secret_access_key = 'RedactedSecret'
 
          aws.keypair_name = "eqt-mw-keys"
 
 
          aws.ami = "ami-7747d01e"
 
 
          override.ssh.username = "ubuntu"
 
          override.ssh.private_key_path = "/home/greg/.ssh/eqt-mw-keys.pem"
 
        end
 
      end
 
    end
 
   
 
   
 
#    config.vm.provider :aws do |aws, override|
 
#        aws.access_key_id = 'RedactedSecret'
 
#        aws.secret_access_key = 'RedactedSecret'
 
#        aws.keypair_name = "eqt-mw-keys"
 
#
 
#        aws.ami = "ami-7747d01e"
 
#
 
#        override.ssh.username = "ubuntu"
 
#        override.ssh.private_key_path = "/home/greg/.ssh/eqt-mw-keys.pem"
 
#    end
 
   
 
   
 
 
 
end
 
</source>
 
 
== Test or Run ==
 
When you're done with the customizations to the Vagrantfile-extra.rb
 
 
<source lang="bash">
 
vagrant status
 
## status looks good?
 
vagrant up --provider=aws
 
</source>
 
 
 
== Resources ==
 
[https://github.com/mitchellh/vagrant/issues/2733 This is the official 'response'] to this issue.  It offers a [https://gist.github.com/maxlinc/8c64c5e93734a3c939b8 gist] that supposedly addresses the problem of running multiple providers, but I wasn't able to figure out how to apply that to the MediaWiki-Vagrant setup. 
 
 
There is a somewhat related issue in Phabricator that requests a web front-end to make deployment easier.
 
https://phabricator.wikimedia.org/T53782
 
 
 
{{References}}
 
  
 
[[Category:DevOps]]
 
[[Category:DevOps]]
 
[[Category:Wiki]]
 
[[Category:Wiki]]
[[Category:Virtualization]]
 

Revision as of 12:21, 5 November 2014

MediaWiki-Vagrant.png

Using wp:MediaWiki-Vagrant, you can setup a development instance of MediaWiki in a snap. Specifically tuned for development of the MediaWiki software, you get all the tools needed to dive right in to coding and patching.

You'll notice in the screenshot that the VM comes pre-configured with shared folders to the host system so that you do not even need to SSH to the VM to see the puppet modules and logs. You can work right on these from your host system.

screenshot showing aspects of the MediaWiki-Vagrant system