Category Archives: Automation

Vagrant for DevOps: Boxes

Boxes can be obtained from Atlas repos , from whatever other repos or created by ourselves with Packer or manually.
Please pay attention that almost all boxes are OK with VirtualBox , but only some can be used with other providers like Parallels, Hyper-V, AWS, etc.
Boxes are stored separately from VMs, in ~/.vagrant.d and during VM deploy process box is cloned to hypervisor default location.

Continue reading

Vagrant for DevOps: Vagrantfile

Vagrantfile is used to deploy the whole infrastructure from scratch on any machine running Vagrant.
Vagrantfile describes environment configuration – stuff like VMs, shares, networking, etc.
Vagrantfile should be stored in VCS, such as Git – we’ll be able to share environment configurations within the team and switch between different environment versions.

Vagrantfile should be stored in the project directory, but if it’s not found there, vagrant will search for it in all dirs from project to / :

Screen Shot 2016-05-25 at 17.02.05
And for security reasons you might want to store Vagrantfiles in a private dir, in this case use environment variable VAGRANT_CWD to specify a path.
If you have a few Vagrantfiles, vagrant will automatically merge them, but it’s not really common practice.

We can generate simple vagrant file with vagrant init command, but we’ll construct our own configuration which would be a bit more complex.
Vagrantfiles are ruby-based, so it’s really easy to have a deal with syntax.

Continue reading

Vagrant for DevOps


With Vagrant we can build and share reproducible and predictable environments using environment-as-code principles.
Vagrant can deploy both on-premise environments based on VirtualBox, VMware, Hyper-V, Parallels and cloud, such as DigitalOcean, Azure and AWS.
I prefer to use tools like CloudFormation to build cloud environments, so I’ll focus on on-premise in this post.

Vagrant can also work with Docker, but now we have native Docker not only on Linux, but also on Windows and OS X, so Vagrant can be used only for complex or legacy Docker scenarios.

Typically Vagrant is used to deploy infrastructure (servers) and Chef, Puppet or Ansible are used to deploy software to those servers.
You can find a full list of providers, provisioners and all other stuff here –

Continue reading

Download and restore MS SQL database backup

databaseSchedulingIconIn this post I’ll show an example of simple automation task – we need to download 7z archive from SFTP, unzip it and restore the newest database automatically on a daily basics.

If we go bit deeper we’ll see a few more requirements:

  1. SFTP requires auth;
  2. 7z file is protected with password;
  3. We need to test every important step;
  4. We need to add permissions to a database;
  5. We can shrink transaction log to save some space;
  6. We we need to log every important step to EventLog;
  7. We want to get a nice report with time measures;

It’s clear now, so let’s get down to prerequisites.

Continue reading

Azure VMs turn off & on by schedule

save-timeIn this post I’ll show how to setup Azure VMs turn off & on by schedule using Azure Automation which is really useful for cost saving.

We’ll use dozen of actions to manage this task.

However, not all actions can be managed with PowerShell, so we’ll use old Azure portal a few times.

Initially I used one big script, but for this demo I decided to split it to make things simple.

In this particular example I’ll use two VMs running in the same cloud service.

Continue reading