Meet Sparrowform
Sparrowform is a tool to provision Terraform instances by running Sparrowdo scenarios. You bootstrap infrastructure by Terraform script and then let Sparrowdo to adjust instances by running configuration tasks against. Here is simple plan how to do this:
Bootstrap infrastructure with Terraform
Say, we have tree aws ec2 instances with corresponding Terraform resources names - example1
, example2
and example3
. We create instances by a related Terraform scenario bootstrap.tf
:
$ nano bootstrap.tf
$ terraform apply
Create some Sparrowdo scenarios:
Now, as we get three ec2 instances up and running, we want to apply some desired configuration to all of them, let's create three Sparrowdo scenarios, one per each instance to describe desired configuration. We should name scenarios files as $terraform-resource-type.$resource-name.sparrowfile
.
For simplicity, all we want is to install Nginx server on every ec2 instance, the scenario would be trivial:
$ nano aws_instance.example1.sparrowfile
#!perl6
package-install "nginx";
service-enable "nginx";
service-start "nginx";
$ nano aws_instance.example1.sparrowfile # so on, for other two instances
Run provision by Sparrowform/Sparrowdo
Now, as we are ready with our Sparrowdo scenarios, let's run them on our freshly Terraform backed instances. We add --ssh_private_key
, --ssh_user
parameters to Sparrowform launcher so that Sparrowdo knows how to connect to the instances by ssh:
$ sparrowform --bootstrap --ssh_private_key=~/.ssh/aws.pub --ssh_user=ec2-user
What else?
Look at Sparrowform to know more. Last nifty example to make you animated:
# We can avoid creating Sparrowdo scenarios, using Sparrowdo modules as
# This one liner.
# Let's install Nginx server on all instances:
$ zef install Sparrowdo::Nginx
$ sparrowform --ssh_private_key=~/.ssh/aws.pub --ssh_user=ec2-user --module_run=Nginx