代码之家  ›  专栏  ›  技术社区  ›  L_sama

ansible awx以私有ip作为主机名设置aws ec2清单

  •  0
  • L_sama  · 技术社区  · 3 年前

    我们集中了可解析的awx塔,并使用aws ec2插件来同步主机。因为主机名是aws的私有dns,我们无法从ansible连接(节点在另一个帐户中,但vpc是对等的)。那么,从awx控制台,有没有一种方法可以列出并使用主要私有IP进行连接?(主机具有多个辅助IP)

    我们当前用于筛选主机的库存源变量:

    ---
    keyed_groups:
    <filter-by-tags>
    groups:
      tags
    filters:
      instance-state-name : running
      vpc-id: vpc-xxxxxxx
    

    在我尝试设置的库存源变量中:

    vpc_destination_variable: private_ip_address
    
    0 回复  |  直到 3 年前
        1
  •  0
  •   L_sama    3 年前

    找到解决方案后,需要将以下行添加到源变量中。

    compose:
      # Use the private IP address to connect to the host
      # (note: this does not modify inventory_hostname, which is set via I(hostnames))
      ansible_host: private_ip_address
    

    参考 https://docs.ansible.com/ansible/latest/collections/amazon/aws/aws_ec2_inventory.html

    推荐文章