Skip to content

GROG/terraform-null-ansible-playbook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terraform-null-ansible-playbook

Latest tag Gitter chat

A Terraform module for applying Ansible playbooks.

Usage

# A resource we will configure with ansible
resource "aws_instance" "node" {
    # ...
}

# (Optional) use a module to get your ansible playbook collection
module "my_collection" {
  source = "GROG/ansible-collection/null"
  name   = "my_namespace.my_collection"
}

# Use this module to run a playbook
module "node-ansible-config" {
  source = "GROG/ansible-playbook/null"

  # Use a custom collections path
  collections_path = module.my_collection.collections_path

  # Playbook to run (in this case from the above collection)
  playbook = "my_namespace.my_collection.bootstrap.yml"

  # Target, this can be a comma separated list
  hosts = "${aws_instance.node.public_ip}"

  # Tags to run from the playbook
  tags = ["deploy"]

  # Pass variables to the playbook
  vars = {
    test     = "1,2,3,4"
    list_var = ["one", "two", "three", "four"]

    number = 1234

    complex = {
        key1 = "value1",
        key2 = "value2"
    }

  }
}

Requirements

  • ansible-core-2.11.0 +

Inputs

Variable Description Type Default value
playbook Playbook to run, can be a local file or from a local collection string
hosts Single host or comma separated list on which the roles will be applied string
vars Ansible variables which will be passed with -e map
args Ansible command arguments []string ["-b"]
env Environment variables that are set []string ["ANSIBLE_NOCOWS=true", "ANSIBLE_RETRY_FILES=false", "ANSIBLE_HOST_KEY_CHECKING=false"]
tags Tags to use when creating the resource []string []
skip Tags to skip when creating the resource []string []

Outputs

Variable Description Type
id Resource ID string

Contributing

All assistance, changes or ideas welcome!

Author

By G. Roggemans

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages