我正在研究shell脚本,女巫确实遵循:
1)我使用follow命令创建快照:
SNAPSHOT_ID=$(aws ec2 create-snapshot "${DRYRUN}" --volume-id "${ROOT_VOLUME_ID}" --description "${SNAPSHOT_DESCRIPTION}" --query 'SnapshotId')
2)我使用服务员等待完成状态:
aws ec2 wait snapshot-completed --snapshot-ids "${SNAPSHOT_ID}"
当我使用EBS Volume 8 GB大小进行测试时,一切顺利.
当它是40 GB时,我有一个例外:
Waiter SnapshotCompleted failed: Max attempts exceeded
也许,40 GB需要更多时间,然后需要8 GB,只需要等待.
AWS Docs(http://docs.aws.amazon.com/cli/latest/reference/ec2/wait/snapshot-completed.html)没有任何超时或尝试数量选项.
可能有些人遇到过同样的问题?
使用Ansible安装ntp,我通知处理程序以启动ntpd服务:
任务:
---
# roles/common/tasks/ntp.yml
- name: ntp | installing
yum: name=ntp state=latest
notify: start ntp
Run Code Online (Sandbox Code Playgroud)
处理器:
---
# roles/common/handlers/main.yml
- name: start ntp
service: name=ntpd state=started
Run Code Online (Sandbox Code Playgroud)
如果尚未安装服务,则安装并启动它.
如果服务已经安装但未运行,则它不会通知处理程序:
任务的状态是changed: false
这意味着,如果已经在操作系统中显示,则无法启动它.
有没有什么好的做法可以帮助确保服务已经安装并且处于运行状态?
PS:我可以这样做:
---
# roles/common/tasks/ntp.yml
- name: ntp | installing
yum: name=ntp state=latest
notify: start ntp
changed: true
Run Code Online (Sandbox Code Playgroud)
但我不确定这是好的做法.