2018-01-17 01:05:45 +01:00
|
|
|
- name: Create sample container instance
|
|
|
|
azure_rm_containerinstance:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "aci{{ resource_group | hash('md5') | truncate(7, True, '') }}"
|
|
|
|
os_type: linux
|
|
|
|
ip_address: public
|
|
|
|
location: eastus
|
|
|
|
ports:
|
|
|
|
- 80
|
|
|
|
containers:
|
|
|
|
- name: mycontainer1
|
|
|
|
image: httpd
|
|
|
|
memory: 1.5
|
|
|
|
ports:
|
|
|
|
- 80
|
|
|
|
- 81
|
|
|
|
register: output
|
|
|
|
|
2018-05-28 06:59:26 +02:00
|
|
|
- debug:
|
|
|
|
var: output
|
|
|
|
|
2018-01-17 01:05:45 +01:00
|
|
|
- name: Assert the container instance is well created
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
2018-05-28 06:59:26 +02:00
|
|
|
- output.provisioning_state == 'Succeeded'
|
2018-01-17 01:05:45 +01:00
|
|
|
|
2018-05-28 06:59:26 +02:00
|
|
|
- name: Create sample container instance -- same parameters
|
2018-01-17 01:05:45 +01:00
|
|
|
azure_rm_containerinstance:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "aci{{ resource_group | hash('md5') | truncate(7, True, '') }}"
|
|
|
|
os_type: linux
|
|
|
|
ip_address: public
|
|
|
|
location: eastus
|
|
|
|
ports:
|
|
|
|
- 80
|
|
|
|
containers:
|
|
|
|
- name: mycontainer1
|
|
|
|
image: httpd
|
|
|
|
memory: 1.5
|
|
|
|
ports:
|
|
|
|
- 80
|
|
|
|
- 81
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: Assert the container instance is well created
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed == False
|
|
|
|
|
2018-05-28 06:59:26 +02:00
|
|
|
- name: Create sample container instance -- force update
|
2018-01-17 01:05:45 +01:00
|
|
|
azure_rm_containerinstance:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "aci{{ resource_group | hash('md5') | truncate(7, True, '') }}"
|
|
|
|
os_type: linux
|
|
|
|
ip_address: public
|
|
|
|
location: eastus
|
|
|
|
ports:
|
|
|
|
- 80
|
|
|
|
containers:
|
|
|
|
- name: mycontainer1
|
|
|
|
image: httpd
|
|
|
|
memory: 1.5
|
|
|
|
ports:
|
|
|
|
- 80
|
|
|
|
- 81
|
|
|
|
force_update: yes
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: Assert the container instance is well created
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
2018-05-28 06:59:26 +02:00
|
|
|
- output.provisioning_state == 'Succeeded'
|
2018-01-17 01:05:45 +01:00
|
|
|
|
2018-09-03 09:51:42 +02:00
|
|
|
- name: Create second container instance for testing purposes
|
|
|
|
azure_rm_containerinstance:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "aci{{ resource_group | hash('md5') | truncate(7, True, '') }}sec"
|
|
|
|
os_type: linux
|
|
|
|
ip_address: public
|
2019-03-21 10:01:12 +01:00
|
|
|
dns_name_label: mydnslabel{{ resource_group | hash('md5') | truncate(7, True, '') }}
|
2018-09-03 09:51:42 +02:00
|
|
|
location: eastus
|
2019-03-21 10:01:12 +01:00
|
|
|
restart_policy: on_failure
|
2018-09-03 09:51:42 +02:00
|
|
|
ports:
|
|
|
|
- 80
|
|
|
|
containers:
|
|
|
|
- name: mycontainer1
|
|
|
|
image: httpd
|
|
|
|
memory: 1.5
|
|
|
|
ports:
|
|
|
|
- 80
|
|
|
|
- 81
|
2019-03-21 10:01:12 +01:00
|
|
|
commands:
|
|
|
|
- echo abc
|
|
|
|
- echo cdf
|
|
|
|
environment_variables:
|
|
|
|
- name: myvar
|
|
|
|
value: myvarvalue
|
2018-09-03 09:51:42 +02:00
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: Gather facts for single Container Instance
|
|
|
|
azure_rm_containerinstance_facts:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "aci{{ resource_group | hash('md5') | truncate(7, True, '') }}sec"
|
|
|
|
register: output
|
|
|
|
|
2019-03-21 10:01:12 +01:00
|
|
|
- debug:
|
|
|
|
var: output
|
|
|
|
|
2018-09-03 09:51:42 +02:00
|
|
|
- name: Assert that facts are returned
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed == False
|
|
|
|
- output.containerinstances[0]['resource_group'] != None
|
|
|
|
- output.containerinstances[0]['name'] != None
|
|
|
|
- output.containerinstances[0]['os_type'] != None
|
|
|
|
- output.containerinstances[0]['location'] != None
|
|
|
|
- output.containerinstances[0]['ip_address'] != None
|
|
|
|
- output.containerinstances[0]['ports'] != None
|
|
|
|
- output.containerinstances[0]['containers'] != None
|
2019-03-21 10:01:12 +01:00
|
|
|
- output.containerinstances[0]['containers'][0]['commands'] | length == 2
|
|
|
|
- output.containerinstances[0]['containers'][0]['environment_variables'] | length == 1
|
|
|
|
- output.containerinstances[0]['restart_policy'] == 'on_failure'
|
2018-09-03 09:51:42 +02:00
|
|
|
|
|
|
|
- name: Gather facts for all Container Instances in the resource group
|
|
|
|
azure_rm_containerinstance_facts:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: Assert that facts are returned
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed == False
|
|
|
|
- output.containerinstances[0]['resource_group'] != None
|
|
|
|
- output.containerinstances[0]['name'] != None
|
|
|
|
- output.containerinstances[0]['os_type'] != None
|
|
|
|
- output.containerinstances[0]['location'] != None
|
|
|
|
- output.containerinstances[0]['ip_address'] != None
|
|
|
|
- output.containerinstances[0]['ports'] != None
|
|
|
|
- output.containerinstances[0]['containers'] != None
|
|
|
|
- output.containerinstances[1]['resource_group'] != None
|
|
|
|
- output.containerinstances[1]['name'] != None
|
|
|
|
- output.containerinstances[1]['os_type'] != None
|
|
|
|
- output.containerinstances[1]['location'] != None
|
|
|
|
- output.containerinstances[1]['ip_address'] != None
|
|
|
|
- output.containerinstances[1]['ports'] != None
|
|
|
|
- output.containerinstances[1]['containers'] != None
|
|
|
|
|
2018-01-17 01:05:45 +01:00
|
|
|
- name: Remove container instance
|
|
|
|
azure_rm_containerinstance:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "aci{{ resource_group | hash('md5') | truncate(7, True, '') }}"
|
|
|
|
os_type: linux
|
|
|
|
ip_address: public
|
|
|
|
location: eastus
|
|
|
|
ports:
|
|
|
|
- 80
|
|
|
|
containers:
|
|
|
|
- name: mycontainer1
|
|
|
|
image: httpd
|
|
|
|
memory: 1.5
|
|
|
|
ports:
|
|
|
|
- 80
|
|
|
|
- 81
|
|
|
|
state: absent
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: Assert the container instance is deleted
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
|
|
|
|
2018-09-03 09:51:42 +02:00
|
|
|
- name: Remove container instance
|
|
|
|
azure_rm_containerinstance:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "aci{{ resource_group | hash('md5') | truncate(7, True, '') }}sec"
|
|
|
|
os_type: linux
|
|
|
|
ip_address: public
|
|
|
|
location: eastus
|
|
|
|
ports:
|
|
|
|
- 80
|
|
|
|
containers:
|
|
|
|
- name: mycontainer1
|
|
|
|
image: httpd
|
|
|
|
memory: 1.5
|
|
|
|
ports:
|
|
|
|
- 80
|
|
|
|
- 81
|
|
|
|
state: absent
|
|
|
|
|
2018-01-17 01:05:45 +01:00
|
|
|
- name: Remove container instance again
|
|
|
|
azure_rm_containerinstance:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "aci{{ resource_group | hash('md5') | truncate(7, True, '') }}"
|
|
|
|
os_type: linux
|
|
|
|
ip_address: public
|
|
|
|
location: eastus
|
|
|
|
ports:
|
|
|
|
- 80
|
|
|
|
containers:
|
|
|
|
- name: mycontainer1
|
|
|
|
image: httpd
|
|
|
|
memory: 1.5
|
|
|
|
ports:
|
|
|
|
- 80
|
|
|
|
- 81
|
|
|
|
state: absent
|
|
|
|
register: output
|
|
|
|
|
|
|
|
- name: Assert the changed is false
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed == False
|