I need a place to build applications and test them out. I want to be able to show friends and spin up new projects quickly. I want to be able to recreate the server quickly.
For my development environment I'll use Debian Linux, and set up support for Docker and Perl.
I will rent a Debian 10 machine from Linode. Any host who provides root access to a Debian 10 virtual machine will suffice for setting this up. I like Linode, and they provide a guide if you've never done this type of thing before.
Now that I have rented a server and gained root access to the virtual machine, I will begin setting it up.
First, I'll install docker. This follows the installation guide provided by docker.
#!/bin/bash
apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose
docker run hello-world
Next I will install puppet. This will allow me to codify all of the rules for setting up the server.
#!/bin/bash
wget https://apt.puppet.com/puppet-tools-release-buster.deb
wget https://apt.puppet.com/puppet7-release-buster.deb
dpkg -i puppet-tools-release-buster.deb puppet7-release-buster.deb
rm puppet-tools-release-buster.deb puppet7-release-buster.deb
apt-get update
apt-get install kitty-terminfo puppet-agent pdk
Before I continue I will log out of the machine and log back in so the $PATH can update.
The file /etc/puppetlabs/code/environments/production/environment.conf will be updated. I want to have the modules divided into base, profile, and role modules. Modules will be installed into the base directory when we use puppet module install, but I will add my custom modules to the role directory.
I will edit the file /etc/puppetlabs/code/environments/production/environment.conf to include the following content.
modulepath = ./modules/base:./modules/profile:./modules/role:$basemodulepath
With these changes in place, I can install the puppet modules I need.
#!/bin/bash
puppet module install puppetlabs-accounts
puppet module install puppetlabs-ntp
puppet module install saz-sudo
Docker and puppet have been installed and the puppet environment is set up. Now it's time to create a module to set up the development environment from here. I will create the role directory and cd there, then create my module.
cd /etc/puppetlabs/code/environments/production/modules/
mkdir role
cd role
pdk new module modfoss_devel
cd modfoss_devel
pdk new class modfoss_devel
The instructions that puppet runs are stored in manifest files. The default manifest file is init.pp, this file I will replace with the following contents to define the instructions for setting up the server.
class modfoss_devel {
include accounts
include sudo
include ntp
file { "/etc/profile.d/locallib.sh":
ensure => 'present',
content => 'eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"',
}
package { 'git':
ensure => 'installed',
}
# Install local lib
package { 'liblocal-lib-perl':
ensure => 'installed',
}
# Install cpanminus
package { 'cpanminus':
ensure => 'installed',
}
# libpq is required for perl PSQL lib building
package { 'libpq-dev':
ensure => 'installed',
}
# libssl is required for perl SSL lib building
package { 'libssl-dev':
ensure => 'installed',
}
# libz is required for perl SSL lib building
package { 'libz-dev':
ensure => 'installed',
}
# Build essential is required to compile Perl things
package { 'build-essential':
ensure => 'installed',
}
}
This manifest file includes other modules like accounts and sudo. I could configure those in the code, but I prefer to use Heria to configure it with a yaml file.
The configuration file, /etc/puppetlabs/code/environments/production/data/common.yaml, should look roughly like this.
# Sudo Configuration
sudo::configs:
'sudo':
'content' : '%sudo ALL=(ALL) NOPASSWD: ALL'
## User Shell Accounts
accounts::group_defaults:
system: true
accounts::group_list:
admins: {}
users: {}
accounts::user_defaults:
groups: [ 'users' ]
managehome: true
system: false
accounts::user_list:
symkat:
groups:
- sudo
- docker
sshkeys:
- ssh-rsa AAAAB3Nzas....== symkat@laptop
- ssh-rsa AAAAB3Nsdf....== symkat@desktop
The configuration for sudo says that users in the sudo group will not need a password. I create a user for myself, in the appropriate groups and add ssh keys.
Now that everything is in place, I can run the following to configure the server:
puppet apply -e "include modfoss_devel"
Now that I have run through making this, I want to make it easier to get here in the future. I've combined the scripts above, and added a bit more to it so that it will install the entire environment from a fresh Debian 10 install with just one command.
curl https://raw.githubusercontent.com/symkat/modfoss_devel/master/install.sh | bash -s - YOUR.HOST.NAME.com
The repository is available on GitHub @ symkat/modfoss_devel.