From f1c103c1579994dca61c37c73890bc61c3119d39 Mon Sep 17 00:00:00 2001 From: Morten Olsen Date: Wed, 9 Oct 2024 21:52:49 +0200 Subject: [PATCH] fix --- inventory.yml | 4 +-- playbooks/Projects/zeronorth/.envrc | 3 +++ .../software_git/tasks/setup-context.yml | 26 +++++++++---------- .../roles/software_git/templates/gitconfig.j2 | 4 +-- 4 files changed, 20 insertions(+), 17 deletions(-) create mode 100644 playbooks/Projects/zeronorth/.envrc diff --git a/inventory.yml b/inventory.yml index 777f7d6..0e17fdc 100644 --- a/inventory.yml +++ b/inventory.yml @@ -14,7 +14,7 @@ desktops: vars: contexts: private: - path: ~/Projects/private + path: Projects/private git: email: fbtijfdq@void.black name: Morten Olsen @@ -24,7 +24,7 @@ desktops: instead_of: "ssh://git@gitea.olsen.cloud:2202/" zeronorth: - path: ~/Projects/zeronorth + path: Projects/zeronorth env: NODE_AUTH_TOKEN: "op://jpksggxxmcuwnbwkooktr3iqcy/ut3yag6r7y4bsfrztahp7pcc6q/password" AWS_PROFILE: "zeronorth" diff --git a/playbooks/Projects/zeronorth/.envrc b/playbooks/Projects/zeronorth/.envrc new file mode 100644 index 0000000..959c236 --- /dev/null +++ b/playbooks/Projects/zeronorth/.envrc @@ -0,0 +1,3 @@ +export NODE_AUTH_TOKEN="op://jpksggxxmcuwnbwkooktr3iqcy/ut3yag6r7y4bsfrztahp7pcc6q/password" +export AWS_PROFILE="zeronorth" + diff --git a/playbooks/roles/software_git/tasks/setup-context.yml b/playbooks/roles/software_git/tasks/setup-context.yml index 3ff2ae0..8d6a1b9 100644 --- a/playbooks/roles/software_git/tasks/setup-context.yml +++ b/playbooks/roles/software_git/tasks/setup-context.yml @@ -1,3 +1,14 @@ +- name: Ensure dir + tags: + - git + - config + become: "{{ use_become }}" + ansible.builtin.file: + path: "{{ home }}/{{ context.path }}" + state: directory + owner: "{{ username }}" + mode: "0700" + - name: Setup context git config tags: - git @@ -5,7 +16,7 @@ become: "{{ use_become }}" ansible.builtin.template: src: "../templates/gitconfig.context.j2" - dest: "{{ context.path }}/.gitconfig" + dest: "{{ home }}/{{ context.path }}/.gitconfig" owner: "{{ username }}" mode: "644" vars: @@ -13,17 +24,6 @@ name: "{{ name }}" when: "'git' in context" -- name: Ensure dir - tags: - - git - - config - become: "{{ use_become }}" - ansible.builtin.file: - path: "{{ context.path }}" - state: directory - owner: "{{ username }}" - mode: "0700" - - name: Setup context ssh config tags: - git @@ -58,5 +58,5 @@ content: "{{ context.git.signing_key }}" dest: "{{ home }}/.ssh/keys/github-{{ name }}.pub" owner: "{{ username }}" - mode: "0644" + mode: "0600" when: "'git' in context and 'signing_key' in context.git" diff --git a/playbooks/roles/software_git/templates/gitconfig.j2 b/playbooks/roles/software_git/templates/gitconfig.j2 index 66accb1..bd93130 100644 --- a/playbooks/roles/software_git/templates/gitconfig.j2 +++ b/playbooks/roles/software_git/templates/gitconfig.j2 @@ -41,8 +41,8 @@ {% for key in contexts %} {% if 'git' in contexts[key] %} -[includeIf "gitdir:{{ contexts[key].path }}/"] - path = {{ contexts[key].path }}/.gitconfig +[includeIf "gitdir:{{ home }}/{{ contexts[key].path }}/"] + path = "{{ home }}/{{ contexts[key].path }}/.gitconfig" {% endif %} {% endfor %}