Difference between revisions of "Services/MW-Vagrant"

From Wikitech-static
Jump to navigation Jump to search
imported>BryanDavis
(Use syntaxhighlight tags)
imported>Krinkle
 
Line 1: Line 1:
[[mw:MediaWiki-Vagrant|MediaWiki Vagrant]] is a very convenient way for developers to rapidly set up a development environment containing a MediaWiki instance and any needed dependencies in a virtualised environment. Your service needs to be present there as well. Luckily, setting it up is very easy. First, in the vagrant directory, create the directory for your service's module and place this code inside <tt><vagrant-dir>/puppet/modules/<service-name>/manifests/init.pp</tt>:
[[mw:MediaWiki-Vagrant|MediaWiki Vagrant]] is a convenient way for developers to rapidly set up a development environment containing a MediaWiki instance and any needed dependencies in a virtualised environment. Your service needs to be present there as well. Luckily, setting it up is very easy. First, in the vagrant directory, create the directory for your service's module and place this code inside <tt><vagrant-dir>/puppet/modules/<service-name>/manifests/init.pp</tt>:


<syntaxhighlight lang="puppet">
<syntaxhighlight lang="puppet">
Line 56: Line 56:
You are done! You can now submit the patch for review and anybody will be able to profit from the service in the MediaWiki-Vagrant environment.
You are done! You can now submit the patch for review and anybody will be able to profit from the service in the MediaWiki-Vagrant environment.


[[Category:Services]]
[[Category:Services| ]]

Latest revision as of 23:43, 15 March 2018

MediaWiki Vagrant is a convenient way for developers to rapidly set up a development environment containing a MediaWiki instance and any needed dependencies in a virtualised environment. Your service needs to be present there as well. Luckily, setting it up is very easy. First, in the vagrant directory, create the directory for your service's module and place this code inside <vagrant-dir>/puppet/modules/<service-name>/manifests/init.pp:

# == Class: <service-name>
#
# <a-short-description-of-the-service-here>
#
# === Parameters
#
# [*port*]
#   Port the service listens on for incoming connections.
#
# [*log_level*]
#   The lowest level to log (trace, debug, info, warn, error, fatal)
#
class <service-name>(
    $port,
    $log_level = undef,
) {

    service::node { '<service-name>':
        port      => $port,
        log_level => $log_level,
        config    => {},
    }

}

This is the minimum amount of code your service's Puppet module should have. As you can see, this definition does not provide any extra configuration for the service. If that is needed, simply add the configuration stanzas to the config hash as key/value pairs. Note that only configuration specific to your service should be listed here and not the whole configuration file, i.e. only the configuration parameters that your service code accesses via app.conf.*.

In order to configure the port (and any other parameters that you might have declared for the class), add the following contents to puppet/hieradata/common.yaml:

<service-name>::port: <service-port>

The last step is to create the role so that users may (de)activate it easily. Place the following Puppet code in puppet/module/role/<service-name>.pp:

# == Class: role::<service-name>
# This role installs <service-name>
#
class role::<service-name> {
    include ::<service-name>
}

Finally, the service's port must be exposed to the host environment; create the file puppet/modules/role/settings/<service-name>.yaml with:

forward_ports:
  <service-port>: <service-port>

You are done! You can now submit the patch for review and anybody will be able to profit from the service in the MediaWiki-Vagrant environment.