Compare commits
15 Commits
24a5c78247
...
main
Author | SHA1 | Date |
---|---|---|
Cory Hawkvelt | 1b95015c0f | |
Cory Hawkvelt | 58d4ca0cf7 | |
Cory Hawkvelt | a99dbaee07 | |
Cory Hawkvelt | f0a6a7d51a | |
Cory Hawkvelt | 3c2d85f480 | |
Cory Hawkvelt | 56beaa8208 | |
Cory Hawkless | 7016ab2464 | |
Cory Hawkless | 032cc44c2b | |
Cory Hawkless | 24d69d8d66 | |
Cory Hawkless | eb0372ded4 | |
Cory Hawkless | 8654f76936 | |
Cory Hawkless | db4c4fbefd | |
Cory Hawkless | 4f62020d89 | |
Cory Hawkless | c06f636bfa | |
Cory Hawkless | 3b47f34642 |
|
@ -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,6 +217,9 @@
|
|||
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')
|
||||
|
||||
|
||||
|
||||
|
@ -221,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 }}"
|
||||
|
@ -231,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
|
||||
|
||||
|
|
|
@ -1,93 +1,12 @@
|
|||
#- name: "Checking docker volume {{working_volume_name}}"
|
||||
# - name: "Checking docker volume {{working_volume_name}}"
|
||||
# debug: msg="Checking docker volume {{working_volume_name}}"
|
||||
|
||||
# ----------------------------------Local Volume----------------------------------
|
||||
|
||||
#----------------------------------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----------------------------------
|
||||
- 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}}"
|
||||
when: item.value.staticName is not defined
|
||||
tags: always
|
||||
|
|
Loading…
Reference in New Issue