[a] experimental new docker compose file creator
This commit is contained in:
parent
d23979f935
commit
48165bef42
3 changed files with 56 additions and 0 deletions
19
roles/docker/defaults/main.yml
Normal file
19
roles/docker/defaults/main.yml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# run compose task?
|
||||||
|
core_docker_compose: false
|
||||||
|
|
||||||
|
# the docker compose service's name
|
||||||
|
core_docker_compose_name: "Docker Compose"
|
||||||
|
|
||||||
|
# create directories
|
||||||
|
core_docker_compose_mkdir: false
|
||||||
|
# chown directories with this value
|
||||||
|
core_docker_compose_dirs_mode: '0750'
|
||||||
|
|
||||||
|
# copy templates
|
||||||
|
core_docker_compose_cp_files: false
|
||||||
|
# chown templates with this value
|
||||||
|
core_docker_compose_templates_mode: '0650'
|
||||||
|
|
||||||
|
# docker-compose.yml template source
|
||||||
|
core_docker_compose_file:
|
||||||
|
src: docker-compose.yml.j2
|
31
roles/docker/tasks/compose.yml
Normal file
31
roles/docker/tasks/compose.yml
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
- name: "Create {{ core_docker_compose_name }} directories."
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: '{{ core_docker_compose_dirs_loop }}'
|
||||||
|
state: directory
|
||||||
|
owner: '{{ core_docker_compose_user }}'
|
||||||
|
group: '{{ core_docker_compose_group }}'
|
||||||
|
mode: "{{ core_docker_compose_dirs_mode }}"
|
||||||
|
loop: '{{ core_docker_compose_dirs }}'
|
||||||
|
loop_control:
|
||||||
|
loop_var: core_docker_compose_dirs_loop
|
||||||
|
when: core_docker_compose_mkdir
|
||||||
|
|
||||||
|
- name: "Create {{ core_docker_compose_name }} files"
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: '{{ core_docker_compose_template_loop.src }}'
|
||||||
|
dest: '{{ core_docker_compose_template_loop.dest }}'
|
||||||
|
owner: '{{ core_docker_compose_user }}'
|
||||||
|
group: '{{ core_docker_compose_group }}'
|
||||||
|
mode: '{{ core_docker_compose_templates_mode }}'
|
||||||
|
loop: '{{ core_docker_compose_templates }}'
|
||||||
|
loop_control:
|
||||||
|
loop_var: '{{ core_docker_compose_template_loop }}'
|
||||||
|
when: core_docker_compose_cp_files
|
||||||
|
|
||||||
|
- name: "Create docker-compose.yml for {{ core_docker_compose_name }}"
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: '{{ core_docker_compose_file.src }}'
|
||||||
|
dest: '{{ core_docker_compose_file.dest }}'
|
||||||
|
owner: '{{ core_docker_compose_compose_user }}'
|
||||||
|
group: '{{ core_docker_compose_compose_group }}'
|
||||||
|
mode: '0750'
|
|
@ -28,3 +28,9 @@
|
||||||
- docker-compose-plugin
|
- docker-compose-plugin
|
||||||
state: present
|
state: present
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
|
|
||||||
|
- name: Run docker-compose creation process
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: docker
|
||||||
|
tasks_from: compose
|
||||||
|
when: core_docker_compose
|
Loading…
Reference in a new issue