question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get ansible_ resources from multiple Remote state

See original GitHub issue

Having terraform configuration in different directories/account for secuirity/sepration o duty or something else, can be useful terraform inventory allow to read states from other directories out of the main as current or defined by ANSIBLE_TF_DIR.

E.g. gathering ansible configuration from multimple remote state (multiple directoies in ANSIBLE_TF_DIR), to work like multiple terraform_remote_state in terraform:

data "terraform_remote_state" "dir1" {...}
data "terraform_remote_state" "dir2" {...}
...
data "terraform_remote_state" "dirn" {...}

Every directory will have its backend with aws connection config ti allow this design, probably.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Roxyrobcommented, Dec 8, 2020

I think It is the same. Before you can pull terraform state, you need to know where the state is and how to have access to it. If not on local disk backend.tf (for any remote state configuration) is what allow your script to pull state.

I’ll give a try to multiple inventory “as scripts” using different env var.

I want to thank you for this dynamic inventory script and the terraform ansible provider (a great solution).

0reactions
nberingcommented, Dec 7, 2020

I think the script read backend.tf to get tfstate with ansible_ configuration right?

To clarify this point… no the script does not try to parse any Terraform files. It calls terraform state pull and reads STDOUT to get the state as JSON, letting Terraform figure out where to get the state data from. That way, we can support all remote state providers with zero work from the inventory script.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Manage Multiple Servers with Ansible Ad Hoc ...
With Ansible, you can use ad hoc commands to execute one instruction at a time on one or more remote servers. They are...
Read more >
Basic Concepts - Ansible Documentation
A list of managed nodes provided by one or more 'inventory sources'. Your inventory can specify information specific to each node, like IP...
Read more >
Ansible Network Examples
Using multiple prompts with the ansible.netcommon.cli_command ... Ansible treats the remote node as a network device with a limited execution environment.
Read more >
Getting started with Ansible
Ansible automates the management of remote systems and controls their desired state. A basic Ansible environment has three main components: Control node. A ......
Read more >
Ansible playbooks
Ansible Playbooks offer a repeatable, re-usable, simple configuration management and multi-machine deployment system, one that is well suited to deploying ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found