diff --git a/infrastructure/templates/infrastructure/yml/service.yml b/infrastructure/templates/infrastructure/yml/service.yml new file mode 100644 index 0000000..27c35ce --- /dev/null +++ b/infrastructure/templates/infrastructure/yml/service.yml @@ -0,0 +1,4 @@ +gitea-service-group: + hosts: + {{ subdomain }}-host: + ansible_port: 2222 diff --git a/infrastructure/utils.py b/infrastructure/utils.py index febed6e..f55a815 100644 --- a/infrastructure/utils.py +++ b/infrastructure/utils.py @@ -90,6 +90,13 @@ class Infra: return self.repo_path.joinpath(f"inventory/{subdomain}-backup.yml") + def _service_path(self, subdomain: str) -> Path: + """ + utility method: get service file for a subdomain + """ + + return self.repo_path.joinpath(f"inventory/{subdomain}-service.yml") + def _hostscript_path(self, subdomain: str) -> Path: """ utility method: hostscript file for a subdomain @@ -204,6 +211,14 @@ class Infra: ) ) + service = self._service_path(subdomain) + with open(backup, "w", encoding="utf-8") as f: + f.write( + render_to_string( + "infrastructure/yml/service.yml", context={"subdomain": subdomain} + ) + ) + # hostscript = self.repo_path.join("inventory/hosts-scripts/{instance.name}-host.sh") self.write_hostscript(