我正在尝试使用ansible删除ecs服务:
- name: Delete the Service
ecs_service:
name: "{{ service_name }}"
cluster: "{{ cluster_name }}"
state: absent
失败了:
An error occurred (InvalidParameterException) when calling the DeleteService operation: The service cannot be stopped while the primary deployment is scaled above 0.
因此,解决方案是在删除服务之前将“desired_count”设置为0。但是我该如何做到这一点? 或者,在ansible中删除正在运行的ecs服务的正确方法是什么?
答案 0 :(得分:2)
我遇到了同样的问题并想出了如何避免这个问题。 正如您已经想到的那样:“所需计数”值必须设置为“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
我很抱歉我的降价技巧很差。但我希望这会有所帮助。
答案 1 :(得分:0)
您必须执行以下更改:ecs_service:name:test-sample-app-service operation:delete cluster:test-sample-app-cluster