Skip to content

Commit

Permalink
Merge pull request #42 from shantanoo-desai/develop
Browse files Browse the repository at this point in the history
features: license headers + .env file generation
  • Loading branch information
shantanoo-desai authored Mar 29, 2023
2 parents d2063ef + d74a1a5 commit 6669e77
Show file tree
Hide file tree
Showing 20 changed files with 205 additions and 52 deletions.
3 changes: 3 additions & 0 deletions ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[defaults]
ansible_managed = This file is generated by Komponist.%n
Generated On: %Y-%m-%d %H:%M:%S %n
31 changes: 31 additions & 0 deletions generate_stack.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# Komponist - Generate Your Favourite Compose Stack With the Least Effort
#
# Copyright (C) 2023 Shantanoo "Shan" Desai <sdes.softdev@gmail.com>
#
# 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
Expand Down Expand Up @@ -39,3 +57,16 @@
compose_files: >-
{{ komponist.configuration.keys() | map('regex_replace', '^(.*)$', ' -f docker-compose.\1.yml') | join | trim }}
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 }}/docker-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 }}/.env"
mode: "0755"
15 changes: 0 additions & 15 deletions tasks/configure-grafana.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,6 @@
state: directory
mode: "0755"

- name: '(Grafana) Adding Environment Variables for Deployment'
block:
- name: Creating `.env` file if it doesn't exist
ansible.builtin.file:
path: "{{ komponist.deploy_dir }}/.env"
state: touch
mode: "0755"

- name: '(Grafana) Insert Grafana Credentials'
ansible.builtin.blockinfile:
path: "{{ komponist.deploy_dir }}/.env"
block: |
GRAFANA_ADMIN_USERNAME={{ credentials.grafana.admin_username }}
GRAFANA_ADMIN_PASSWORD={{ credentials.grafana.admin_password }}
- name: '(Grafana) Generating Datasources File'
ansible.builtin.template:
src: config/grafana/provisioning/datasources/datasources.yml.j2
Expand Down
1 change: 1 addition & 0 deletions tasks/configure-mosquitto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
community.docker.docker_container:
name: mosquitto-passgen
image: "eclipse-mosquitto:{{ komponist.configuration.mosquitto.version }}"
user: "1000"
state: started
command: mosquitto_passwd -U /mosquitto/config/users
volumes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
# 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/>.

# datasources.yml.j2: Grafana Datasources file for Komponist services
{{ ansible_managed | comment }}

{# datasources.yml.j2: Jinja2 Template for Grafana Datasources YAML file #}

apiVersion: 1

datasources:
Expand Down
22 changes: 21 additions & 1 deletion templates/config/influxdbv1/influxdbv1.env.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
# InfluxDBv1
# Komponist - Generate Your Favourite Compose Stack With the Least Effort
#
# Copyright (C) 2023 Shantanoo "Shan" Desai <sdes.softdev@gmail.com>
#
# 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/>.

{{ ansible_managed | comment }}

{# influxdbv1.env.j2: Jinja2 Template InfluxDBv1 Environment Variables #}

INFLUXDB_DB={{ credentials.influxdbv1.init_database }}

INFLUXDB_ADMIN_USER={{ credentials.influxdbv1.admin_username }}
Expand Down
22 changes: 21 additions & 1 deletion templates/config/influxdbv2/influxdbv2.env.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
# InfluxDBv2
# Komponist - Generate Your Favourite Compose Stack With the Least Effort
#
# Copyright (C) 2023 Shantanoo "Shan" Desai <sdes.softdev@gmail.com>
#
# 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/>.

{{ ansible_managed | comment }}

{# influxdbv2.env.j2: Jinja2 Template InfluxDBv2 Environment Variables #}

DOCKER_INFLUXDB_INIT_ORG={{ credentials.influxdbv2.init_org_name }}
DOCKER_INFLUXDB_INIT_BUCKET={{ credentials.influxdbv2.init_bucket }}
DOCKER_INFLUXDB_INIT_RETENTION={{ credentials.influxdbv2.init_bucket_retention }}
Expand Down
26 changes: 26 additions & 0 deletions templates/config/komponist.env.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Komponist - Generate Your Favourite Compose Stack With the Least Effort
#
# Copyright (C) 2023 Shantanoo "Shan" Desai <sdes.softdev@gmail.com>
#
# 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/>.

{{ ansible_managed | comment }}

{# komponist.env.j2: Jinja2 Template for generating the .env file for Docker Compose Deployment #}

{% if 'grafana' in komponist.configuration.keys() %}
# Grafana Admin Credentials
GRAFANA_ADMIN_USERNAME={{ credentials.grafana.admin_username }}
GRAFANA_ADMIN_PASSWORD={{ credentials.grafana.admin_password }}
{% endif %}
1 change: 0 additions & 1 deletion templates/config/mosquitto/acl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# 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/>.#}
{#- acl.j2: Jinja2 Template for Mosquitto ACL -#}

{%- for user in credentials.mosquitto.users %}
user {{ user.username }}
{% for access_list in user.acl %}
Expand Down
9 changes: 6 additions & 3 deletions templates/config/mosquitto/mosquitto.conf.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{#- Komponist - Generate Your Favourite Compose Stack With the Least Effort
# Komponist - Generate Your Favourite Compose Stack With the Least Effort
#
# Copyright (C) 2023 Shantanoo "Shan" Desai <sdes.softdev@gmail.com>
#
Expand All @@ -13,8 +13,11 @@
# 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/>. #}
{#- mosquitto.conf.j2: Jinja2 Template for mosquitto.conf file required for Mosquitto MQTT Broker -#}
# along with this program. If not, see <https://www.gnu.org/licenses/>. #

{{ ansible_managed | comment }}

{# mosquitto.conf.j2: Jinja2 Template for mosquitto.conf file required for Mosquitto MQTT Broker #}

# MQTT Port Listener
listener 1883
Expand Down
43 changes: 24 additions & 19 deletions templates/config/nodered/settings.js.j2
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
{#- Komponist - Generate Your Favourite Compose Stack With the Least Effort
#
# Copyright (C) 2023 Shantanoo "Shan" Desai <sdes.softdev@gmail.com>
#
# 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/>. #}
{#- Modified settings.js file from node-red project at https://github.com/node-red/node-red
# Licensed with Apache 2.0 License by OpenJS Foundation (https://github.com/node-red/node-red/blob/master/LICENSE) #}
{#- setting.js.j2: Jinja2 Template for settings.js file required for Node-RED -#}
/*
* Komponist - Generate Your Favourite Compose Stack With the Least Effort
*
* Copyright (C) 2023 Shantanoo "Shan" Desai <sdes.softdev@gmail.com>
*
* 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/>. #}
* Modified settings.js file from node-red project at https://github.com/node-red/node-red
* Licensed with Apache 2.0 License by OpenJS Foundation (https://github.com/node-red/node-red/blob/master/LICENSE)
*/

{{ ansible_managed | comment('cblock') }}

{# setting.js.j2: Jinja2 Template for settings.js file required for Node-RED #}

module.exports = {

Expand Down
10 changes: 7 additions & 3 deletions templates/config/traefik/configurations/dynamic.yml.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{#- Komponist - Generate Your Favourite Compose Stack With the Least Effort
# Komponist - Generate Your Favourite Compose Stack With the Least Effort
#
# Copyright (C) 2023 Shantanoo "Shan" Desai <sdes.softdev@gmail.com>
#
Expand All @@ -13,8 +13,12 @@
# 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/>.#}
{#- dynamic.yml.j2: Jinja2 Template for Traefik Reverse Proxy Dynamic Configuration -#}
# along with this program. If not, see <https://www.gnu.org/licenses/>.

{{ ansible_managed | comment }}

{# dynamic.yml.j2: Jinja2 Template for Traefik Reverse Proxy Dynamic Configuration #}

http:
# Routers
routers:
Expand Down
10 changes: 7 additions & 3 deletions templates/config/traefik/traefik.yml.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{#- Komponist - Generate Your Favourite Compose Stack With the Least Effort
# Komponist - Generate Your Favourite Compose Stack With the Least Effort
#
# Copyright (C) 2023 Shantanoo "Shan" Desai <sdes.softdev@gmail.com>
#
Expand All @@ -13,8 +13,12 @@
# 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/>.#}
{#- traefik.yml.j2: Jinja2 Template for Default Traefik Reverse Proxy -#}
# along with this program. If not, see <https://www.gnu.org/licenses/>

{{ ansible_managed | comment }}

{# traefik.yml.j2: Jinja2 Template for Default Traefik Reverse Proxy #}

global:
checkNewVersion: false
sendAnonymousUsage: false
Expand Down
18 changes: 18 additions & 0 deletions templates/license_header.txt.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Komponist - Generate Your Favourite Compose Stack With the Least Effort
#
# Copyright (C) 2023 Shantanoo "Shan" Desai <sdes.softdev@gmail.com>
#
# 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/>.

{{ ansible_managed | comment }}
4 changes: 3 additions & 1 deletion templates/services/docker-compose.grafana.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
# 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/>.

# docker-compose.grafana.yml.j2: Jinja2 Template for Grafana Compose Service
{{ ansible_managed | comment }}

{# docker-compose.grafana.yml.j2: Jinja2 Template for Grafana Compose Service #}

services:
grafana:
Expand Down
4 changes: 3 additions & 1 deletion templates/services/docker-compose.influxdbv1.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
# 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/>.

# docker-compose.influxdbv1.yml.j2: Jinja2 Template for InfluxDBv1 Compose Service
{{ ansible_managed | comment }}

{# docker-compose.influxdbv1.yml.j2: Jinja2 Template for InfluxDBv1 Compose Service #}

services:
influxdbv1:
Expand Down
4 changes: 3 additions & 1 deletion templates/services/docker-compose.influxdbv2.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
# 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/>.

# docker-compose.influxdbv2.yml.j2: Jinja2 Template for InfluxDBv2 Compose Service
{{ ansible_managed | comment }}

{# docker-compose.influxdbv2.yml.j2: Jinja2 Template for InfluxDBv2 Compose Service #}

services:
influxdbv2:
Expand Down
4 changes: 3 additions & 1 deletion templates/services/docker-compose.mosquitto.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
# 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/>.

# docker-compose.mosquitto.yml.j2: Jinja2 Template for Mosquitto MQTT Compose Service
{{ ansible_managed | comment }}

{# docker-compose.mosquitto.yml.j2: Jinja2 Template for Mosquitto MQTT Compose Service #}

services:
mosquitto:
Expand Down
4 changes: 3 additions & 1 deletion templates/services/docker-compose.nodered.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
# 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/>.

# docker-compose.nodered.yml.j2: Jinja2 Template for Node-RED Compose Service
{{ ansible_managed | comment }}

{# docker-compose.nodered.yml.j2: Jinja2 Template for Node-RED Compose Service #}

services:
nodered:
Expand Down
21 changes: 21 additions & 0 deletions templates/services/docker-compose.traefik.yml.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# Komponist - Generate Your Favourite Compose Stack With the Least Effort
#
# Copyright (C) 2023 Shantanoo "Shan" Desai <sdes.softdev@gmail.com>
#
# 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/>.

{{ ansible_managed | comment }}

{# docker-compose.traefik.yml.j2: Jinja2 Template for Traefik Compose Service #}

services:
traefik:
{# Check whether the Image should be pulled from a Public Registry or Internal Registry #}
Expand Down

0 comments on commit 6669e77

Please sign in to comment.