我有兩個不同的實例具有相同專用地址的VPC。Ansible在動態庫存中返回錯誤的主機(私有IP衝突?)
CI-VPC:
172.18.50.180:
tags:
Environment: ci
Role: aRole
測試VPC:
172.18.50.180:
tags:
Environment: test
Role: web
我運行以下劇本:
- name: "print account specific variables"
hosts: "tag_Environment_ci:&tag_Role_web"
tasks:
- name: "print account specific variables for account {{ account }}"
debug:
msg:
- 'ec2_tag_Name': "{{ ec2_tag_Name }}"
'ec2_tag_Role': "{{ ec2_tag_Role }}"
'ec2_private_ip_address': "{{ ec2_private_ip_address }}"
'ec2_tag_Environment': "{{ ec2_tag_Environment }}"
因爲我要求都角色網絡和環境ci,no這些實例的NE應採摘,但儘管如此,我得到的結果是:
ok: [172.18.50.180] => {
"changed": false,
"msg": [
{
"ec2_private_ip_address": "172.18.50.180",
"ec2_tag_Environment": "test",
"ec2_tag_Name": "test-web-1",
"ec2_tag_Role": "web"
}
]
}
顯然,這種情況下不符合hosts
下要求...
好像關注Environment
ec2.py
標籤,發現ci爲172.18.50.180,然後單獨搜索角色標籤,在172.18.50.180下找到另一個,並將該實例標記爲ok,即使這些是兩個不同vpcs上的不同實例。
我試圖在ec2.ini
改變vpc_destination_variable
到id
但後來我發現了,當Ansible試圖連接到這些情況,因爲它不能連接到ID差錯......
fatal: [i-XXX]: UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname i-XXX: Name or service not known\r\n", "unreachable": true
}
是否有另選項,將在vpc_destination_variable
下工作?這種碰撞的任何已知解決方案?