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:
4
init.sh
4
init.sh
@@ -1,4 +0,0 @@
|
||||
git clone https://github.com/morten-olsen/configs.git ~/.configs/system
|
||||
cd ~/.configs/system
|
||||
make install
|
||||
./scripts/setup-local.sh
|
||||
@@ -11,11 +11,30 @@ android:
|
||||
ansible_port: 8022
|
||||
ansible_user: u0_a200
|
||||
desktops:
|
||||
vars:
|
||||
contexts:
|
||||
private:
|
||||
path: ~/Projects/private
|
||||
git:
|
||||
email: fbtijfdq@void.black
|
||||
name: Morten Olsen
|
||||
signing_key: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFaIAP/ZJ7+7jeR44e1yIJjfQAB6MN351LDKJAXVF62P
|
||||
replacements:
|
||||
- use: "ssh://git@giteaa.olsen.cloud:2202/"
|
||||
instead_of: "ssh://git@gitea.olsen.cloud:2202/"
|
||||
|
||||
zeronorth:
|
||||
path: ~/Projects/zeronorth
|
||||
env:
|
||||
NODE_AUTH_TOKEN: "op://jpksggxxmcuwnbwkooktr3iqcy/ut3yag6r7y4bsfrztahp7pcc6q/password"
|
||||
AWS_PROFILE: "zeronorth"
|
||||
git:
|
||||
email: morten.olsen@zeronorth.com
|
||||
name: Morten Olsen
|
||||
signing_key: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKDbZITpz5QrVIxPn9gKVWMPK+3W3YZZGszFOQvO/h7M
|
||||
hosts:
|
||||
zn-macbook:
|
||||
ansible_host: 192.168.3.3
|
||||
ansible_connection: ssh
|
||||
ansible_port: 22
|
||||
ansible_user: alice
|
||||
contexts:
|
||||
- zeronorth
|
||||
# ansible_host: 192.168.3.3
|
||||
# ansible_connection: ssh
|
||||
# ansible_port: 22
|
||||
# ansible_user: alice
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
- name: Setup host
|
||||
hosts: localhost
|
||||
vars:
|
||||
contexts: []
|
||||
contexts: {}
|
||||
roles:
|
||||
- role: env_terminal
|
||||
- role: env_develop
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
export TMPDIR="${TMPDIR:-/tmp}"
|
||||
export PATH="$PATH:$HOME/.local/bin"
|
||||
|
||||
alias ls=eza
|
||||
alias cat=bat
|
||||
alias grep=rg
|
||||
alias diff=delta
|
||||
alias less=bat
|
||||
alias gr='if [ "`git rev-parse --show-cdup`" != "" ]; then cd `git rev-parse --show-cdup`; fi'
|
||||
@@ -1,3 +0,0 @@
|
||||
---
|
||||
dependencies:
|
||||
- role: base_info
|
||||
@@ -1,39 +0,0 @@
|
||||
---
|
||||
- name: Copy config {{ context }}
|
||||
tags:
|
||||
- config
|
||||
ansible.builtin.file:
|
||||
mode: "{{ item.mode }}"
|
||||
path: "{{ home }}/{{ item.path }}"
|
||||
state: directory
|
||||
with_community.general.filetree:
|
||||
- ../files/{{ context }}
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
when: item.state == 'directory'
|
||||
|
||||
- name: "Copy templates : {{ context }}"
|
||||
tags:
|
||||
- config
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ home }}/{{ item.path | regex_replace('\\.j2$', '') }}"
|
||||
mode: "{{ item.mode }}"
|
||||
with_community.general.filetree:
|
||||
- ../templates/{{ context }}
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
when: item.state == 'file'
|
||||
|
||||
- name: Copy config {{ context }}
|
||||
tags:
|
||||
- config
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ home }}/{{ item.path }}"
|
||||
mode: "{{ item.mode }}"
|
||||
with_community.general.filetree:
|
||||
- ../files/{{ context }}
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
when: item.state == 'file'
|
||||
@@ -1,34 +0,0 @@
|
||||
---
|
||||
- name: "Unload vars : {{ context }}"
|
||||
ansible.builtin.include_vars: ../vars/empty.yml
|
||||
tags:
|
||||
- install
|
||||
|
||||
- name: "Load vars : {{ context }}"
|
||||
ansible.builtin.include_vars: "{{ item }}"
|
||||
tags:
|
||||
- install
|
||||
with_first_found:
|
||||
- files:
|
||||
- "{{ ansible_distribution }}-{{ ansible_distribution_release }}.yml"
|
||||
- "{{ ansible_distribution }}.yml"
|
||||
- "{{ ansible_os_family }}.yml"
|
||||
- default.yml
|
||||
paths: ../vars/{{ context }}
|
||||
skip: true
|
||||
|
||||
- name: "Install dependencies : {{ context }}"
|
||||
tags:
|
||||
- install
|
||||
when: terminal_pkgs
|
||||
become: "{{ install_with_root }}"
|
||||
ansible.builtin.package:
|
||||
name: "{{ terminal_pkgs }}"
|
||||
|
||||
- name: "Install casks : {{ context }}"
|
||||
tags:
|
||||
- install
|
||||
when: terminal_casks
|
||||
community.general.homebrew_cask:
|
||||
name: "{{ terminal_casks }}"
|
||||
state: installed
|
||||
@@ -1,16 +0,0 @@
|
||||
---
|
||||
- name: Install context dependencies
|
||||
ansible.builtin.include_tasks: install.yml
|
||||
loop: "{{ contexts }}"
|
||||
loop_control:
|
||||
loop_var: context
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: Configure contexts
|
||||
ansible.builtin.include_tasks: config.yml
|
||||
loop: "{{ contexts }}"
|
||||
loop_control:
|
||||
loop_var: context
|
||||
tags:
|
||||
- config
|
||||
@@ -1,14 +0,0 @@
|
||||
---
|
||||
terminal_pkgs:
|
||||
- bat
|
||||
- eza
|
||||
- direnv
|
||||
- fzf
|
||||
- gnupg
|
||||
- jq
|
||||
- ripgrep
|
||||
- neovim
|
||||
- gh
|
||||
- tmux
|
||||
- zoxide
|
||||
- sshpass
|
||||
@@ -1,4 +0,0 @@
|
||||
---
|
||||
terminal_pkgs: []
|
||||
terminal_casks: []
|
||||
terminal_flatpaks: []
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
terminal_pkgs:
|
||||
- terraform
|
||||
- awscli
|
||||
- copier
|
||||
@@ -1,8 +1,13 @@
|
||||
- name: Setting host facts
|
||||
- name: Setting generic facts
|
||||
tags: always
|
||||
ansible.builtin.set_fact:
|
||||
username: alice
|
||||
home: "{{ ansible_env.HOME }}"
|
||||
use_become: true
|
||||
mac_os: "{{ ansible_distribution == 'MacOSX' }}"
|
||||
contexts: "{{ ['default'] + (contexts | default([])) }}"
|
||||
|
||||
- name: Setting macos facts
|
||||
tags: always
|
||||
when: mac_os
|
||||
ansible.builtin.set_fact:
|
||||
install_with_root: false
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
install_with_root: true
|
||||
terminal_casks: []
|
||||
pkgs: []
|
||||
contexts: {}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
- name: Copy config {{ context }}
|
||||
- name: Setup directories
|
||||
tags:
|
||||
- config
|
||||
ansible.builtin.file:
|
||||
@@ -7,25 +7,12 @@
|
||||
path: "{{ home }}/{{ item.path }}"
|
||||
state: directory
|
||||
with_community.general.filetree:
|
||||
- ../files/{{ context }}
|
||||
- ../files/
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
when: item.state == 'directory'
|
||||
|
||||
- name: "Copy templates : {{ context }}"
|
||||
tags:
|
||||
- config
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ home }}/{{ item.path | regex_replace('\\.j2$', '') }}"
|
||||
mode: "{{ item.mode }}"
|
||||
with_community.general.filetree:
|
||||
- ../templates/{{ context }}
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
when: item.state == 'file'
|
||||
|
||||
- name: Copy config {{ context }}
|
||||
- name: Copy config
|
||||
tags:
|
||||
- config
|
||||
ansible.builtin.copy:
|
||||
@@ -33,7 +20,7 @@
|
||||
dest: "{{ home }}/{{ item.path }}"
|
||||
mode: "{{ item.mode }}"
|
||||
with_community.general.filetree:
|
||||
- ../files/{{ context }}
|
||||
- ../files
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
when: item.state == 'file'
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
ansible.builtin.package:
|
||||
name: "{{ terminal_pkgs }}"
|
||||
|
||||
- name: "Install casks : {{ context }}"
|
||||
- name: "Install casks"
|
||||
tags:
|
||||
- install
|
||||
when: terminal_casks
|
||||
|
||||
@@ -1,16 +1,22 @@
|
||||
---
|
||||
- name: Install context dependencies
|
||||
- name: Install dependencies
|
||||
ansible.builtin.include_tasks: install.yml
|
||||
loop: "{{ contexts }}"
|
||||
loop_control:
|
||||
loop_var: context
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: Configure contexts
|
||||
ansible.builtin.include_tasks: config.yml
|
||||
loop: "{{ contexts }}"
|
||||
loop_control:
|
||||
loop_var: context
|
||||
- name: Configure
|
||||
tags:
|
||||
- config
|
||||
ansible.builtin.include_tasks: config.yml
|
||||
|
||||
- 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 }}"
|
||||
|
||||
12
playbooks/roles/base_terminal/tasks/setup-context.yml
Normal file
12
playbooks/roles/base_terminal/tasks/setup-context.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
- name: Setup context env
|
||||
tags:
|
||||
- git
|
||||
- config
|
||||
ansible.builtin.template:
|
||||
src: "../templates/envrc.context.j2"
|
||||
dest: "{{ context.path }}/.envrc"
|
||||
mode: "600"
|
||||
vars:
|
||||
env: "{{ context.env}}"
|
||||
name: "{{ name }}"
|
||||
when: "'env' in context"
|
||||
4
playbooks/roles/base_terminal/templates/envrc.context.j2
Normal file
4
playbooks/roles/base_terminal/templates/envrc.context.j2
Normal file
@@ -0,0 +1,4 @@
|
||||
{% for key in env %}
|
||||
export {{ key }}="{{ env[key] }}"
|
||||
{% endfor %}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
host github-private
|
||||
hostname ssh.github.com
|
||||
user git
|
||||
port 443
|
||||
IdentityFile ~/.ssh/keys/github-private.pub
|
||||
IdentitiesOnly yes
|
||||
@@ -1 +0,0 @@
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFaIAP/ZJ7+7jeR44e1yIJjfQAB6MN351LDKJAXVF62P
|
||||
@@ -1,4 +0,0 @@
|
||||
export NPM_GITHUB_TOKEN="op://jpksggxxmcuwnbwkooktr3iqcy/ut3yag6r7y4bsfrztahp7pcc6q/password"
|
||||
export NODE_AUTH_TOKEN=$NPM_GITHUB_TOKEN
|
||||
export GITHUB_TOKEN=$NPM_GITHUB_TOKEN
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
[user]
|
||||
email = morten@olsen.pro
|
||||
name = Morten Olsen
|
||||
signingkey = ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFaIAP/ZJ7+7jeR44e1yIJjfQAB6MN351LDKJAXVF62P
|
||||
|
||||
[url "git@github-private:morten-olsen/"]
|
||||
insteadOf = https://github.com/morten-olsen/
|
||||
|
||||
[url "ssh://git@giteaa.olsen.cloud:2202/"]
|
||||
insteadOf = ssh://git@gitea.olsen.cloud:2202/
|
||||
@@ -1,3 +0,0 @@
|
||||
@morten-olsen:registry=https://npm.pkg.github.com
|
||||
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
host github-zeronorth
|
||||
hostname ssh.github.com
|
||||
user git
|
||||
port 443
|
||||
IdentityFile ~/.ssh/keys/github-zeronorth.pub
|
||||
IdentitiesOnly yes
|
||||
@@ -1 +0,0 @@
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKDbZITpz5QrVIxPn9gKVWMPK+3W3YZZGszFOQvO/h7M
|
||||
@@ -1,4 +0,0 @@
|
||||
export NPM_GITHUB_TOKEN="op://jpksggxxmcuwnbwkooktr3iqcy/ut3yag6r7y4bsfrztahp7pcc6q/password"
|
||||
export NODE_AUTH_TOKEN=$NPM_GITHUB_TOKEN
|
||||
export GITHUB_TOKEN="op://Employee/lobazchngpvla4opw4rwzjwnoi/credential"
|
||||
export AWS_PROFILE="zeronorth"
|
||||
@@ -1,7 +0,0 @@
|
||||
[user]
|
||||
email = morten.olsen@zeronorth.com
|
||||
name = Morten Olsen
|
||||
signingkey = ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKDbZITpz5QrVIxPn9gKVWMPK+3W3YZZGszFOQvO/h7M
|
||||
|
||||
[url "git@github-zeronorth:"]
|
||||
insteadOf = https://github.com/
|
||||
@@ -1,2 +0,0 @@
|
||||
@0north:registry=https://npm.pkg.github.com
|
||||
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
|
||||
@@ -1,39 +0,0 @@
|
||||
---
|
||||
- name: Copy config {{ context }}
|
||||
tags:
|
||||
- config
|
||||
ansible.builtin.file:
|
||||
mode: "{{ item.mode }}"
|
||||
path: "{{ home }}/{{ item.path }}"
|
||||
state: directory
|
||||
with_community.general.filetree:
|
||||
- ../files/{{ context }}
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
when: item.state == 'directory'
|
||||
|
||||
- name: "Copy templates : {{ context }}"
|
||||
tags:
|
||||
- config
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ home }}/{{ item.path | regex_replace('\\.j2$', '') }}"
|
||||
mode: "{{ item.mode }}"
|
||||
with_community.general.filetree:
|
||||
- ../templates/{{ context }}
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
when: item.state == 'file'
|
||||
|
||||
- name: Copy config {{ context }}
|
||||
tags:
|
||||
- config
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ home }}/{{ item.path }}"
|
||||
mode: "{{ item.mode }}"
|
||||
with_community.general.filetree:
|
||||
- ../files/{{ context }}
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
when: item.state == 'file'
|
||||
@@ -1,33 +0,0 @@
|
||||
---
|
||||
- name: "Unload vars : {{ context }}"
|
||||
ansible.builtin.include_vars: ../vars/empty.yml
|
||||
tags:
|
||||
- install
|
||||
|
||||
- name: "Load vars : {{ context }}"
|
||||
ansible.builtin.include_vars: "{{ item }}"
|
||||
tags:
|
||||
- install
|
||||
with_first_found:
|
||||
- files:
|
||||
- "{{ ansible_distribution }}-{{ ansible_distribution_release }}.yml"
|
||||
- "{{ ansible_distribution }}.yml"
|
||||
- "{{ ansible_os_family }}.yml"
|
||||
- default.yml
|
||||
paths: ../vars/{{ context }}
|
||||
skip: true
|
||||
|
||||
- name: "Install dependencies : {{ context }}"
|
||||
tags:
|
||||
- install
|
||||
when: terminal_pkgs
|
||||
ansible.builtin.package:
|
||||
name: "{{ terminal_pkgs }}"
|
||||
|
||||
- name: "Install casks : {{ context }}"
|
||||
tags:
|
||||
- install
|
||||
when: terminal_casks
|
||||
community.general.homebrew_cask:
|
||||
name: "{{ terminal_casks }}"
|
||||
state: installed
|
||||
@@ -1,22 +1,28 @@
|
||||
---
|
||||
- name: Install context dependencies
|
||||
ansible.builtin.include_tasks: install.yml
|
||||
loop: "{{ contexts }}"
|
||||
loop_control:
|
||||
loop_var: context
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: Install atuin
|
||||
- name: "Load vars"
|
||||
ansible.builtin.include_vars: "{{ item }}"
|
||||
tags:
|
||||
- install
|
||||
ansible.builtin.include_role:
|
||||
name: software_atuin
|
||||
with_first_found:
|
||||
- files:
|
||||
- "{{ ansible_distribution }}-{{ ansible_distribution_release }}.yml"
|
||||
- "{{ ansible_distribution }}.yml"
|
||||
- "{{ ansible_os_family }}.yml"
|
||||
- default.yml
|
||||
paths: ../vars
|
||||
skip: true
|
||||
|
||||
- name: Configure contexts
|
||||
ansible.builtin.include_tasks: config.yml
|
||||
loop: "{{ contexts }}"
|
||||
loop_control:
|
||||
loop_var: context
|
||||
- name: "Install dependencies"
|
||||
tags:
|
||||
- config
|
||||
- install
|
||||
when: terminal_pkgs
|
||||
ansible.builtin.package:
|
||||
name: "{{ terminal_pkgs }}"
|
||||
|
||||
- name: "Install casks"
|
||||
tags:
|
||||
- install
|
||||
when: terminal_casks
|
||||
community.general.homebrew_cask:
|
||||
name: "{{ terminal_casks }}"
|
||||
state: installed
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
---
|
||||
terminal_pkgs: []
|
||||
terminal_casks: []
|
||||
terminal_flatpaks: []
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
terminal_pkgs:
|
||||
- terraform
|
||||
- awscli
|
||||
- copier
|
||||
@@ -22,9 +22,10 @@
|
||||
- name: Ensure dir
|
||||
tags: always
|
||||
ansible.builtin.file:
|
||||
path: "{{ home }}/.scripts"
|
||||
path: "{{ home }}/.local/bin"
|
||||
mode: "0755"
|
||||
state: directory
|
||||
|
||||
- name: Move bin
|
||||
tags: always
|
||||
ansible.builtin.copy:
|
||||
@@ -33,6 +34,12 @@
|
||||
src: "{{ software_atuin_unpack_file }}"
|
||||
dest: "{{ home }}/.local/bin/atuin"
|
||||
|
||||
- name: Cleanup
|
||||
tags: always
|
||||
ansible.builtin.file:
|
||||
path: "{{ software_atuin_unpack_file }}"
|
||||
state: absent
|
||||
|
||||
- name: Setup config dirctories
|
||||
tags:
|
||||
- config
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
install_with_root: true
|
||||
contexts: {}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
---
|
||||
dependencies:
|
||||
- role: base_info
|
||||
- role: base_terminal
|
||||
- role: software_ssh
|
||||
|
||||
@@ -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"
|
||||
28
playbooks/roles/software_git/templates/gitconfig.context.j2
Normal file
28
playbooks/roles/software_git/templates/gitconfig.context.j2
Normal file
@@ -0,0 +1,28 @@
|
||||
[user]
|
||||
email = {{ git.email }}
|
||||
name = {{ git.name }}
|
||||
{% if 'signing_key' in git %}
|
||||
signingkey = {{ git.signing_key }}
|
||||
|
||||
[commit]
|
||||
gpgsign = true
|
||||
|
||||
[gpg]
|
||||
format = ssh
|
||||
|
||||
[gpg "ssh"]
|
||||
program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign"
|
||||
{% endif %}
|
||||
|
||||
{% if 'replacements' in git %}
|
||||
{% for replacement in git.replacements %}
|
||||
|
||||
[url "{{ replacement.use }}"]
|
||||
insteadOf = "{{ replacement.instead_of }}"
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
[url "git@github-{{name}}:"]
|
||||
insteadOf = https://github.com/
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
[gpg]
|
||||
format = ssh
|
||||
|
||||
[gpg "ssh"]
|
||||
program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign"
|
||||
|
||||
[alias]
|
||||
graph = log --graph --color --pretty=format:"%C(yellow)%H%C(green)%d%C(reset)%n%x20%cd%n%x20%cn%C(blue)%x20(%ce)%x20%C(cyan)[gpg:%GK%x20%G?]%C(reset)%n%x20%s%n"
|
||||
@@ -20,8 +15,6 @@
|
||||
|
||||
[difftool "nvimdiff"]
|
||||
cmd = "nvim -d \"$LOCAL\" \"$REMOTE\""
|
||||
[commit]
|
||||
gpgsign = true
|
||||
[url "https://"]
|
||||
insteadOf = git://
|
||||
|
||||
@@ -43,11 +36,13 @@
|
||||
process = git-lfs filter-process
|
||||
required = true
|
||||
|
||||
[includeIf "gitdir:~/Projects/zeronorth/"]
|
||||
path = ~/Projects/zeronorth/.gitconfig
|
||||
|
||||
[includeIf "gitdir:~/Projects/private/"]
|
||||
path = ~/Projects/private/.gitconfig
|
||||
[push]
|
||||
autoSetupRemote = true
|
||||
|
||||
{% for key in contexts %}
|
||||
{% if 'git' in contexts[key] %}
|
||||
[includeIf "gitdir:{{ contexts[key].path }}/"]
|
||||
path = {{ contexts[key].path }}/.gitconfig
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
host github-{{ name }}
|
||||
hostname ssh.github.com
|
||||
user git
|
||||
port 443
|
||||
IdentityFile ~/.ssh/keys/github-{{ name }}.pub
|
||||
IdentitiesOnly yes
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
- name: Setup config dirctories
|
||||
tags:
|
||||
- nvim
|
||||
- config
|
||||
ansible.builtin.file:
|
||||
mode: "{{ item.mode }}"
|
||||
@@ -22,6 +23,7 @@
|
||||
|
||||
- name: Copy config {{ context }}
|
||||
tags:
|
||||
- nvim
|
||||
- config
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item.src }}"
|
||||
@@ -39,12 +41,30 @@
|
||||
- nvim
|
||||
ansible.builtin.git:
|
||||
repo: https://github.com/morten-olsen/nvim
|
||||
dest: "{{ home }}/.config/nvim"
|
||||
dest: "{{ home }}/Projects/private/nvim"
|
||||
accept_newhostkey: true
|
||||
clone: true
|
||||
update: true
|
||||
force: true
|
||||
|
||||
- name: Ensure dir
|
||||
tags:
|
||||
- config
|
||||
- nvim
|
||||
ansible.builtin.file:
|
||||
path: "{{ home }}/.config"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
|
||||
- name: Setup nvim link
|
||||
tags:
|
||||
- config
|
||||
- nvim
|
||||
ansible.builtin.file:
|
||||
src: "{{ home }}/Projects/private/nvim"
|
||||
dest: "{{ home }}/.config/nvim"
|
||||
state: link
|
||||
|
||||
- name: Prepare neovim
|
||||
tags:
|
||||
- config
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
- name: Copy config
|
||||
tags:
|
||||
- git
|
||||
- config
|
||||
ansible.builtin.file:
|
||||
mode: "{{ item.mode }}"
|
||||
path: "{{ home }}/{{ item.path }}"
|
||||
state: directory
|
||||
with_community.general.filetree:
|
||||
- ../files
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
when: item.state == 'directory'
|
||||
|
||||
- name: "Copy configs"
|
||||
tags:
|
||||
- git
|
||||
- config
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ home }}/{{ item.path }}"
|
||||
mode: "{{ item.mode }}"
|
||||
with_community.general.filetree:
|
||||
- ../files
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
when: item.state == 'file'
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
- role: env_terminal
|
||||
- role: env_develop
|
||||
- role: server_ssh
|
||||
- role: env_desktop
|
||||
# - role: env_desktop
|
||||
|
||||
- name: Setup android
|
||||
hosts: android
|
||||
|
||||
@@ -12,8 +12,8 @@ fi
|
||||
echo "Setting up $MACHINE_NAME"
|
||||
ansible-playbook -i inventory.yml playbooks/setup.yml \
|
||||
--extra-vars "ansible_python_interpreter=$(which python)" \
|
||||
--connection=local \
|
||||
--inventory "$MACHINE_NAME," \
|
||||
--limit "$MACHINE_NAME" \
|
||||
$@ \
|
||||
--ask-become-pass
|
||||
$@
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ fi
|
||||
|
||||
echo "Setting up $MACHINE_NAME"
|
||||
ansible-playbook -i inventory.yml playbooks/setup.yml \
|
||||
--connection=local \
|
||||
--inventory "$MACHINE_NAME," \
|
||||
--limit "$MACHINE_NAME" \
|
||||
$@ \
|
||||
|
||||
Reference in New Issue
Block a user