Terraform dynamic inventory 0.12.12 (#5298)
* Update parsing of terraform state file for 0.12.12 * Resource does not seem to have a module element but instead has provider * Return the boolean right way if it is already a bool since a bool does not have an lower method * Remove the setting of ansible_ssh_user to root for all Packet Not all servers in packet are accessed as root by default. CoreOS systems use the `core` user. Removing this allows the user to specify the remote user with an extra_var or in an ansible.cfg file. * Default to root user for packet devices except on CoreOS * Update TF_VERSION for packet in tf-validate-packet Update TV_VERSION to 0.12.12 for gitlab-ci tf-validate-packet tests * convert packet terraform files to TV_VERSION 4 * initalize terraform before copying the variable file to the top level dir
This commit is contained in:
committed by
Kubernetes Prow Robot
parent
94d4ce5a6f
commit
108a6297e9
@ -73,7 +73,7 @@ def iterresources(filenames):
|
||||
# In version 4 the structure changes so we need to iterate
|
||||
# each instance inside the resource branch.
|
||||
for resource in state['resources']:
|
||||
name = resource['module'].split('.')[-1]
|
||||
name = resource['provider'].split('.')[-1]
|
||||
for instance in resource['instances']:
|
||||
key = "{}.{}".format(resource['type'], resource['name'])
|
||||
if 'index_key' in instance:
|
||||
@ -182,6 +182,9 @@ def parse_list(source, prefix, sep='.'):
|
||||
|
||||
|
||||
def parse_bool(string_form):
|
||||
if type(string_form) is bool:
|
||||
return string_form
|
||||
|
||||
token = string_form.lower()[0]
|
||||
|
||||
if token == 't':
|
||||
@ -210,7 +213,7 @@ def packet_device(resource, tfvars=None):
|
||||
'state': raw_attrs['state'],
|
||||
# ansible
|
||||
'ansible_ssh_host': raw_attrs['network.0.address'],
|
||||
'ansible_ssh_user': 'root', # it's always "root" on Packet
|
||||
'ansible_ssh_user': 'root', # Use root by default in packet
|
||||
# generic
|
||||
'ipv4_address': raw_attrs['network.0.address'],
|
||||
'public_ipv4': raw_attrs['network.0.address'],
|
||||
@ -220,6 +223,10 @@ def packet_device(resource, tfvars=None):
|
||||
'provider': 'packet',
|
||||
}
|
||||
|
||||
if raw_attrs['operating_system'] == 'coreos_stable':
|
||||
# For CoreOS set the ssh_user to core
|
||||
attrs.update({'ansible_ssh_user': 'core'})
|
||||
|
||||
# add groups based on attrs
|
||||
groups.append('packet_operating_system=' + attrs['operating_system'])
|
||||
groups.append('packet_locked=%s' % attrs['locked'])
|
||||
@ -342,7 +349,7 @@ def iter_host_ips(hosts, ips):
|
||||
use_access_ip = host[1]['metadata']['use_access_ip']
|
||||
if host_id in ips:
|
||||
ip = ips[host_id]
|
||||
|
||||
|
||||
host[1].update({
|
||||
'access_ip_v4': ip,
|
||||
'access_ip': ip,
|
||||
|
Reference in New Issue
Block a user