mirror of https://github.com/ansible/ansible.git
Ecs service force new deployment (#47983)
* Support UpdateService forceNewDeployment in ecs_service module * Force update to be called if force_new_deployment set * Fixes for review * Add force_new_deployment option to ecs_service.py cherrypicks changes from via/ansible Adds tests for pull request #42518 fixes backwards compatability with boto<1.8.4 * change version_added to 2.8 for force_new_deployment * remove extra lines from test * remove more unnecessary whitespacepull/49083/head
parent
3143abc8dc
commit
4b2356ff55
@ -0,0 +1,108 @@
|
|||||||
|
- hosts: localhost
|
||||||
|
connection: local
|
||||||
|
vars:
|
||||||
|
resource_prefix: 'ansible-testing-fnd'
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- block:
|
||||||
|
- name: set up aws connection info
|
||||||
|
set_fact:
|
||||||
|
aws_connection_info: &aws_connection_info
|
||||||
|
aws_access_key: "{{ aws_access_key }}"
|
||||||
|
aws_secret_key: "{{ aws_secret_key }}"
|
||||||
|
security_token: "{{ security_token }}"
|
||||||
|
region: "{{ aws_region }}"
|
||||||
|
no_log: True
|
||||||
|
|
||||||
|
- name: create ecs cluster
|
||||||
|
ecs_cluster:
|
||||||
|
name: "{{ resource_prefix }}"
|
||||||
|
state: present
|
||||||
|
<<: *aws_connection_info
|
||||||
|
|
||||||
|
- name: create ecs_taskdefinition
|
||||||
|
ecs_taskdefinition:
|
||||||
|
containers:
|
||||||
|
- name: my_container
|
||||||
|
image: ubuntu
|
||||||
|
memory: 128
|
||||||
|
family: "{{ resource_prefix }}"
|
||||||
|
state: present
|
||||||
|
<<: *aws_connection_info
|
||||||
|
register: ecs_taskdefinition_creation
|
||||||
|
|
||||||
|
- name: create ecs_service
|
||||||
|
ecs_service:
|
||||||
|
name: "{{ resource_prefix }}"
|
||||||
|
cluster: "{{ resource_prefix }}"
|
||||||
|
task_definition: "{{ resource_prefix }}"
|
||||||
|
desired_count: 1
|
||||||
|
state: present
|
||||||
|
<<: *aws_connection_info
|
||||||
|
register: ecs_service_creation
|
||||||
|
|
||||||
|
- name: ecs_service works fine even when older botocore is used
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- ecs_service_creation.changed
|
||||||
|
|
||||||
|
- name: create ecs_service using force_new_deployment
|
||||||
|
ecs_service:
|
||||||
|
name: "{{ resource_prefix }}"
|
||||||
|
cluster: "{{ resource_prefix }}"
|
||||||
|
task_definition: "{{ resource_prefix }}"
|
||||||
|
desired_count: 1
|
||||||
|
force_new_deployment: true
|
||||||
|
state: present
|
||||||
|
<<: *aws_connection_info
|
||||||
|
register: ecs_service_creation_force_new_deploy
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: check that module returns success
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- ecs_service_creation_force_new_deploy.changed
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: scale down ecs service
|
||||||
|
ecs_service:
|
||||||
|
name: "{{ resource_prefix }}"
|
||||||
|
cluster: "{{ resource_prefix }}"
|
||||||
|
task_definition: "{{ resource_prefix }}"
|
||||||
|
desired_count: 0
|
||||||
|
state: present
|
||||||
|
<<: *aws_connection_info
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: pause to wait for scale down
|
||||||
|
pause:
|
||||||
|
seconds: 30
|
||||||
|
|
||||||
|
- name: remove ecs service
|
||||||
|
ecs_service:
|
||||||
|
name: "{{ resource_prefix }}"
|
||||||
|
cluster: "{{ resource_prefix }}"
|
||||||
|
task_definition: "{{ resource_prefix }}"
|
||||||
|
desired_count: 1
|
||||||
|
state: absent
|
||||||
|
<<: *aws_connection_info
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: remove ecs task definition
|
||||||
|
ecs_taskdefinition:
|
||||||
|
containers:
|
||||||
|
- name: my_container
|
||||||
|
image: ubuntu
|
||||||
|
memory: 128
|
||||||
|
family: "{{ resource_prefix }}"
|
||||||
|
revision: "{{ ecs_taskdefinition_creation.taskdefinition.revision }}"
|
||||||
|
state: absent
|
||||||
|
<<: *aws_connection_info
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: remove ecs cluster
|
||||||
|
ecs_cluster:
|
||||||
|
name: "{{ resource_prefix }}"
|
||||||
|
state: absent
|
||||||
|
<<: *aws_connection_info
|
||||||
|
ignore_errors: yes
|
@ -0,0 +1,109 @@
|
|||||||
|
- hosts: localhost
|
||||||
|
connection: local
|
||||||
|
vars:
|
||||||
|
resource_prefix: 'ansible-testing-fndf'
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- block:
|
||||||
|
- name: set up aws connection info
|
||||||
|
set_fact:
|
||||||
|
aws_connection_info: &aws_connection_info
|
||||||
|
aws_access_key: "{{ aws_access_key }}"
|
||||||
|
aws_secret_key: "{{ aws_secret_key }}"
|
||||||
|
security_token: "{{ security_token }}"
|
||||||
|
region: "{{ aws_region }}"
|
||||||
|
no_log: True
|
||||||
|
|
||||||
|
- name: create ecs cluster
|
||||||
|
ecs_cluster:
|
||||||
|
name: "{{ resource_prefix }}"
|
||||||
|
state: present
|
||||||
|
<<: *aws_connection_info
|
||||||
|
|
||||||
|
- name: create ecs_taskdefinition
|
||||||
|
ecs_taskdefinition:
|
||||||
|
containers:
|
||||||
|
- name: my_container
|
||||||
|
image: ubuntu
|
||||||
|
memory: 128
|
||||||
|
family: "{{ resource_prefix }}"
|
||||||
|
state: present
|
||||||
|
<<: *aws_connection_info
|
||||||
|
register: ecs_taskdefinition_creation
|
||||||
|
|
||||||
|
- name: create ecs_service
|
||||||
|
ecs_service:
|
||||||
|
name: "{{ resource_prefix }}"
|
||||||
|
cluster: "{{ resource_prefix }}"
|
||||||
|
task_definition: "{{ resource_prefix }}"
|
||||||
|
desired_count: 1
|
||||||
|
state: present
|
||||||
|
<<: *aws_connection_info
|
||||||
|
register: ecs_service_creation
|
||||||
|
|
||||||
|
- name: ecs_service works fine even when older botocore is used
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- ecs_service_creation.changed
|
||||||
|
|
||||||
|
- name: create ecs_service using force_new_deployment
|
||||||
|
ecs_service:
|
||||||
|
name: "{{ resource_prefix }}"
|
||||||
|
cluster: "{{ resource_prefix }}"
|
||||||
|
task_definition: "{{ resource_prefix }}"
|
||||||
|
desired_count: 1
|
||||||
|
force_new_deployment: true
|
||||||
|
state: present
|
||||||
|
<<: *aws_connection_info
|
||||||
|
register: ecs_service_creation_force_new_deploy
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: check that graceful failure message is returned from ecs_service
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- ecs_service_creation_force_new_deploy.failed
|
||||||
|
- 'ecs_service_creation_force_new_deploy.msg == "botocore needs to be version 1.8.4 or higher to use force_new_deployment"'
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: scale down ecs service
|
||||||
|
ecs_service:
|
||||||
|
name: "{{ resource_prefix }}"
|
||||||
|
cluster: "{{ resource_prefix }}"
|
||||||
|
task_definition: "{{ resource_prefix }}"
|
||||||
|
desired_count: 0
|
||||||
|
state: present
|
||||||
|
<<: *aws_connection_info
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: pause to wait for scale down
|
||||||
|
pause:
|
||||||
|
seconds: 30
|
||||||
|
|
||||||
|
- name: remove ecs service
|
||||||
|
ecs_service:
|
||||||
|
name: "{{ resource_prefix }}"
|
||||||
|
cluster: "{{ resource_prefix }}"
|
||||||
|
task_definition: "{{ resource_prefix }}"
|
||||||
|
desired_count: 1
|
||||||
|
state: absent
|
||||||
|
<<: *aws_connection_info
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: remove ecs task definition
|
||||||
|
ecs_taskdefinition:
|
||||||
|
containers:
|
||||||
|
- name: my_container
|
||||||
|
image: ubuntu
|
||||||
|
memory: 128
|
||||||
|
family: "{{ resource_prefix }}"
|
||||||
|
revision: "{{ ecs_taskdefinition_creation.taskdefinition.revision }}"
|
||||||
|
state: absent
|
||||||
|
<<: *aws_connection_info
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: remove ecs cluster
|
||||||
|
ecs_cluster:
|
||||||
|
name: "{{ resource_prefix }}"
|
||||||
|
state: absent
|
||||||
|
<<: *aws_connection_info
|
||||||
|
ignore_errors: yes
|
Loading…
Reference in New Issue