我正在尝试在组下的文件中列出stop/start
的特定group
实例.以下playbook可以正常停止实例.hosts
[target]
--- - hosts: target remote_user: ubuntu tasks: - name: Gather facts action: ec2_facts - name: Stop Instances local_action: module: ec2 region: "{{region}}" instance_ids: "{{ansible_ec2_instance_id}}" state: stopped
但是当我试图启动这些实例时,它不起作用,因为ec2_facts
它无法ssh
进入实例(因为它们现在被停止)并获得instance-ids
--- - hosts: target remote_user: ubuntu tasks: - name: start instances local_action: module: ec2 region: "{{region}}" instance_ids: "{{ansible_ec2_instance_id}}" state: running
我已经看过使用dynamic inventory
主机文件的文档和硬编码的方法instance-ids
.我想启动文件组IPs
中列出的实例.target
hosts