radekg / terraform-provisioner-ansible

Ansible with Terraform 0.14.x
Apache License 2.0
572 stars 100 forks source link

support host variables #105

Open sjwl opened 5 years ago

sjwl commented 5 years ago

Playbooks that take advantage of host variables like so

http_port: "{{ default_http_port | default(hostvars[groups['Atlanta'][0]]['http_port']) }}"

would need an inventory that has host variables like so

[atlanta]
host1 http_port=80 maxRequestsPerChild=808
host2 http_port=303 maxRequestsPerChild=909
radekg commented 5 years ago

Hi @sjwl, definitely something to investigate. Thank you for reporting.

rflume-zt commented 5 years ago

My workaround is using a seperate null_resource with the ansible provisioner for each instance I want to provision with Ansible.

That way I can pass specific vars per host through the extra_vars of the ansible provisioner.

radekg commented 5 years ago

I will take a look at this. Ideas are welcomed, though. Maybe there is an alternative, more intuitive may for handling this.