-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinv.j2
32 lines (28 loc) · 1.26 KB
/
inv.j2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[mongo-cluster:children]
west1
west2
[west1]
{% for item in ec2_info_one.instances %}
{{ item.public_dns_name }} ansible_host={{ lookup('ip', item.public_dns_name) }} ansible_ssh_private_key_file={{ ssh_private_key }} ansible_ssh_user={{ ssh_user }}
{% endfor %}
[west2]
{% for item in ec2_info_two.instances %}
{{ item.public_dns_name }} ansible_host={{ lookup('ip', item.public_dns_name) }} ansible_ssh_private_key_file={{ ssh_private_key }} ansible_ssh_user={{ ssh_user }}
{% endfor %}
[config-servers]
{% for item in ec2_info_one.instances %}
{% if loop.index < 3 %}
{{ item.public_dns_name }} ansible_host={{ lookup('ip', item.public_dns_name) }} ansible_ssh_private_key_file={{ ssh_private_key }} ansible_ssh_user={{ ssh_user }}
{% endif %}
{% endfor %}
{% for item in ec2_info_two.instances %}
{% if loop.index == 1 %}
{{ item.public_dns_name }} ansible_host={{ lookup('ip', item.public_dns_name) }} ansible_ssh_private_key_file={{ ssh_private_key }} ansible_ssh_user={{ ssh_user }}
{% endif %}
{% endfor %}
[mongos-server]
{% for item in ec2_info_one.instances %}
{% if loop.index == 1 %}
{{ item.public_dns_name }} ansible_host={{ lookup('ip', item.public_dns_name) }} ansible_ssh_private_key_file={{ ssh_private_key }} ansible_ssh_user={{ ssh_user }}
{% endif %}
{% endfor %}