Compare commits

...

10 Commits

2 changed files with 78 additions and 29 deletions
+62 -13
View File
@@ -56,6 +56,7 @@
#----------------------------------TEMPLATES----------------------------------
#Only copy template files if there are templates defined in the incoming defintion dict
- set_fact: templates_Defined=0
@@ -80,7 +81,8 @@
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
@@ -91,7 +93,8 @@
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
@@ -132,6 +135,8 @@
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
@@ -142,6 +147,8 @@
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
@@ -152,6 +159,8 @@
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:
@@ -208,12 +217,9 @@
tags: always
#----------------------------------/Check ENV----------------------------------
#TODO - If a confile file or volume is changed, trestart the container
- name: "Container {{ container_Name }}"
become: yes
docker_container:
- name: Setup default values for this container
set_fact:
default:
name: "{{ container_Name }}"
hostname: "{{ item.value.hostname | default(container_Name) }}"
command: "{{ item.value.command | default('') }}"
@@ -231,9 +237,52 @@
network_mode: "{{ item.value.network_mode | default ('default') }}"
shm_size: "{{ item.value.shm_size | default ('64M') }}"
ports: "{{ item.value.ports | default ([]) }}"
#log_driver: fluentd
#"{{item.value.ports | default ([json-file])}}"
#log_options:
# fluentd-sub-second-precision: true
# tag: myservice
tags: always
- name: Setup devices_override blank
set_fact:
devices_override:
tags: always
- name: Setup ulimit_override blank
set_fact:
ulimit_override:
tags: always
#----------Merge ulimits--------------
- name: Apply conditional override
set_fact:
ulimit_override:
ulimits: "{{ item.value.ulimits }}"
when: item.value.ulimits is defined
tags: always
- name: Merge the two lists
set_fact:
ulimits_merged: "{{ default | combine(ulimit_override, recursive=true) }}"
tags: always
#----------Merge devices--------------
- name: Apply conditional override
set_fact:
devices_override:
devices: "{{ item.value.devices }}"
when: item.value.devices is defined
tags: always
- name: Merge the two lists
set_fact:
final_merged: "{{ ulimits_merged | combine(devices_override, recursive=true) }}"
tags: always
- name: debug value
debug:
msg: "{{final_merged}}"
tags: always
- name: "Container {{ container_Name }}"
become: true
docker_container: "{{ final_merged }}"
tags: always