mirror of
https://github.com/morten-olsen/configs.git
synced 2026-02-08 00:46:24 +01:00
improved context system
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
---
|
||||
- name: Install dependencies
|
||||
tags:
|
||||
- git
|
||||
- install
|
||||
become: "{{ install_with_root }}"
|
||||
ansible.builtin.package:
|
||||
@@ -10,6 +11,7 @@
|
||||
|
||||
- name: Copy config
|
||||
tags:
|
||||
- git
|
||||
- config
|
||||
ansible.builtin.file:
|
||||
mode: "{{ item.mode }}"
|
||||
@@ -21,21 +23,9 @@
|
||||
label: "{{ item.path }}"
|
||||
when: item.state == 'directory'
|
||||
|
||||
- name: "Copy templates"
|
||||
tags:
|
||||
- config
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ home }}/{{ item.path | regex_replace('\\.j2$', '') }}"
|
||||
mode: "{{ item.mode }}"
|
||||
with_community.general.filetree:
|
||||
- ../templates
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
when: item.state == 'file'
|
||||
|
||||
- name: Copy config
|
||||
- name: "Copy configs"
|
||||
tags:
|
||||
- git
|
||||
- config
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item.src }}"
|
||||
@@ -46,3 +36,24 @@
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
when: item.state == 'file'
|
||||
|
||||
- name: Setup config
|
||||
tags:
|
||||
- git
|
||||
- config
|
||||
ansible.builtin.template:
|
||||
src: "../templates/gitconfig.j2"
|
||||
dest: "{{ home }}/.gitconfig"
|
||||
mode: "644"
|
||||
|
||||
- name: Setup contexts
|
||||
tags:
|
||||
- git
|
||||
- config
|
||||
include_tasks: "setup-context.yml"
|
||||
vars:
|
||||
name: "{{ item.key }}"
|
||||
context: "{{ item.value }}"
|
||||
loop: "{{ contexts | dict2items }}"
|
||||
loop_control:
|
||||
label: "{{ item.key }}"
|
||||
|
||||
43
playbooks/roles/software_git/tasks/setup-context.yml
Normal file
43
playbooks/roles/software_git/tasks/setup-context.yml
Normal file
@@ -0,0 +1,43 @@
|
||||
- name: Setup context git config
|
||||
tags:
|
||||
- git
|
||||
- config
|
||||
ansible.builtin.template:
|
||||
src: "../templates/gitconfig.context.j2"
|
||||
dest: "{{ context.path }}/.gitconfig"
|
||||
mode: "644"
|
||||
vars:
|
||||
git: "{{ context.git }}"
|
||||
name: "{{ name }}"
|
||||
when: "'git' in context"
|
||||
|
||||
- name: Setup context ssh config
|
||||
tags:
|
||||
- git
|
||||
- config
|
||||
ansible.builtin.template:
|
||||
src: "../templates/sshconfig.context.j2"
|
||||
dest: "{{ home }}/.ssh/config.d/git-{{ name }}"
|
||||
mode: "644"
|
||||
vars:
|
||||
name: "{{ name }}"
|
||||
when: "'git' in context and 'signing_key' in context.git"
|
||||
|
||||
- name: Ensure dir
|
||||
tags:
|
||||
- git
|
||||
- config
|
||||
ansible.builtin.file:
|
||||
path: "{{ home }}/.ssh/keys"
|
||||
state: directory
|
||||
mode: "0700"
|
||||
|
||||
- name: Setup context public key
|
||||
tags:
|
||||
- git
|
||||
- config
|
||||
ansible.builtin.copy:
|
||||
content: "{{ context.git.signing_key }}"
|
||||
dest: "{{ home }}/.ssh/keys/github-{{ name }}.pub"
|
||||
mode: "0644"
|
||||
when: "'git' in context and 'signing_key' in context.git"
|
||||
Reference in New Issue
Block a user