Compare commits
No commits in common. "main" and "24a5c782477e10b448bbf504d848d0b470293841" have entirely different histories.
main
...
24a5c78247
|
@ -56,7 +56,6 @@
|
|||
|
||||
|
||||
|
||||
|
||||
#----------------------------------TEMPLATES----------------------------------
|
||||
#Only copy template files if there are templates defined in the incoming defintion dict
|
||||
- set_fact: templates_Defined=0
|
||||
|
@ -81,8 +80,7 @@
|
|||
loop_var: outer_item
|
||||
when: templates_Defined ==1 and outer_item.value.generic is not defined
|
||||
tags: always
|
||||
register: regular_template
|
||||
notify: Restart container
|
||||
|
||||
#Copy templates form a generic dir, allow ansible to search
|
||||
- name: "Generic template mappings for {{ container_Name }}"
|
||||
#Files will be copied to the 'config' dir as defined by container_configDir, they will be stored using their template file name but with the '.j2' stripped
|
||||
|
@ -93,8 +91,7 @@
|
|||
loop_var: outer_item
|
||||
when: templates_Defined ==1 and outer_item.value.generic is defined
|
||||
tags: always
|
||||
register: generic_template
|
||||
notify: Restart container
|
||||
|
||||
- name: Append templated files to the mapping list
|
||||
set_fact:
|
||||
#build a list to pass to docker containing the source of the file(As on disk on the host) and the destination mount within the container
|
||||
|
@ -135,8 +132,6 @@
|
|||
loop_var: outer_item
|
||||
when: files_Defined == 1 and outer_item.value.generic is not defined and outer_item.value.src_text is not defined
|
||||
tags: always
|
||||
register: file_copy
|
||||
notify: Restart container
|
||||
#Copy files from a generic dir, allow ansible to search
|
||||
- name: "Generic File mappings for {{ container_Name }}"
|
||||
#Files will be copied to the 'config' dir as defined by container_configDir, they will be stored using their file name
|
||||
|
@ -147,8 +142,6 @@
|
|||
loop_var: outer_item
|
||||
when: files_Defined == 1 and outer_item.value.generic is defined and outer_item.value.src_text is not defined
|
||||
tags: always
|
||||
register: generic_copy
|
||||
notify: Restart container
|
||||
#Create files based on the suplied src_text param
|
||||
- name: "Text based file creation for {{ container_Name }}"
|
||||
#Files will be copied to the 'config' dir as defined by container_configDir, they will be stored using their file name
|
||||
|
@ -159,8 +152,6 @@
|
|||
loop_var: outer_item
|
||||
when: files_Defined == 1 and outer_item.value.src_text is defined
|
||||
tags: always
|
||||
register: text_copy
|
||||
notify: Restart container
|
||||
|
||||
- name: Append static remote files to the mapping list
|
||||
set_fact:
|
||||
|
@ -217,9 +208,6 @@
|
|||
tags: always
|
||||
#----------------------------------/Check ENV----------------------------------
|
||||
|
||||
- name: Restart the container if fileChanged is defined
|
||||
set_fact: containerRestart1='yes'
|
||||
when: (containerRestart is defined and containerRestart=='yes') or (item.value.restart is defined and item.value.restart =='yes')
|
||||
|
||||
|
||||
|
||||
|
@ -233,7 +221,7 @@
|
|||
recreate: "{{ item.value.recreate | default('false') }}"
|
||||
image: "{{ item.value.image }}"
|
||||
state: "{{ item.value.start | default ('started') }}"
|
||||
restart: "{{ containerRestart1 | default ('no') }}"
|
||||
restart: "{{ item.value.restart | default ('no') }}"
|
||||
restart_policy: "{{ item.value.restart_policy | default ('always') }}"
|
||||
purge_networks: "{{ item.value.purge_networks | default ('yes') }}"
|
||||
networks: "{{ net_checked }}"
|
||||
|
@ -243,17 +231,9 @@
|
|||
network_mode: "{{ item.value.network_mode | default ('default') }}"
|
||||
shm_size: "{{ item.value.shm_size | default ('64M') }}"
|
||||
ports: "{{ item.value.ports | default ([]) }}"
|
||||
cpu_period: "{{ item.value.cpu_period | default(0) }}"
|
||||
cpu_quota: "{{ item.value.cpu_quota | default(0) }}"
|
||||
cpu_shares: "{{ item.value.cpu_shares | default(0) }}"
|
||||
cpus: "{{ item.value.cpus | default(0) }}"
|
||||
cpuset_cpus: "{{ item.value.cpuset_cpus | default('') }}"
|
||||
mem_limit: "{{ item.value.mem_limit | default(0) }}"
|
||||
mem_reservation: "{{ item.value.mem_reservation | default(0) }}"
|
||||
#log_driver: fluentd
|
||||
#"{{item.value.ports | default ([json-file])}}"
|
||||
#log_options:
|
||||
# fluentd-sub-second-precision: true
|
||||
# tag: myservice
|
||||
tags: always
|
||||
|
||||
|
|
|
@ -1,12 +1,93 @@
|
|||
#- name: "Checking docker volume {{working_volume_name}}"
|
||||
# debug: msg="Checking docker volume {{working_volume_name}}"
|
||||
|
||||
# ----------------------------------Local Volume----------------------------------
|
||||
|
||||
- set_fact: base_volume_name="local_"
|
||||
#----------------------------------CephFS Volume----------------------------------
|
||||
- set_fact: base_volume_name="cephFS_"
|
||||
tags: always
|
||||
|
||||
- name: xSet working_volume_name(staticName not defined)
|
||||
- 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----------------------------------
|
||||
- set_fact: base_volume_name="local_"
|
||||
- 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
|
||||
|
|
Loading…
Reference in New Issue