Help:MediaWiki-Vagrant in Labs
MediaWiki-Vagrant in Labs provisions a full MediaWiki stack 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
- 1 Setting up your instance with MediaWiki-Vagrant
- 2 Additional commands
- 3 How do I...?
- 3.1 Update MediaWiki-Vagrant to the latest version
- 3.2 Update the custom MediaWiki-Vagrant Vagrant plugin?
- 3.3 Update MediaWiki and other applications
- 3.4 Edit MediaWiki and other git managed files
- 3.5 Migrate from using role::labs::vagrant
- 3.6 Create new MediaWiki-Vagrant roles
- 3.7 Test my puppet changes to Mediawiki-Vagrant
- 3.8 Choose how big an instance to use
- 3.9 Run a wikifarm on a single labs-vagrant host
- 3.10 Access the MySQL database
- 4 Troubleshooting
- 5 See also
Setting up your instance with MediaWiki-Vagrant
- 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.
- Create your instance
- Choose the m1.medium or m1.large instances (4 and 8 GB RAM respectively) if your wiki will see a lot of use. m1.small is usually fine for a quick testing project.
- Choose Image type
ubuntu-14.04-trusty. MediaWiki-Vagrant will not run on the default
- Choose a security group that allows access on port 8080. (On Wikitech this can only be done while creating the instance, after that only Horizon can change it.)
- Apply the role
role::labs::mediawiki_vagrant. You can do this in Horizon in
Puppetsection. If you don't want to apply this to all instances, create new prefixes as needed, and choose the role from the list of preset Common puppet rules.
- ssh to your instance, and run sudo puppet agent --test --verbose to ensure that the latest Puppet changes have been applied.
- Log out and log back in (so that your shell will pick up the command alias from
profile.dthat will make the vagrant command run Vagrant as the
mwvagrantshared user account). Note: skipping this step will cause problems!
- Change to the directory that MediaWiki-Vagrant has been pre-installed in: cd /srv/mediawiki-vagrant
- Start the LXC container and provision MediaWiki in it: vagrant up
- 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.
- Setup a proxy to port
8080on your instance.
- If your chosen proxy name is not the same as the hostname of the Labs instance, you will need to override the default value for
role::mediawiki::hostnameby creating a config file at /srv/mediawiki-vagrant/puppet/hieradata/local.yaml with
role::mediawiki::hostname: <your new proxy hostname>.wmflabs.organd apply the change using vagrant provision.
https://<your new proxy hostname>.wmflabs.orgto see your new wiki
- 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.
Caution: There are many default settings in MediaWiki-Vagrant that leave your wiki insecure, it is tuned primarily to be a local development environment.
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:
- vagrant roles list to see all roles that you can enable.
- vagrant roles enable <role> to enable a role.
- vagrant provision to apply role changes to your LXC container.
- vagrant ssh to open a command shell inside the LXC container.
- 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
git pull (as yourself) in the
Note: if there have been changes to the mediawiki-vagrant ruby code (Vagrant plugin), you will need to force a Puppet run on the host computer using
sudo -i puppet agent --test --verbose in order to update the Vagrant installation to use the newer plugin code.
Update the custom MediaWiki-Vagrant Vagrant plugin?
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
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
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.
role::labs::vagrant has been renamed
role::deprecated::labsvagrant. To find hosts where it is still in use, see watroles.
Create new MediaWiki-Vagrant roles
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.
- Submit a patchset to Mediawiki-Vagrant via Gerrit
- ssh to your labs instance, and cd to
- Cherry-pick your patch from gerrit (you can copy paste the relevant
git cherry-pickcommand from the gerrit page for your changeset)
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
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.yamlfile containing a base name that will be common to all of the wikis in your farm:
mwv::tld: '-mycommonwikifarmname.wmflabs.org' role::mediawiki::hostname: "mycommonwikifarmname.wmflabs.org" mediawiki::multiwiki::base_domain: "-mycommonwikifarmname.wmflabs.org"
- Enable role(s) that provide additional wikis (e.g. centralauth, wikidata)
vagrant provisionto update the /etc/apache2/site-confs/devwiki/00-default.conf
- Configure web proxies to route to your instance using hostnames like
mywikihere would be the same name that precedes
.wiki.local.wmftest.netwhen you are using MediaWiki-Vagrant on a laptop (e.g. "login", "centralauthtest", "wikidata", etc)
- it can be handy to configure a proxy for
bogus-mycommonwikifarmname.wmflabs.orgso that you can visit the wiki via an invalid hostname (which will make it list all the valid ones)
Access the MySQL database
When you install MediaWiki using MediaWiki-vagrant, it will install it an instance of MySQL server inside the vagrant virtual machine. To access the database, you should first connect to the virtual. To do that you should first go to the directory where the virtual machine is stored (typically
/srv/mediawiki-vagrant) and run
vagrant ssh to connect to the virtual machine. At this point, you can simply run
mysql at the command prompt of that virtual machine to connect to the MySQL server.
"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.
Error message: "A Vagrant environment or target machine is required to run this command."
mwvagrant@my-cool-vm:~$ vagrant ssh A Vagrant environment or target machine is required to run this command. Run `vagrant init` to create a new Vagrant environment. Or, get an ID of a target machine from `vagrant global-status` to run this command on. A final option is to change to a directory with a Vagrantfile and to try again.
This error has two likely causes:
- Your shell session does not have the necessary alias that remaps
mwvagrant@my-cool-vm:~$ type -a vagrant vagrant is aliased to `/usr/local/bin/mwvagrant' vagrant is /usr/bin/vagrant
- Solution: log out and log back into your Labs VM.
- Your working directory is not
/srv/mediawiki-vagrantor a subdirectory.
cd /srv/mediawiki-vagrantand then try your command again.
Server not found
If your chosen proxy name is not the same as the hostname of the Labs instance, you will need to override the default value for
role::mediawiki::hostname by creating a config file at /srv/mediawiki-vagrant/puppet/hieradata/local.yaml with
role::mediawiki::hostname: <your new proxy hostname>.wmflabs.org and apply the change using vagrant provision.