ansible playbook有一个ec2模块是专门给亚马逊云主机写的,因为云主机也频繁涉及停止,启动等相关的操作,
- name: Stop the node
local_action:
module: ec2
instance_ids: '{{ instance_id }}'
region: '{{ instance_region }}'
state: stopped
wait: True
其中,instance_id 是实例的id
instance_type 实例所属region
这两个都可以通过Dynamic Inventory 来获取到(http://docs.ansible.com/intro_dynamic_inventory.html)
需要注意的是wait选项,True是等待这个命令完成,即实例的状态为stopped
- name: Start the instance
local_action:
module: ec2
instance_ids: '{{ instance_id }}'
region: '{{ instance_region }}'
state: running
wait: True
register: running
启动同上
欢迎转载,转载请注明出处:http://www.503error.com/
Latest posts by Zhiming Zhang (see all)
- aws eks node 自动化扩展工具 Karpenter - 8月 10, 2022
- ReplicationController and ReplicaSet in Kubernetes - 12月 20, 2021
- public key fingerprint - 5月 27, 2021