我正在尝试使用 ansible 删除 ecs 服务:
- name: Delete the Service
ecs_service:
name: "{{ service_name }}"
cluster: "{{ cluster_name }}"
state: absent
Run Code Online (Sandbox Code Playgroud)
它失败了:
An error occurred (InvalidParameterException) when calling the DeleteService operation: The service cannot be stopped while the primary deployment is scaled above 0.
Run Code Online (Sandbox Code Playgroud)
因此,解决方案是在删除服务之前将“desired_count”设置为 0。但是我该怎么做呢?或者,在ansible中删除正在运行的ecs服务的正确方法是什么?
我遇到了同样的问题并想出了如何避免这个问题。正如您已经想到的:“所需计数”值必须设置为“0”。
不幸的是,在 Ansible 中,您只能通过两步方法来完成此操作,如下所示:
---
- hosts: localhost
connection: local
gather_facts: False`
tasks:
#update the service as you would do in console or cli,
# so that desired count is set to 0
- ecs_service:
name: jenkins-service
state: present
cluster: jenkins-cluster
desired_count: 0
task_definition: jenkins-task
#now you're able to delete the service definition.
- ecs_service:
name: jenkins-service
state: absent
cluster: jenkins-cluster
Run Code Online (Sandbox Code Playgroud)
我为我糟糕的 Markdown 技能感到抱歉。但我希望这会有所帮助。
| 归档时间: |
|
| 查看次数: |
1813 次 |
| 最近记录: |