Last active
March 18, 2022 03:03
-
-
Save hostmaster/073e2ad2b78617a2ef63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dict key tranformation table | |
_ssh_to_ansible = { | |
'user': 'ansible_ssh_user', | |
'hostname': 'ansible_ssh_host', | |
'identityfile': 'ansible_ssh_private_key_file', | |
'port': 'ansible_ssh_port' | |
} | |
# host_config = config.lookup(box_name) # dict | |
temp = {} | |
for k in _ssh_to_ansible: | |
temp[_ssh_to_ansible[k]] = host_config[k] | |
@jtsoi Thanks.
Missing the context. Both of your solutions does the job. If you're after minimal code, there's also dict comprehension:
temp = {k: host_config[k] for k, v in _ssh_to_ansible.items()}
@vs-ab thank it is exactly what i am looking for
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@hostmaster that looks pretty minimal to me.
You could:
Other than that, no ideas.