GithubHelp home page GithubHelp logo

mwea / terraform-provider-chef-solo Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 2.0 1.56 MB

License: Mozilla Public License 2.0

Makefile 6.08% Go 68.09% Shell 25.83%
terraform chef-solo chef terraform-provider plugin terraform-provisioner chef-zero

terraform-provider-chef-solo's Introduction

Terraform Chef Solo Provider v 0.1

Terraform ChefSolo Provider is a data-source designed to easily helps you generating node files. It is a basic extension of the data-source "template_file".

This plugin is supposed to be used with the Terraform ChefSolo provisioner

Example of usage :

As an attribute file we use attributes/master.pl :

{
  "ipaddress": "${node_ip}",
  "fqdn": "${node_id}",
  "location": {
    "datacenter": "PAR"
  },
  "network": {
    "setup": {
      "teaming": false
    },
    "restart": false,
    "config": {
      "hosts": ${hosts}
    }
  },
  "vault": {
    "mesos_keytabs": {
      "marathon": {
        "keytab": "SOME8VALUE"
      }
    }
  }
}

As a terraform configuration we can now use this :

data "template_chefsolo" "consul_server" {

  # Generate multiple node files with a count
  count = "${length(var.instances_ips)}"

  # Create automatic attributes for your node files and use a TPL file
  automatic_attributes = "${file("${path.module}/attributes/master.tpl")}"
  
  # Specify your node-id, it is required
  node_id         = "${element(var.instances_hostnames, count.index)}"
  
  # Specify policy names and policy groups / run_list
  # it'll be automatically added in a json file
  policy_name     = "consul_server"
  policy_group    = "local"
  environment     = "preprod"


  # Every variables that are declared here can be accessed in TPL files
  # with the syntax `${name_of_my_var}` 
  vars {
    node_ip     = "${element(var.instances_ips, count.index)}"
    node_id     = "${element(var.instances_hostnames, count.index)}"
    hosts       = "${jsonencode(zipmap(
                        var.instances_ips,
                        var.instances_hostnames)
                    )}"
  }
}

# Output Node files , it'll return an array of Rendered json files
output "node_files" {
    value = "${data.template_chefsolo.consul_server.*.node}"
}

# Output DNA files, it'll return an array of Rendered json files
output "dna_files" {
    value = "${data.template_chefsolo.consul_server.*.dna}"
}

Options

  • default_attributes:

    • Type: String
    • Optional: true
    • Description: "Default attributes of your chef node"
  • automatic_attributes:

    • Type: String
    • Optional: true
    • Description: "Automatic attributes of your chef node"
  • vars:

    • Type: Map
    • Optional: true
    • Default: {}
    • Description: "variables to substitute"
  • node_id:

    • Type: String
    • Required: true
    • Description: "Instance ID of the node"
  • policy_name:

    • Type: String
    • Optional: true
    • Description: "Policy name to use"
    • ConflictsWith: "run_list"
  • policy_group:

    • Type: String
    • Optional: true
    • Default: "local"
    • Description: "Policy group to use"
    • ConflictsWith: "run_list"
  • named_run_list:

    • Type: String
    • Optional: true
    • Default: ""
    • Description: "Optional named run list to target"
    • ConflictsWith: "run_list"
  • run_list:

    • Type: List[String]
    • Optional: true
    • Description: "List of cookbooks to run"
    • ConflictsWith: "named_run_list", "policy_group", "policy_name"
  • environment:

    • Type: String
    • Optional: true
    • Default: "local"
    • Description: "Chef environment"

Output

  • node:

    • Type: String
    • Computed: true
    • Description: "rendered node"
  • dna:

    • Type: String
    • Computed: true
    • Description: "rendered dna"
  • use_policyfile:

    • Type: Bool
    • Computed: true
    • Description: "rendered bool"

terraform-provider-chef-solo's People

Contributors

mwea avatar

Watchers

 avatar  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.