User Tools

Site Tools


dev-env-windows-aws

Build a Linux / AWS developer environnement on Windows with Vagrant

If the Bash for Windows (WSL) works on your machine, good for you ! Just use it.

Otherwise, your admin rights can be too restrictive or you may need to test other distributions, this method would work and allows you to choose a lot of Linux distributions and VM technologies.

In our case we focus on Debian/CentOS and Virtualbox, but it could vary according to your needs, following the same methodology.

Prerequesite tools

To install prerequesites quickly

PS(admin) > choco install -y git virtualbox vagrant cmder vscode

Install the Debian machine from Vagrant

# to launch the machine for the first time :
# make a dir for your vagrant machine configuration (e.g. ~/dev/vagrant/debian9)
PS > vagrant init debian/contrib-stretch64
PS > vagrant up --provider virtualbox
# to connect :
PS > vagrant ssh

# to define the configuration :
# in the vagrantfile, you can add this lines :
# config.vm.synced_folder "../../www", "/www"
# config.vm.provider "virtualbox"

# don't forget to stop the VM before stopping Windows : 
PS > vagrant halt

Install the CentOS machine from Vagrant

# to launch the machine for the first time :
# make a dir for your vagrant machine configuration (e.g. ~/dev/vagrant/centos7)
PS > vagrant init centos/7
PS > vagrant up --provider virtualbox
# to connect :
PS > vagrant ssh

# to sync the folder where you put your code :
# from virtualbox, attach the VBoxGuestAdditions CD to the machine, as an IDE controller
sudo -i
yum update
yum install dkms gcc make kernel-devel bzip2 binutils patch libgomp glibc-headers glibc-devel kernel-headers
mkdir -p /media/cdrom
mount /dev/sr0 /media/cdrom
sh /media/cdrom/VBoxLinuxAdditions.run

# to define the configuration :
# in the vagrantfile, you can add this lines :
# config.vm.synced_folder "C:/Users/<my-name>/dev/www", "/www"
# config.vm.provider "virtualbox"

# don't forget to stop the VM before stopping Windows : 
PS > vagrant halt

Bash first configuration on the Vagrant Debian machine

sudo apt update
sudo apt install -y wget vim htop tree git libssl-dev curl ruby python
echo "alias ls='ls --color=never'" >> ~/.bashrc # because the color is ugly when you go on synced folders
echo "alias l='ls -la'" >> ~/.bashrc # because it's convenient !

Bash first configuration on the Vagrant CentOS machine

sudo yum update
sudo yum install -y wget vim tree git openssl-devel ruby python
echo "alias ls='ls --color=never'" >> ~/.bashrc # because the color is ugly when you go on synced folders
echo "alias l='ls -la'" >> ~/.bashrc # because it's convenient !

Install Pip for Python

wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
python -V
pip -V

Install AWS CLI

pip install awscli --upgrade --user
echo "export PATH=~/.local/bin:$PATH" >> ~/.bashrc
echo "source ~/.local/bin/aws_bash_completer" >> ~/.bashrc
source ~/.bashrc
aws --version

Install CloudFormation linters

gem install --user-install --bindir $HOME/.local/bin  cfn-nag
pip install --user cfn-lint
pip install --user yamllint

Install Ansible

pip install ansible --upgrade --user
ansible --version

Before commiting to Git

ssh-keygen # and add your public key to Github or whatever
sudo update-alternatives --config editor # and choose your favorite text editor
git config --global --edit

Troubleshooting

# to ensure that hyperv doesn't block virtuabox, you can make a dual boot with "No Hyper-V" mode :
# (from cmd.exe, with admin rights)
bcdedit /copy {current} /d "No Hyper-V"
bcdedit /set {<the-code-you-just-received} hypervisorlaunchtype off

# to redefine the root pwd
sudo passwd root

dev-env-windows-aws.txt · Last modified: 2018/09/25 09:21 by jdx