mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
2.1 KiB
YAML
93 lines
2.1 KiB
YAML
6 years ago
|
---
|
||
|
- 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
|
||
|
|
||
|
- name: Create a volume (force)
|
||
|
docker_volume:
|
||
|
name: "{{ vname }}"
|
||
|
force: yes
|
||
|
register: create_3
|
||
|
|
||
|
- 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
|
||
|
- create_3 is changed
|
||
|
- 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
|
||
|
|
||
|
- name: Cleanup
|
||
|
docker_volume:
|
||
|
name: "{{ vname }}"
|
||
|
state: absent
|
||
|
|
||
|
- assert:
|
||
|
that:
|
||
|
- driver_options_1 is changed
|
||
|
- driver_options_2 is not changed
|
||
|
- driver_options_3 is changed
|