Code Monkey home page Code Monkey logo

terraform-provisioner-ansible's Introduction

terraform-provisioner-ansible

Provision terraform resources with ansible

Overview

Terraform is a tool for automating infrastructure. Terraform includes the ability to provision resources at creation time through a plugin api. Currently, some builtin provisioners such as chef and standard scripts are provided; this provisioner introduces the ability to provision an instance at creation time with ansible.

This provisioner provides the ability to apply host-groups, plays or roles against a host at provision time. Ansible is run on the host itself and this provisioner configures a dynamic inventory on the fly as resources are created.

terraform-provisioner-ansible is shipped as a Terraform module. To include it, simply download the binary and enable it as a terraform module in your terraformrc.

Installation

terraform-provisioner-ansible ships as a single binary and is compatible with terraform's plugin interface. Behind the scenes, terraform plugins use https://github.com/hashicorp/go-plugin and communicate with the parent terraform process via RPC.

To install, download and un-archive the binary and place it on your path.

$ https://github.com/jonmorehouse/terraform-provisioner-ansible/releases/download/0.0.1-terraform-provisioner-ansible.tar.gz

$ tar -xvf 0.0.1-terraform-provisioner-ansible.tar.gz /usr/local/bin

Once installed, a ~/.terraformrc file is used to enable the plugin.

providers {
    ansible = "/usr/local/bin/terraform-provisioner-ansible"
}

Usage

Once installed, you can provision resources by including an ansible provisioner block.

The following example demonstrates a configuration block to apply a host group's plays to new instances. You can specify a list of hostgroups and a list of plays to specify which ansible tasks to perform on the host.

Additionally, groups and extra_vars are accessible to resolve variables and group the new host in ansible.

{
  resource "aws_instance" "terraform-provisioner-ansible-example" {
    ami = "ami-408c7f28"
    instance_type = "t1.micro"

    provisioner "ansible" {
      connection {
        user = "ubuntu"
      }

      playbook = "ansible/playbook.yml"
      groups = ["all"]
      hosts = ["terraform"]
      extra_vars = {
        "env": "terraform"  
      }
    }
  }
}

Check out example for a more detailed walkthrough of the provisioner and how to provision resources with ansible.

terraform-provisioner-ansible's People

Contributors

joaocc avatar jonmorehouse avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.