Compare commits

...

10 Commits

Author SHA1 Message Date
coryHawkvelt 1b95015c0f cpu and memory limits 2024-07-03 10:27:22 +09:30
coryHawkvelt 58d4ca0cf7 Added CPU and memoty limits 2024-07-03 10:22:31 +09:30
coryHawkvelt a99dbaee07 Includes conditional setting for ulimts and devices 2022-11-17 00:37:48 +10:30
coryHawkvelt f0a6a7d51a changed defaultto None 2022-10-22 01:18:28 +10:30
coryHawkvelt 3c2d85f480 Add devices 2022-10-22 01:03:01 +10:30
coryHawkvelt 56beaa8208 Rollback ulimits 2022-10-11 00:18:19 +10:30
HawkveltGiteaAdmin 7016ab2464 Upd 2022-10-10 14:40:59 +10:30
HawkveltGiteaAdmin 032cc44c2b Upd 2022-10-10 14:39:36 +10:30
HawkveltGiteaAdmin 24d69d8d66 containerRestart1 2021-06-17 01:53:42 +09:30
HawkveltGiteaAdmin eb0372ded4 remove merge text 2021-06-17 01:07:43 +09:30
2 changed files with 24 additions and 17 deletions
+22 -15
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
@@ -79,9 +80,9 @@
loop_control:
loop_var: outer_item
when: templates_Defined ==1 and outer_item.value.generic is not defined
register: fileChanged
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,9 +92,9 @@
loop_control:
loop_var: outer_item
when: templates_Defined ==1 and outer_item.value.generic is defined
register: fileChanged
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
@@ -133,8 +134,9 @@
loop_control:
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
register: fileChanged
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
@@ -144,8 +146,9 @@
loop_control:
loop_var: outer_item
when: files_Defined == 1 and outer_item.value.generic is defined and outer_item.value.src_text is not defined
register: fileChanged
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
@@ -155,8 +158,9 @@
loop_control:
loop_var: outer_item
when: files_Defined == 1 and outer_item.value.src_text is defined
register: fileChanged
tags: always
register: text_copy
notify: Restart container
- name: Append static remote files to the mapping list
set_fact:
@@ -197,7 +201,6 @@
loop_control:
loop_var: outer_item
when: local_Defined == 1
register: fileChanged
tags: always
#----------------------------------/LOCAL----------------------------------
@@ -214,15 +217,11 @@
tags: always
#----------------------------------/Check ENV----------------------------------
<<<<<<< HEAD
- name: Restart the container if fileChanged is defined
set_fact: item.value.restart='yes'
when: 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')
=======
#TODO - If a confile file or volume is changed, trestart the container
>>>>>>> 4f62020d89990a6ff0b6ec67f986f613e77f308f
- name: "Container {{ container_Name }}"
become: yes
@@ -234,7 +233,7 @@
recreate: "{{ item.value.recreate | default('false') }}"
image: "{{ item.value.image }}"
state: "{{ item.value.start | default ('started') }}"
restart: "{{ item.value.restart | default ('no') }}"
restart: "{{ containerRestart1 | default ('no') }}"
restart_policy: "{{ item.value.restart_policy | default ('always') }}"
purge_networks: "{{ item.value.purge_networks | default ('yes') }}"
networks: "{{ net_checked }}"
@@ -244,9 +243,17 @@
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