Help:MediaWiki-Vagrant in Labs

From Wikitech
Jump to navigation Jump to search
MediaWiki-Vagrant logo

MediaWiki-Vagrant in Labs is enabled by applying the role::labs::mediawiki_vagrant Puppet role to a Labs instance. This role will install Vagrant, LXC and MediaWiki-Vagrant on the target host. This combination allows using the full features of the MediaWiki-Vagrant stack including the custom Vagrant plugin on the labs host.

This role replaced the former method of applying the MediaWiki-Vagrant Puppet configuration directly on the Labs host via role::labs::vagrant.

Setting up your instance with MediaWiki-Vagrant

  1. Ensure your project has a security group that allows access on port 8080, the default port for MediaWiki-Vagrant HTTP requests. The security group may be named "Web" or "web-server", or the "default" security group for your project may allow on port 8080.
  2. Create your instance
    • Choose Image type ubuntu-14.04-trusty. MediaWiki-Vagrant will not run on the default debian-8.1-jessie base image.
    • Choose a security group that allows access on port 8080. (This can only be done while creating the instance!)
  3. Apply the role role::labs::mediawiki_vagrant. You can do this by clicking on the "configure" next to your instance in the table of all instances.
  4. ssh to your instance, and run sudo puppet agent --test --verbose to ensure that the latest Puppet changes have been applied.
  5. Log out and log back in to pick up profile.d alias that will make the vagrant command run Vagrant as the mwvagrant shared user account. Note: skipping this step will cause problems!
  6. Change to the directory that MediaWiki-Vagrant has been pre-installed in: cd /srv/mediawiki-vagrant
  7. Start the LCX virtual machine and provision MediaWiki in it: vagrant up
  8. Verify that the new wiki is accessible from the host: curl http://localhost:8080/wiki/Main_Page
    • If you get an error like "curl: (7) Failed to connect to localhost port 8080: Connection refused" you may need to run vagrant reload to restart the LXC container and trigger Vagrant to setup the proper port forwarding.
  9. Setup a proxy to port 8080 on your instance.
  10. Visit https://<your new proxy hostname>.wmflabs.org to see your new wiki
  11. Login to MediaWiki on your instance as user admin then use Special:ChangePassword to change the admin password to something other than the MediaWiki-Vagrant default.
Warning Caution: There are many default settings in MediaWiki-Vagrant that leave your wiki insecure, it is tuned primarily to be a local development environment.

Additional commands

Since you are using the full MediaWiki-Vagrant stack on your instance, the same commands that you are used to using for local MediaWiki-Vagrant development on your laptop apply:

  1. vagrant roles list to see all roles that you can enable.
  2. vagrant roles enable <role> to enable a role.
  3. vagrant provision to apply role changes to your LXC container.
  4. vagrant ssh to open a command shell inside the LXC container.
  5. See MediaWiki-Vagrant for additional instructions and tips.

How do I...?

Most of your questions should be answered by reading the How do I...? section on the MediaWiki-Vagrant page. Since 99% of the code is re-used, most of your questions should be answered there.

Update MediaWiki-Vagrant to the latest version

Run git pull (as yourself) in the /srv/mediawiki-vagrant directory.


Update the custom MediaWiki-Vagrant Vagrant plugin?

After updating /srv/mediawiki-vagrant via git pull you may receive an error from the vagrant command similar to "Message: RuntimeError: Your mediawiki-vagrant plugin isn't up-to-date. Please re-run `setup.sh`." If you try to follow this advice the setup.sh command will fail with a "Permission denied" error. This happens because the Vagrant environment is actually owned by the mwvagrant user and vagrant is a shell alias to a wrapper script that uses sudo.

The easiest way to update the installed version of the MediaWiki-Vagrant Vagrant plugin is by running Puppet on the host computer: sudo puppet agent --test --verbose. If you really want to update manually for some reason, this command should work: cd /srv/mediawiki-vagrant && sudo -u mwvagrant -n -- /usr/bin/env VAGRANT_HOME="/srv/vagrant-data" ./setup.sh


Update MediaWiki and other applications

The Vagrant command git-update intelligently upgrades most of the pieces of MediaWiki.

$ cd /srv/mediawiki-vagrant
$ vagrant git-update


Edit MediaWiki and other git managed files

It's probably easiest to become user mwvagrant as that user owns most content that is managed by MediaWiki-Vagrant.

$ sudo su mwvagrant
$ cd mediawiki
$ # Make temporary local changes, etc.
$ exit


Migrate from using role::labs::vagrant

The best way to do this is just to build a new VM with role::labs::mediawiki-vagrant following the instructions above and migrate your wiki content and configuration over to the new host using normal methods. See Manual:Moving_a_wiki for more instructions.


Create new MediaWiki-Vagrant roles

Patch the mediawiki-vagrant repository, either on gerrit or github. See mw:MediaWiki-Vagrant for more details.


Test my puppet changes to Mediawiki-Vagrant

The best idea is for you to develop your patches in your local machine, push them to gerrit, pull them onto the labs machine and test it there. This ensures that you don't have to put your private keys on the labs instance.

  1. Submit a patchset to Mediawiki-Vagrant via Gerrit
  2. ssh to your labs instance, and cd to /srv/mediawiki-vagrant
  3. Cherry-pick your patch from gerrit (you can copy paste the relevant git cherry-pick command from the gerrit page for your changeset)
  4. Run vagrant provision


Choose how big an instance to use

Consider that Vagrant runs several services by default, including MySql, HHVM and a Redis jobrunner. Especially if you plan to run heavy operations like unit testing big masses of code, to avoid swapdeath and/or OOM, choose the m1.medium or m1.large instances (4 and 8 GB RAM respectively).


Run a wikifarm on a single labs-vagrant host

When using roles like centralauth and wikidata you will need to be able to access multiple wikis that are provisioned on a single Labs virtual machine. By default, role::labs::mediawiki-vagrant sets up its Apache2 configuration so that if you are running from a Labs instance named mycoolproject.eqiad.wmflabs then Apache will route requests for something-mycoolproject.wmflabs.org the same as MediaWiki-Vagrant would route something.wiki.local.wmftest.net. All you need to do to get access to these wikis is to follow the instructions at Help:Proxy to setup a proxy for the something-mycoolproject.wmflabs.org DNS hostname to your mycoolproject.eqiad.wmflabs instance.

If you want to change the base name of the wikifarm to something more meaningful for external users, you can customize the name by adding local hiera configuration data:

  • Make a /srv/mediawiki-vagrant/puppet/hieradata/local.yaml file containing a base name that will be common to all of the wikis in your farm:
mediawiki::multiwiki::base_domain: "-mycommonwikifarmname.wmflabs.org"
  • Enable role(s) that provide additional wikis (e.g. centralauth, wikidata)
  • Run vagrant provision to update the /etc/apache2/site-confs/devwiki/00-default.conf
  • Configure web proxies to route to your instance using hostnames like mywiki-mycommonwikifarmname.wmflabs.org
    • mywiki here would be the same name that precedes .wiki.local.wmftest.net when you are using MediaWiki-Vagrant on a laptop (e.g. "login", "centralauthtest", "wikidata", etc)
  • Profit!

Troubleshooting

"No usable default provider could be found for your system."

This usually means that the shell alias for vagrant has not been setup for the current shell. type -a vagrant is expected to return "vagrant is aliased to '/usr/local/bin/mwvagrant'". source /etc/profile.d/alias-vagrant.sh can be used to set the alias in the current shell or the user can log out and log back into the Labs host.

See also