terraform-null-ansible icon indicating copy to clipboard operation
terraform-null-ansible copied to clipboard

How to specify hosts file?

Open mabushey opened this issue 6 years ago • 2 comments

  • module.ansible_provisioner.null_resource.provisioner: Error running command 'ansible-playbook --user=ubuntu -e host=54.219.165.55 interview_devops_playbook.yml': exit status 4. Output: [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

there is no inventory file being passed.... :( How can I specify the hosts file? I would like -i ./hosts added to the command string. Terraform is awesome, but when the code is in a module it gets cached and becomes difficult to modify.

mabushey avatar Jun 07 '18 21:06 mabushey

I guess it's dynamic and does not write to an inventory file. The raw install python is not idempotent so I figured it just wasn't working.

  • In the raw command, the changed does not work. Use this:
register: output
changed_when: output.stdout != ""
  • Inventory is spelled wrong: Create a runtime inventorty with an ip address of a host
  • Github is now owned by a patent troll, consider migrating to a service like Gitlab.

mabushey avatar Jun 07 '18 23:06 mabushey

You should also create a group_vars/all file so people can specify the correct pem to use:

$ cat group_vars/all                                                                                                                                                                                                                             
ansible_ssh_private_key_file: ~/.ssh/my_key

mabushey avatar Jun 07 '18 23:06 mabushey