Restart the container if fileChanged is defined

This commit is contained in:
Cory Hawkless 2021-06-17 01:04:27 +09:30
commit 8654f76936
2 changed files with 9 additions and 84 deletions

View File

@ -214,10 +214,15 @@
tags: always tags: always
#----------------------------------/Check ENV---------------------------------- #----------------------------------/Check ENV----------------------------------
<<<<<<< HEAD
- name: Restart the container if fileChanged is defined - name: Restart the container if fileChanged is defined
set_fact: item.value.restart='yes' set_fact: item.value.restart='yes'
when: fileChanged is defined when: fileChanged is defined
=======
#TODO - If a confile file or volume is changed, trestart the container
>>>>>>> 4f62020d89990a6ff0b6ec67f986f613e77f308f
- name: "Container {{ container_Name }}" - name: "Container {{ container_Name }}"
become: yes become: yes

View File

@ -1,92 +1,12 @@
#- name: "Checking docker volume {{working_volume_name}}" #- name: "Checking docker volume {{working_volume_name}}"
# debug: msg="Checking docker volume {{working_volume_name}}" # debug: msg="Checking docker volume {{working_volume_name}}"
#----------------------------------CephFS Volume----------------------------------
- set_fact: base_volume_name="cephFS_"
tags: always
- name: Set working_volume_name(staticName not defined)
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/cephFS"
file:
path: "{{containerConfigDir}}/docker/cephFS"
state: directory
recurse: no
when: item.value.type=="cephfs"
tags: always
- name: "Create {{ containerConfigDir }}/docker/configs"
file:
path: "{{containerConfigDir}}/docker/configs"
state: directory
recurse: no
when: item.value.type=="cephfs"
tags: always
- name: Add CephFS mount to fstab
lineinfile:
dest=/etc/fstab
backup=yes
state=present
line='none {{containerConfigDir}}/docker/cephFS fuse.ceph ceph.id=admin,_netdev,defaults 0 0'
register: fstab
tags: mount,always
when: item.value.type=="cephfs"
- name: Mount FSTab
shell: "mount -a"
args:
warn: false
when: fstab.changed
tags: mount,always
- name: "Checking docker volume "
debug: msg="CephFS user {{ cephFS_user }} secret {{ cephFS_secret }}"
when: item.value.type=="cephfs"
tags: always
- name: "Create docker volume - {{ working_volume_name }}"
docker_volume:
name: "{{ working_volume_name }}"
driver: n0r1skcom/docker-volume-cephfs
driver_options:
name="{{cephFS_user}}"
path="/container/{{working_volume_name}}"
secret="{{cephFS_secret}}"
monitors="{{ceph_Mons}}"
register: dockerVolume
tags: volume,always
when: item.value.type=="cephfs"
# This is needed so that when Docker goes to mount the volume, the folder it's looking for actually exists
- name: Create {{containerConfigDir}}/docker/cephFS/container/{{working_volume_name}}
file:
path: "{{containerConfigDir}}/docker/cephFS/container/{{working_volume_name}}"
state: directory
recurse: no
when: dockerVolume.changed
tags: volume,always
when: item.value.type=="cephfs"
- 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=="cephfs"
tags: always
#----------------------------------/CephFS Volume----------------------------------
#----------------------------------Local Volume---------------------------------- #----------------------------------Local Volume----------------------------------
- set_fact: base_volume_name="local_" - set_fact: base_volume_name="local_"
- name: Set working_volume_name(staticName not defined) tags: always
- name: xSet working_volume_name(staticName not defined)
set_fact: working_volume_name="{{base_volume_name+container_Name + '_' + item.value.volumeName}}" set_fact: working_volume_name="{{base_volume_name+container_Name + '_' + item.value.volumeName}}"
when: item.value.staticName is not defined when: item.value.staticName is not defined
tags: always tags: always