Skip to content

ansible inventory via terraform.py picks up instances from unrelated sibling directories #37

Description

@rudi

Hi, the terraform.py script linked from https://docs.nrec.no/terraform-part4.html#ansible-inventory-from-terraform-state contains the following:

   default_root = os.environ.get('TERRAFORM_STATE_ROOT',
                                  os.path.abspath(os.path.join(os.path.dirname(__file__),
                                                               '..', '..', )))

When following the instructions for linking it as inventory/hosts of the terraform working directory, ansible all -i inventory --list-hosts will also pick up hosts from the .tfstate files of sibling directories of the current directory (since default_root will be the parent directory of the current directory).

As a workaround, one can add the line export TERRAFORM_STATE_ROOT=$(pwd) to keystone_rc.sh.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions