Answer the question
In order to leave comments, you need to log in
What's wrong with dynamic inventory?
Hello. Internally, the company uses its own hostnames, such as dev-nginx, dev-memcached, etc.
Created a dynamic inventory that returns something like this list:
{
"_meta": {
"hostvars": {
"dev-nginx": {
"ansible_ssh_host": "ip-192-168-1-1.internal.tld",
"ec2_private_dns_name": "ip-192-168-1-1.internal.tld"
},
"dev-memcached": {
"ansible_ssh_host": "ip-192-168-1-2.internal.tld",
"ec2_private_dns_name": "ip-192-168-1-2.internal.tld"
},
}
}
....
"dev-nginx": [
"ip-192-168-1-1.internal.tld"
],
"dev-memcached": [
"ip-192-168-1-2.internal.tld"
],
---
- host: dev-nginx
- name echo memcached
- shell: echo {{ hostvars[groups['dev-memcached']][0]['ansible_fqdn'] }}
fatal: [ip-192-168-1-1.internal.tld] => One or more undefined variables: ansible.runner.HostVars object has no element [u'ip-192-168-1-2.internal.tld']
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question