-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgenerate_stack.yml
66 lines (60 loc) · 2.74 KB
/
generate_stack.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# SPDX-License-Identifier: AGPL-3.0-only
#
# Komponist - Generate Your Favourite Compose Stack With the Least Effort
#
# Copyright (C) 2025 Shantanoo "Shan" Desai <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# generate-stack.yml: Ansible Playbook that generates Komponist Stack Files
---
- name: Komponist Stack Generation Playbook
hosts: localhost
gather_facts: true
vars_files:
- vars/config.yml
- vars/creds.yml
tasks:
- name: "(KOMPONIST) Generating Directory for Production-Ready Files"
ansible.builtin.file:
name: "{{ komponist.deploy_dir | default(ansible_user_dir + '/.komponist') }}"
state: directory
mode: "0755"
- name: "(KOMPONIST) Generating Configuration / Compose Files from Templates"
ansible.builtin.include_tasks: "tasks/configure-{{ item }}.yml"
with_items:
- "{{ komponist.configuration.keys() }}"
- name: "(KOMPONIST) Generating Entrypoint compose.yml file from Templates"
ansible.builtin.template:
src: templates/services/compose.yml.j2
dest: "{{ komponist.deploy_dir | default(ansible_user_dir + '/.komponist') }}/compose.yml"
mode: "0644"
- name: "(KOMPONIST) Validating Docker Compose Services"
ansible.builtin.command:
cmd: docker compose config --no-interpolate --no-path-resolution --quiet
args:
chdir: "{{ komponist.deploy_dir | default(ansible_user_dir + '/.komponist') }}"
register: docker_compose_validity
changed_when: docker_compose_validity.rc != 0
- name: "(KOMPONIST) Update the header for generated docker-compose.yml file"
ansible.builtin.blockinfile:
block: "{{ lookup('ansible.builtin.template', 'templates/license_header.txt.j2') }}"
path: "{{ komponist.deploy_dir | default(ansible_user_dir + '/.komponist') }}/compose.yml"
insertbefore: "BOF"
marker: ""
- name: "(KOMPONIST) Generating the .env file for the Project"
ansible.builtin.template:
src: config/komponist.env.j2
dest: "{{ komponist.deploy_dir | default(ansible_user_dir + '/.komponist') }}/.env"
mode: "0644"