From 6bb920717715b66a0f432f2d7eafb523da9543bd Mon Sep 17 00:00:00 2001 From: Mikel Larreategi Date: Wed, 9 Oct 2024 18:22:41 +0200 Subject: [PATCH] do not hard-code the created username to plone, use the one set in the .env file (#64) * do not hard-code the created username to plone, use the one set in the .env file * set default value for the DEPLOY_USER * use an environment var for the deploy_folder * adjust for tests * fix * fix name * this is not an ansible template --- project/cookiecutter.json | 5 ++++- project/{{ cookiecutter.__folder_name }}/devops/.env_dist | 1 + .../devops/inventory/group_vars/all/projects.yml | 2 +- .../devops/inventory/group_vars/all/users.yml | 2 +- .../devops/stacks/{{ cookiecutter.hostname }}.yml | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/project/cookiecutter.json b/project/cookiecutter.json index 126c435..00834bf 100644 --- a/project/cookiecutter.json +++ b/project/cookiecutter.json @@ -116,7 +116,10 @@ "devops/etc", "devops/playbooks", "devops/requirements", - "devops/tasks" + "devops/tasks", + "devops/inventory/group_vars/all/users.yml", + "devops/inventory/group_vars/all/projects.yml" + ], "_extensions": [ "cookieplone.filters.use_prerelease_versions", diff --git a/project/{{ cookiecutter.__folder_name }}/devops/.env_dist b/project/{{ cookiecutter.__folder_name }}/devops/.env_dist index 9a6b793..0f5b59e 100644 --- a/project/{{ cookiecutter.__folder_name }}/devops/.env_dist +++ b/project/{{ cookiecutter.__folder_name }}/devops/.env_dist @@ -2,5 +2,6 @@ DEPLOY_ENV=prod DEPLOY_HOST={{ cookiecutter.hostname }} DEPLOY_PORT=22 DEPLOY_USER=plone +DEPLOY_FOLDER=/srv/{{ cookiecutter.project_slug }}/data DOCKER_CONFIG=.docker STACK_NAME={{ cookiecutter.__devops_stack_name }} diff --git a/project/{{ cookiecutter.__folder_name }}/devops/inventory/group_vars/all/projects.yml b/project/{{ cookiecutter.__folder_name }}/devops/inventory/group_vars/all/projects.yml index cb026fa..d999251 100644 --- a/project/{{ cookiecutter.__folder_name }}/devops/inventory/group_vars/all/projects.yml +++ b/project/{{ cookiecutter.__folder_name }}/devops/inventory/group_vars/all/projects.yml @@ -1,7 +1,7 @@ --- project_folders: # Path to store {{ cookiecutter.hostname }} postgres data - - path: "/srv/{{ cookiecutter.project_slug }}/data" + path: "{{ lookup('ansible.builtin.env', 'DEPLOY_FOLDER', default='/srv/plone/data') }}" owner: 999 group: 999 mode: "0750" diff --git a/project/{{ cookiecutter.__folder_name }}/devops/inventory/group_vars/all/users.yml b/project/{{ cookiecutter.__folder_name }}/devops/inventory/group_vars/all/users.yml index 446e5cd..43026eb 100644 --- a/project/{{ cookiecutter.__folder_name }}/devops/inventory/group_vars/all/users.yml +++ b/project/{{ cookiecutter.__folder_name }}/devops/inventory/group_vars/all/users.yml @@ -1,6 +1,6 @@ --- users: default: - name: plone + name: "{{ lookup('ansible.builtin.env', 'DEPLOY_USER', default='plone') }}" group: sudo additional_keys: [] diff --git a/project/{{ cookiecutter.__folder_name }}/devops/stacks/{{ cookiecutter.hostname }}.yml b/project/{{ cookiecutter.__folder_name }}/devops/stacks/{{ cookiecutter.hostname }}.yml index fd51100..d6e8c00 100644 --- a/project/{{ cookiecutter.__folder_name }}/devops/stacks/{{ cookiecutter.hostname }}.yml +++ b/project/{{ cookiecutter.__folder_name }}/devops/stacks/{{ cookiecutter.hostname }}.yml @@ -246,7 +246,7 @@ volumes: vol-site-data: driver_opts: type: none - device: /srv/{{ cookiecutter.project_slug }}/data + device: "${DEPLOY_FOLDER:/srv/{{ cookiecutter.project_slug }}/data}" o: bind networks: