Creating Self Hosted puppetmaster in Wikitech labs

While trying to test an exim-puppet patch ( gerrit.wikimedia.org/r/#/c/155753/ ) which adds a new router in one of my labs instance, I came across the need to create a self hosted puppetmaster. For starters ( like I was few days before ), puppet is a provisioning language, as they call it and applies pre-written configuration files to various daemons and tools coming under its realm. For example, I can set it to generate a standardized exim4.conf file when its run, this standardizing file need not be on the local machine you are working on. A self hosted puppetmaster will have all the configuration files packed inside a local directory – which is inside /var/lib/git/operations/puppet/
Where it come useful :
* It come into use when you want to play around with the default configuration files of your instance.
* When you dont want your changes not to be overwritten by the default puppet configured files.
Steps to make your Wikitech labs instance as a self hosted puppetmaster:
* make sure that all previously enabled roles were applied and puppet is running completely.

$ sudo puppet agent -tv

* go to Special:NovaInstance and select configure on your preferred instance.
* now, add tick the role role::puppet::self . This is our required self puppetmaster role
* go to your instance shell and give the command:

$ sudo service puppetmaster restart
$ sudo puppet agent -tv 

* now make sure you have the pupept repo in your local instance.

$ cd /var/lib/git/operations/puppet/ 

if the folder exists – Yay!
Now, you can apply your operations/puppet patches to this folder.

Using IMAP with dovecot in Wikitech labs instance

While working with the VERP project, we thought of installing a dovecot IMAP environment and alter the local_delivery to a Maildir in $home/Maildir according to https://nsrc.org/workshops/2005/pre-SANOG-VI/bc/mail/maildir.htm
Problem:
* Set up and open IMAP in labs instance
Solution:
* First install dovecot using the commands
sudo apt-get install dovecot-imapd dovecot-pop3d
and edit etc/dovecot/dovecot.conf: to add
protocols = imap imaps
Configure Mailboxes
mail_location = maildir:~/Maildir
and now, if you are using exim4 as your mailer
go to /etc/exim4/exim4.conf
and edit the local_delvier part to [2]:

local_delivery:
driver = appendfile
directory = $home/Maildir
maildir_format
maildir_use_size_file
delivery_date_add
envelope_to_add
return_path_add

Now you have done with dovecot, and exim — time to open up the IMAP port 143
in terminal, give:
# sudo iptables -A INPUT -p tcp --dport 143 -j ACCEPT
and give reboot to reboot the system
now, to test things are working, give
# telnet localhost imap
if you see a connection refused, you will have to add the IMAP port (143) to the Wikitech-I labs Manage Security Groups.
now, again reboot, if necessary -- and do # telnet localhost imap
and you will recieve the telnet shell 🙂 Horray
* References:
[1] https://help.ubuntu.com/community/Dovecot
[2] https://nsrc.org/workshops/2005/pre-SANOG-VI/bc/mail/maildir.htm

$ mosh – ing into the Wikitech bastion host

Those who got no idea what bastion server is :-
* bastion host :- A Bastion host is a special purpose computer on a network specifically designed and configured to withstand attacks. The computer generally hosts a single application, for example a proxy server, and all other services are removed or limited to reduce the threat to the computer. ( from wikipedia 😉

Being far away from the Wikitech hosts, I had my own difficulties connecting to my Wikitech labs instance. The response time between key stroke and output almost crossed 1 sec in certain cases. Desperate, I was searching for alternatives for SSH, and came across this amazing software, mosh (http://mosh.mit.edu/).
You can install mosh by :- $ sudo apt-get install mosh
You can connect via mosh using the folowing command :
$ mosh user@server.com
instead of $ ssh user@server.com

Troubleshooting connection to Wikitech-Labs:-
* If you get an error message like :

$ mosh user@bastion.wmflabs.org
mosh-server: invalid option -- 'l'
Usage: mosh-server new [-s] [-i LOCALADDR] [-p PORT] [-c COLORS] [-- COMMAND...]
mosh-server: invalid option -- 'l'
Usage: mosh-server new [-s] [-i LOCALADDR] [-p PORT] [-c COLORS] [-- COMMAND...]
mosh-server: invalid option -- 'l'
Usage: mosh-server new [-s] [-i LOCALADDR] [-p PORT] [-c COLORS] [-- COMMAND...]
setlocale: No such file or directory
Connection to bastion.wmflabs.org closed.
/usr/bin/mosh: Did not find mosh server startup message.

if you are using
* the default bash shell :
$ nano .bashrc
* the zsh shell :
$ nano .zshrc

and add the following lines to the end of the file :-

export LANG="en_US.UTF-8 locale"
export LC_ALL="en_US.UTF-8"

to update the shell, run
$ source .zshrc
or
$ source .bashrc