2018-10-26 02:51:41 +02:00
|
|
|
---
|
|
|
|
- name: Registering volume name
|
|
|
|
set_fact:
|
|
|
|
vname: "{{ name_prefix ~ '-basic' }}"
|
|
|
|
- name: Registering container name
|
|
|
|
set_fact:
|
|
|
|
vnames: "{{ vnames }} + [vname]"
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## basic ###########################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: Create a volume
|
|
|
|
docker_volume:
|
|
|
|
name: "{{ vname }}"
|
|
|
|
register: create_1
|
|
|
|
|
|
|
|
- name: Create a volume (idempotency)
|
|
|
|
docker_volume:
|
|
|
|
name: "{{ vname }}"
|
|
|
|
register: create_2
|
|
|
|
|
2019-02-03 21:09:24 +01:00
|
|
|
- name: "Create a volume (recreate: options-changed)"
|
2018-10-26 02:51:41 +02:00
|
|
|
docker_volume:
|
|
|
|
name: "{{ vname }}"
|
2019-02-03 21:09:24 +01:00
|
|
|
recreate: options-changed
|
2018-10-26 02:51:41 +02:00
|
|
|
register: create_3
|
|
|
|
|
2019-02-03 21:09:24 +01:00
|
|
|
- name: "Create a volume (recreate: always)"
|
|
|
|
docker_volume:
|
|
|
|
name: "{{ vname }}"
|
|
|
|
recreate: always
|
|
|
|
register: create_4
|
|
|
|
|
2018-10-26 02:51:41 +02:00
|
|
|
- name: Remove a volume
|
|
|
|
docker_volume:
|
|
|
|
name: "{{ vname }}"
|
|
|
|
state: absent
|
|
|
|
register: absent_1
|
|
|
|
|
|
|
|
- name: Remove a volume (idempotency)
|
|
|
|
docker_volume:
|
|
|
|
name: "{{ vname }}"
|
|
|
|
state: absent
|
|
|
|
register: absent_2
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- create_1 is changed
|
|
|
|
- create_2 is not changed
|
2019-01-11 21:41:37 +01:00
|
|
|
- create_3 is not changed
|
2019-02-03 21:09:24 +01:00
|
|
|
- create_4 is changed
|
2018-10-26 02:51:41 +02:00
|
|
|
- absent_1 is changed
|
|
|
|
- absent_2 is not changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## driver_options ##################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: Create a volume with options
|
|
|
|
docker_volume:
|
|
|
|
name: "{{ vname }}"
|
|
|
|
driver: local
|
|
|
|
driver_options:
|
|
|
|
type: tempfs
|
|
|
|
device: tmpfs
|
|
|
|
o: size=100m,uid=1000
|
|
|
|
register: driver_options_1
|
|
|
|
|
|
|
|
- name: Create a volume with options (idempotency)
|
|
|
|
docker_volume:
|
|
|
|
name: "{{ vname }}"
|
|
|
|
driver: local
|
|
|
|
driver_options:
|
|
|
|
type: tempfs
|
|
|
|
device: tmpfs
|
|
|
|
o: size=100m,uid=1000
|
|
|
|
register: driver_options_2
|
|
|
|
|
|
|
|
- name: Create a volume with options (changed)
|
|
|
|
docker_volume:
|
|
|
|
name: "{{ vname }}"
|
|
|
|
driver: local
|
|
|
|
driver_options:
|
|
|
|
type: tempfs
|
|
|
|
device: tmpfs
|
|
|
|
o: size=200m,uid=1000
|
|
|
|
register: driver_options_3
|
|
|
|
|
2019-02-03 21:09:24 +01:00
|
|
|
- name: "Create a volume with options (changed, recreate: options-changed)"
|
2019-01-11 21:41:37 +01:00
|
|
|
docker_volume:
|
|
|
|
name: "{{ vname }}"
|
|
|
|
driver: local
|
|
|
|
driver_options:
|
|
|
|
type: tempfs
|
|
|
|
device: tmpfs
|
|
|
|
o: size=200m,uid=1000
|
2019-02-03 21:09:24 +01:00
|
|
|
recreate: options-changed
|
2019-01-11 21:41:37 +01:00
|
|
|
register: driver_options_4
|
|
|
|
|
2018-10-26 02:51:41 +02:00
|
|
|
- name: Cleanup
|
|
|
|
docker_volume:
|
|
|
|
name: "{{ vname }}"
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- driver_options_1 is changed
|
|
|
|
- driver_options_2 is not changed
|
2019-01-11 21:41:37 +01:00
|
|
|
- driver_options_3 is not changed
|
|
|
|
- driver_options_4 is changed
|
2018-11-12 12:24:07 +01:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## labels ##########################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: Create a volume with labels
|
|
|
|
docker_volume:
|
|
|
|
name: "{{ vname }}"
|
|
|
|
labels:
|
|
|
|
ansible.test.1: hello
|
|
|
|
ansible.test.2: world
|
|
|
|
register: driver_labels_1
|
|
|
|
|
|
|
|
- name: Create a volume with labels (idempotency)
|
|
|
|
docker_volume:
|
|
|
|
name: "{{ vname }}"
|
|
|
|
labels:
|
|
|
|
ansible.test.2: world
|
|
|
|
ansible.test.1: hello
|
|
|
|
register: driver_labels_2
|
|
|
|
|
|
|
|
- name: Create a volume with labels (less)
|
|
|
|
docker_volume:
|
|
|
|
name: "{{ vname }}"
|
|
|
|
labels:
|
|
|
|
ansible.test.1: hello
|
|
|
|
register: driver_labels_3
|
|
|
|
|
2019-02-03 21:09:24 +01:00
|
|
|
- name: "Create a volume with labels (less, recreate: options-changed)"
|
2019-01-11 21:41:37 +01:00
|
|
|
docker_volume:
|
|
|
|
name: "{{ vname }}"
|
|
|
|
labels:
|
|
|
|
ansible.test.1: hello
|
2019-02-03 21:09:24 +01:00
|
|
|
recreate: options-changed
|
2019-01-11 21:41:37 +01:00
|
|
|
register: driver_labels_4
|
|
|
|
|
2018-11-12 12:24:07 +01:00
|
|
|
- name: Create a volume with labels (more)
|
|
|
|
docker_volume:
|
|
|
|
name: "{{ vname }}"
|
|
|
|
labels:
|
|
|
|
ansible.test.1: hello
|
|
|
|
ansible.test.3: ansible
|
2019-01-11 21:41:37 +01:00
|
|
|
register: driver_labels_5
|
|
|
|
|
2019-02-03 21:09:24 +01:00
|
|
|
- name: "Create a volume with labels (more, recreate: options-changed)"
|
2019-01-11 21:41:37 +01:00
|
|
|
docker_volume:
|
|
|
|
name: "{{ vname }}"
|
|
|
|
labels:
|
|
|
|
ansible.test.1: hello
|
|
|
|
ansible.test.3: ansible
|
2019-02-03 21:09:24 +01:00
|
|
|
recreate: options-changed
|
2019-01-11 21:41:37 +01:00
|
|
|
register: driver_labels_6
|
2018-11-12 12:24:07 +01:00
|
|
|
|
|
|
|
- name: Cleanup
|
|
|
|
docker_volume:
|
|
|
|
name: "{{ vname }}"
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- driver_labels_1 is changed
|
|
|
|
- driver_labels_2 is not changed
|
|
|
|
- driver_labels_3 is not changed
|
2019-01-11 21:41:37 +01:00
|
|
|
- driver_labels_4 is not changed
|
|
|
|
- driver_labels_5 is not changed
|
|
|
|
- driver_labels_6 is changed
|