Skip to content

Commit 8573276

Browse files
committed
Fix inventory file format for variables.
1 parent 77f7402 commit 8573276

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

cloudlab/commandline.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,14 @@ def mkenv(envdir, update, template, provision):
210210
logging.info('Cloud formation stack created.')
211211

212212
# build the inventory
213-
inventory = {'ansible_ssh_private_key_file': keyfile_name }
213+
inventory = {
214+
"all": {
215+
"vars": {
216+
"ansible_ssh_private_key_file": envname + ".pem"
217+
}
218+
}
219+
}
220+
214221
for subnet in config['subnets']:
215222
for group in subnet['servers']:
216223
role = group['role']
@@ -221,10 +228,15 @@ def mkenv(envdir, update, template, provision):
221228
private_ip = attributes[1]
222229
# dns_name = attributes[2]
223230

224-
inv_role = inventory.setdefault(role, {'hosts': {}})
231+
inv_role = inventory.setdefault(role, {
232+
'vars': {
233+
'ansible_user': config['roles'][role]['ssh_user']
234+
},
235+
'hosts': {}
236+
})
237+
225238
inv_role['hosts'][public_ip] = {
226-
'private_ip': private_ip,
227-
'ansible_user': config['roles'][role]['ssh_user']
239+
'private_ip': private_ip
228240
}
229241

230242
invfile = os.path.join(envdir, 'inventory.yaml')

0 commit comments

Comments
 (0)