2020-10-02 06:07:29 +00:00
|
|
|
#- name: "Checking docker volume {{working_volume_name}}"
|
|
|
|
# debug: msg="Checking docker volume {{working_volume_name}}"
|
|
|
|
|
2021-06-09 12:23:46 +00:00
|
|
|
#----------------------------------Local Volume----------------------------------
|
2020-10-02 06:07:29 +00:00
|
|
|
|
2021-06-09 12:23:46 +00:00
|
|
|
- set_fact: base_volume_name="local_"
|
2020-10-02 06:07:29 +00:00
|
|
|
tags: always
|
|
|
|
|
2021-06-09 12:23:46 +00:00
|
|
|
- name: xSet working_volume_name(staticName not defined)
|
2020-10-02 06:07:29 +00:00
|
|
|
set_fact: working_volume_name="{{base_volume_name+container_Name + '_' + item.value.volumeName}}"
|
|
|
|
when: item.value.staticName is not defined
|
|
|
|
tags: always
|
|
|
|
|
|
|
|
- name: Set working_volume_name(staticName IS defined)
|
|
|
|
set_fact: working_volume_name={{item.value.staticName}}
|
|
|
|
when: item.value.staticName is defined
|
|
|
|
tags: always
|
|
|
|
|
|
|
|
- name: "Create {{ containerConfigDir }}/docker/local"
|
|
|
|
file:
|
|
|
|
path: "{{containerConfigDir}}/docker/local"
|
|
|
|
state: directory
|
|
|
|
recurse: no
|
|
|
|
when: item.value.type=="local"
|
|
|
|
tags: always
|
|
|
|
|
|
|
|
- name: "Create {{ containerConfigDir }}/docker/configs"
|
|
|
|
file:
|
|
|
|
path: "{{containerConfigDir}}/docker/configs"
|
|
|
|
state: directory
|
|
|
|
recurse: no
|
|
|
|
when: item.value.type=="local"
|
|
|
|
tags: always
|
|
|
|
|
|
|
|
- name: "Create docker volume - {{ working_volume_name }}"
|
|
|
|
docker_volume:
|
|
|
|
name: "{{ working_volume_name }}"
|
|
|
|
driver: "local"
|
|
|
|
driver_options:
|
|
|
|
o: "bind"
|
|
|
|
device: "{{containerConfigDir}}/docker/local/container/{{working_volume_name}}"
|
|
|
|
type: "none"
|
|
|
|
register: dockerVolume
|
|
|
|
tags: volume,always
|
|
|
|
when: item.value.type=="local"
|
|
|
|
|
|
|
|
# This is needed so that when Docker goes to mount the volume, the folder it's looking for actually exists
|
|
|
|
- name: Create {{containerConfigDir}}/docker/local/container/{{working_volume_name}}
|
|
|
|
file:
|
|
|
|
path: "{{containerConfigDir}}/docker/local/container/{{working_volume_name}}"
|
|
|
|
state: directory
|
|
|
|
recurse: no
|
|
|
|
when: dockerVolume.changed
|
|
|
|
tags: volume,always
|
|
|
|
when: item.value.type=="local"
|
|
|
|
|
|
|
|
- name: Append the volume to the container mapping list(mappings var defined in dockerContainer.yml)
|
|
|
|
set_fact:
|
|
|
|
mappings: "{{ mappings + [ working_volume_name + ':' + item.value.dest + ':' + item.value.params | default('rw') ] }}"
|
|
|
|
when: item.value.type=="local"
|
|
|
|
tags: always
|
|
|
|
#----------------------------------/Local Volume----------------------------------
|