A beginners guide to Vagrant and Puppet, part 3 – facts, conditionals and modules | erikaheidi

If you are just starting with Puppet and Vagrant and already have your first default.pp, this article will guide you from the moment when you already have a big enough single file to start separating it to modules. Pay a special attention to the directory and files organization which is the current style and if you are still using import ..pp you should replace it with modules:

A beginners guide to Vagrant and Puppet, part 3 – facts, conditionals and modules | erikaheidi.

Put your GitLab on HTTPS

For this article I will use the following configuration:

GitLab Docker image by sameersbn – Since the rise of Docker LXC I prefer to encapsulate all of my apps in production with it.

Docker is really easy to install. Just follow the instructions from here: https://docs.docker.com/installation or directly for Ubuntu users here: https://docs.docker.com/installation/ubuntulinux/.

Then follow the installation instructions of the Docker image here: https://github.com/sameersbn/docker-gitlab#installation.

Of course you can just install GitLab for you OS using their instructions here: https://about.gitlab.com/installation/.

My specific configuration is to put the Docker GitLab container behind a main nginx which becomes a reverse proxy for the container. Only the GitLab SSH console’s port is mapped directly to the host.

You may decide to map the GitLab ports directly to the host’s external IP and use it that way. The instructions on the Docker GitLab image are given with this in mind.

Now let’s say you have a running GitLab server behind or not an nginx reverse proxy. It’s working with ssh:// and http:// access for git clone/pull/push. You are getting used to it and now you want to make it the professional way: using HTTPS!

The first thing is to consider where will you get an SSL certificate from?

There are many companies out there selling good certificates for web sites, mail servers, etc. Some of them are expensive, others are very cheap. It depends on that whether you need to use it for multiple subdomains, will it be recognizable by all browsers and other software and so on. The third type are free. They are limited but they are recognized by the browsers and in our case by git/curl/OS too. Since they are free we don’t need to create self signed certificates and force everybody using our site to install certificates locally or to accept the warnings.

My personal choice is StartSSL. They give you a free certificate, it’s CA authorized and it’s working with a subdomain. I haven’t checked yet StartSSL’s other alternatives which are paid and also other providers of free certificates but for our case we only need the certificate for one thing and one place. In my case: https://gitlab.iliyan-trifonov.com and git clone https://gitlab.iliyan-trifonov.com/..project-name.git.

Now go to the free certificate page on StartSSL and sign up. Create a backup of the certificate you will install on your browser because without it you will have to pay to recover your account access. When you’re ready and you’re in the Control Panel of the site, authorize your email and domain. Also for a subdomain I picked gitlab as in gitlab.iliyan-trifonov.com.

From StartSSL you will get a .key file and a .crt file. Back them up.

There is a little more work to make the certificate compatible with git. Before that you can already use the key and crt files in your web server and make your site using https. But this is not enough for us so let’s continue.

First decrypt the key file using the following command and the password you provided while generating it on StartSSL:

openssl rsa -in ssl.key -out ssl-decrypted.key

This will prevent your web server to ask you for the password every time it is started. Imagine the downtime if the server was restarted automatically and it is waiting for a human to continue its work.

We need 2 more files freely available from StartSSL to make our certificate combined with their Root CA and Intermediate CA:

wget http://www.startssl.com/certs/ca.pem
wget http://www.startssl.com/certs/sub.class1.server.ca.pem

Combine the 3 certificate files you have:

cat ssl.crt sub.class1.server.ca.pem ca.pem > ssl-unified.crt

There is a possibility that the concatenated crt file will have some BEGIN/END lines on the same line. If your web server is not happy with that and says bad end of file in its logs, do this: open ssl-unified.crt with a text editor like nano and search for a line like this:

-----END CERTIFICATE----------BEGIN CERTIFICATE-----

or

-----BEGIN CERTIFICATE----------END CERTIFICATE-----

Make sure BEGIN and END are on a separate files and also that the B of the BEGIN and E of the END are on the same column, like this:

-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----

Not like this or similar:

-----BEGIN CERTIFICATE----
------END CERTIFICATE-----

Dashes on the left/right should be equal.

Now the only 2 files you need to use in your web server are ssl-unified.crt and ssl-decrypted.key.

It’s time to go to Nginx and make the configuration:

server {
    server_name gitlab.yourdomain.com;
    listen 80;
    
    return 301 https://$server_name$request_uri;

    access_log /var/log/gitlab.access.log;
    error_log /var/log/gitlab.error.log;
}

server {
    server_name gitlab.yourdomain.com;
    listen 443 ssl;

    ssl_certificate /.../certs/ssl-unified.crt;
    ssl_certificate_key /.../certs/ssl-decrypted.key;

    access_log /var/log/gitlab.ssl.access.log;
    error_log /var/log/gitlab.ssl.error.log;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header Host $http_host;
         proxy_set_header X-Forwarded-Proto $scheme;
         proxy_redirect off;
         proxy_read_timeout 300;
         proxy_pass http://INTERNAL_IP:INTERNAL_PORT; #the docker gitlab container's address
     }
}

Remember that this example Nginx configuration is for Nginx running as a reverse proxy to the container. In your case you may have decided to not have a reverse proxy and then you have to use the really easy configuration of the Dockerized GitLab from the link above or change the GitLab’s server configuration in a similar way. Still the preparation of the good .crt and .key files and the server configuration will give you a good start.

For better security read Configuring HTTPS servers and Enabling Perfect Forward Secrecy.

At the end you will have your GitLab pages loaded with HTTPS and everybody can git clone https://yourgitlabserver.com/..project.git like a pro!

Your first app: node.js by Jim Schubert

I started reading the book “Your first app: node.js” by Jim Schubert.

It has a good amount of pages which I really like and teaches us how to create a whole application from installing Node.JS, using npm and adding modules, configure and use the server and client testing tools, building the client side, getting used with MongoDB, using JavaScript the clever way, improving our code on every chapter, to the very end when we will enjoy our completely finished app!

The software tools/libs we will get used to at the and are: Node.js, AngularJS, Express, MongoDB, Git, Bootstrap and more.
The book also has links to a priceless information connected to these tools and JavaScript.

I am at 1/3 of the book and already have learnt things about JavaScript that I would never find easily by myself.

Before that book I’ve started reading 2-3 other books but after some reading and waiting to get the knowledge of creating my own app I couldn’t do anything because I was like reading to random pieces of the documentation. Not that reading the documentation for a new language or framework is not necessary but it should be done after we have some knowledge about how to create an app with it(simple demos, examples) and then using the documentation to upgrade our skills and then write the app in an even better way.

On the book’s page you will find the “table of contents” and a free sample. The price is best too. Do not hesitate and check it now!

First things to do when you just installed Ubuntu

Open the windows in center:

http://askubuntu.com/questions/142128/open-windows-in-center-of-screen

Open Terminal menu from Nautilus:

http://askubuntu.com/questions/207442/how-to-add-open-terminal-here-to-nautilus-context-menu

Improve Bash’s prompt for Git:

http://blog.iliyan-trifonov.com/current-git-branch-name-in-command-prompt-martinvalasek-com/

Current Git branch name in command prompt | martinvalasek.com

Current Git branch name in command prompt | martinvalasek.com.

You may want to add a new line at the end with:

\n\$

The new line is just before the $ symbol at the end. I’ve got used to the git-bash Windows prompt and prefer it that way. It also saves some space for your long commands.