Giter VIP home page Giter VIP logo

terraform-null-ansible-collection's Introduction

terraform-null-ansible-collection

Latest tag Gitter chat

A Terraform module for installing Ansible collections.

It uses a hash of the collection source to install the collection and it's dependencies in an isolated folder. Allowing you to easily combine different versions for different parts of the infrastructure.

It provides an output that can be used to pass the custom collections path to Ansible

Usage

# Installing a collection from galaxy
module "mynamespace_mycollection_example1" {
  source = "GROG/ansible-collection/null"
  name   = "my_namespace.my_collection"
}

# Adding version info (recommended)
module "mynamespace_mycollection_example2" {
  source = "GROG/ansible-collection/null"
  name   = "my_namespace.my_collection:>=1.0.0,<2.0.0"
}

# You can also use git urls or local files
module "my_collection" {
  source = "GROG/ansible-collection/null"
  name   = "https://github.com/my/ansible-collection"
}

# Some other resource using the collections path
resource "null_resource" "run_ansible" {
  provisioner "local-exec" {
    command = "ANSIBLE_COLLECTIONS_PATHS=${module.my_collection.collections_path} ansible-playbook my_collection.playbook"
  }
}

Requirements

  • ansible-core-2.11.0 +

Inputs

Variable Description Type Default value
name Name or source of the collection to install, can include version info string /

Outputs

Variable Description Type
id Resource ID string

Contributing

All assistance, changes or ideas welcome!

Author

By G. Roggemans

License

MIT

terraform-null-ansible-collection's People

Contributors

groggemans avatar

Watchers

 avatar

terraform-null-ansible-collection's Issues

Checkout from a private repo

My collection is in a GitLab private repo and I attempted to use the url form, like so:

module "nats_default" {
  source = "GROG/ansible-collection/null"
  name   = "https://user:pass@my_gitlab.com/ansible/collections/nats-default.git"
}

But I received this error:

╷
│ Error: Plugin did not respond
│
│   with ansible_playbook.playbook,
│   on main.tf line 103, in resource "ansible_playbook" "playbook":
│  103: resource "ansible_playbook" "playbook" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.
╵
╷
│ Error: local-exec provisioner error
│
│   with module.nats_default.null_resource.collection,
│   on .terraform/modules/nats_default/main.tf line 27, in resource "null_resource" "collection":
│   27:   provisioner "local-exec" {
│
│ Error running command 'ansible-galaxy collection install -p /home/mfaine/development/terraform/gitlab/.ansible/collections/5808f704ad23abcb1e03c0dfdb63d328e3c2115f
│ https://user:[email protected]/ansible/collections/nats-default.git': exit status 1. Output: Downloading
│ https://user:[email protected]/ansible/collections/nats-default.git to
│ /home/mfaine/.ansible/tmp/ansible-local-86944r2oive7j/tmpnnl4ocoj/nats-defa-fx50vrv1
│ ERROR! Collection artifact at '/home/mfaine/.ansible/tmp/ansible-local-86944r2oive7j/tmpnnl4ocoj/nats-defa-fx50vrv1/nats-default.git' is not a valid tar file.

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.