Move static files into files/ and Jinja2 templates into templates/ #169

Merged
samsapti merged 7 commits from move_stuff_around into main 2023-09-29 21:09:08 +00:00
Owner

I've moved files around so that they are in the correct folders, and so that it makes more sense (to me at least :D).

This is how it looks now:

files
├── element
│  └── riot.im.conf
├── mastodon
│  └── postgresql.conf
├── matrix
│  └── log.config
├── privatebin
│  └── conf.php
├── sso
│  └── sso.data.coop.pem
└── vhost
   ├── base_domain
   ├── docker_registry
   ├── element
   ├── mastodon
   ├── matrix
   ├── nextcloud
   └── www.base_domain
templates
├── element
│  └── config.json.j2
├── mailu
│  └── env.j2
├── mastodon
│  └── env.j2
├── matrix
│  └── homeserver.yaml.j2
├── rallly
│  └── env.j2
└── restic
   ├── ssh.config.j2
   └── ssh.known_hosts.j2

What do you think?

I've moved files around so that they are in the correct folders, and so that it makes more sense (to me at least :D). This is how it looks now: ```txt files ├── element │ └── riot.im.conf ├── mastodon │ └── postgresql.conf ├── matrix │ └── log.config ├── privatebin │ └── conf.php ├── sso │ └── sso.data.coop.pem └── vhost ├── base_domain ├── docker_registry ├── element ├── mastodon ├── matrix ├── nextcloud └── www.base_domain templates ├── element │ └── config.json.j2 ├── mailu │ └── env.j2 ├── mastodon │ └── env.j2 ├── matrix │ └── homeserver.yaml.j2 ├── rallly │ └── env.j2 └── restic ├── ssh.config.j2 └── ssh.known_hosts.j2 ``` What do you think?
samsapti added the
Refactor
label 2023-07-09 18:31:55 +00:00
samsapti added 2 commits 2023-07-09 18:31:55 +00:00
valberg reviewed 2023-07-09 18:38:52 +00:00
@ -20,2 +19,3 @@
- name: Run byro
docker_compose:
project_name: "byro member system"
project_name: byro_member_system"
Owner

will this not break the deployment by creating a new stack with a new name?

will this not break the deployment by creating a new stack with a new name?
Author
Owner

It will, so we will need to take down the old containers first. However, I think it's better to have a project_name without spaces, as the containers are actually named byromembersystem_... if spaces are in the name. Naming with underscores better reflects what the container names will be.

It will, so we will need to take down the old containers first. However, I think it's better to have a `project_name` without spaces, as the containers are actually named `byromembersystem_...` if spaces are in the name. Naming with underscores better reflects what the container names will be.
Owner

if you want to do the work it's fine by me - I can live with the non-underscore name ;)

if you want to do the work it's fine by me - I can live with the non-underscore name ;)
Author
Owner

I can't XD

I'll do the work, no problem!

I can't XD I'll do the work, no problem!
samsapti marked this conversation as resolved
samsapti added 1 commit 2023-07-09 18:39:13 +00:00
valberg reviewed 2023-07-09 18:42:19 +00:00
@ -4,3 +4,2 @@
copy:
src: "files/configs/docker_registry/nginx.conf"
dest: "/docker-volumes/nginx/vhost/{{ services.docker_registry.domain }}"
src: vhost/docker
Owner

can we call this file docker_registry?

can we call this file docker_registry?
Author
Owner

My (undocumented) naming convention here is actually the subdomain the service is hosted on, so the docker registry's domain is docker.data.coop and the vhost file is docker (without .data.coop). But if you insist I can change it.

My (undocumented) naming convention here is actually the subdomain the service is hosted on, so the docker registry's domain is `docker.data.coop` and the vhost file is `docker` (without `.data.coop`). But if you insist I can change it.
Owner

can we have the full domain name as the name of the file then? the same with the other comments

can we have the full domain name as the name of the file then? the same with the other comments
Author
Owner

Then I would rather use the service name instead, just for the sake of avoiding code duplication (not hardcoding the base domain). What do you think?

Then I would rather use the service name instead, just for the sake of avoiding code duplication (not hardcoding the base domain). What do you think?
Owner

ah yes very good point! let's use the name of the service and not anything related to the domain name

ah yes very good point! let's use the name of the service and not anything related to the domain name
samsapti marked this conversation as resolved
valberg reviewed 2023-07-09 18:45:39 +00:00
@ -23,2 +23,2 @@
template:
src: files/configs/mastodon/vhost-mastodon
copy:
src: vhost/social
Owner

can we call this file mastodon ?

can we call this file mastodon ?
valberg marked this conversation as resolved
@ -4,2 +4,2 @@
template:
src: files/configs/nextcloud/vhost
copy:
src: vhost/cloud
Owner

can we call this file nextcloud ?

can we call this file nextcloud ?
valberg marked this conversation as resolved
samsapti added 1 commit 2023-07-09 19:08:54 +00:00
samsapti force-pushed move_stuff_around from f6061e1b5e to 7d13fc5302 2023-07-09 21:07:35 +00:00 Compare
Owner

@samsapti what's the reason that there are subfolders for each service in files/ but not in templates/?

(I like the idea of consistently having subfolders for each service, it scales better and the pattern is easier to enforce when it's simple to understand)

@samsapti what's the reason that there are subfolders for each service in `files/` but not in `templates/`? (I like the idea of consistently having subfolders for each service, it scales better and the pattern is easier to enforce when it's simple to understand)
Author
Owner

@samsapti what's the reason that there are subfolders for each service in files/ but not in templates/?

Ansible doesn't support it when it comes to referencing the files from a task. If you have subfolders in templates/, you need to reference it as templates/path/to/file.j2 instead of path/to/file.j2 in a template task. This is not the case with files/ in the copy task, subfolders work without the files/ prefix in file paths.

(I haven't actually verified this myself, that's just what I've seen online.)

> @samsapti what's the reason that there are subfolders for each service in `files/` but not in `templates/`? Ansible doesn't support it when it comes to referencing the files from a task. If you have subfolders in `templates/`, you need to reference it as `templates/path/to/file.j2` instead of `path/to/file.j2` in a `template` task. This is not the case with `files/` in the `copy` task, subfolders work without the `files/` prefix in file paths. (I haven't actually verified this myself, that's just what I've seen online.)
samsapti added 1 commit 2023-07-20 16:10:01 +00:00
Owner

@samsapti what's the reason that there are subfolders for each service in files/ but not in templates/?

Ansible doesn't support it when it comes to referencing the files from a task. If you have subfolders in templates/, you need to reference it as templates/path/to/file.j2 instead of path/to/file.j2 in a template task. This is not the case with files/ in the copy task, subfolders work without the files/ prefix in file paths.

(I haven't actually verified this myself, that's just what I've seen online.)

I just tested:

- name: test template
  template:
    src: testdir/test.j2
    dest: /tmp/test
    mode: 0644
  vars:
    foo: "bar"

with the template in docker/templates/testdir/test.j2 works as expected :)

So, I also think we should namespace templates. @samsapti when that is done you have an approve from me :)

> > @samsapti what's the reason that there are subfolders for each service in `files/` but not in `templates/`? > > Ansible doesn't support it when it comes to referencing the files from a task. If you have subfolders in `templates/`, you need to reference it as `templates/path/to/file.j2` instead of `path/to/file.j2` in a `template` task. This is not the case with `files/` in the `copy` task, subfolders work without the `files/` prefix in file paths. > > (I haven't actually verified this myself, that's just what I've seen online.) I just tested: ```yaml - name: test template template: src: testdir/test.j2 dest: /tmp/test mode: 0644 vars: foo: "bar" ``` with the template in `docker/templates/testdir/test.j2` works as expected :) So, I also think we should namespace templates. @samsapti when that is done you have an approve from me :)
samsapti added 1 commit 2023-08-05 17:36:05 +00:00
samsapti added 1 commit 2023-09-29 21:04:45 +00:00
samsapti merged commit 3098e1e320 into main 2023-09-29 21:09:08 +00:00
samsapti deleted branch move_stuff_around 2023-09-29 21:09:08 +00:00
Sign in to join this conversation.
No description provided.