Development Environments
========================

The puppet server gives access to a limited set of users to the
environment area, where prod and preprod environments are already
present, to create environments that can be used for new puppet code
development.

This area is accessible via sftp and can be mounted on users'
workstations via sshfs.

The typical workflow would be:

   #. user mounts the environment area (``puppet01:/envs/`` on the puppet master - this is the directory /srv/puppet/code/dev/envs on puppet01!) via sshfs on ``~/puppetenv``;
   #. user create a directory for the new environent (``mkdir ~/puppetenv/issue_x``);
   #. after a few seconds ``issue_x`` will be populated with a copy of the content of the the ``preprod`` environment with a proper git branch named ``issue_x``;
   #. user edits files in that directory;
   #. user run on some testing node the command ``puppet agent -t --environment=issue_x``;
   #. user iterates on steps number 4 and 5 until the code is ready;
   #. users makes the proper add/commit into the directory and finally pushes the code;
   #. from the git server web interface user triggers a merge request of the ``issue_x`` into the ``preprod`` branch.

Please note that ssh to the puppet server has to be done via ``wmgt`` nodes, e.g by using the option ``-oProxyJump=wmgt01.psi.ch``.

Environment names
-----------------

The name of the environment:

   - must be at least 4 characters long;
   - can include lower case letters, digits and the underscore character;
   - must start with a letter.

If the name is not compliant with these rules, the directory will be automatically removed.

SSHFS mount
-----------

Generally refer to your operating system instructions on how to
properly configure sshfs.

One caveat is that your local user can be different from the remote (puppet master)
user. In this case a file mapping your local username to the remote user id should be passed to the sshfs client.
The file should be in the form of::

   <local username>:<remote uid>

And should then be passed in the command like::

   sshfs -o idmap=file,uidfile=/Users/talamoig/uidmap,nomap=ignore,ProxyJump=wmgt01.psi.ch talamo_i@puppet01:/ ~/puppetenvs


