Add option to use https/ssh git repositories

This commit is contained in:
Przemek Grondek 2024-05-10 20:29:51 +02:00
parent 0d13709bb0
commit 8df370f630
9 changed files with 31 additions and 16 deletions

View File

@ -22,3 +22,14 @@
vars: vars:
desktop_src_dir: "{{ ansible_user_dir }}/src/desktop" desktop_src_dir: "{{ ansible_user_dir }}/src/desktop"
arch_src_dir: "{{ ansible_user_dir }}/src/arch" arch_src_dir: "{{ ansible_user_dir }}/src/arch"
git_repos:
ssh:
dwm: ssh://git@git.grondek.dev:2222/pgrondek/dwm.git
dotfiles: ssh://git@git.grondek.dev:2222/pgrondek/dotfiles.git
polybar: ssh://git@git.grondek.dev:2222/pgrondek/polybar-dwm.git
st: ssh://git@git.grondek.dev:2222/pgrondek/stterm.git
https:
dwm: https://git.grondek.dev/pgrondek/dwm.git
dotfiles: https://git.grondek.dev/pgrondek/dotfiles.git
polybar: https://git.grondek.dev/pgrondek/polybar-dwm.git
st: https://git.grondek.dev/pgrondek/stterm.git

View File

@ -1,7 +1,7 @@
--- ---
- name: checkout dotfiles - name: checkout dotfiles
git: git:
repo: "{{ dotfiles.repo }}" repo: "{{ git.dotfiles }}"
dest: "{{ desktop_src_dir }}/dotfiles" dest: "{{ desktop_src_dir }}/dotfiles"
clone: yes clone: yes
update: yes update: yes

View File

@ -1,3 +0,0 @@
---
dotfiles:
repo: ssh://git@git.grondek.dev:2222/pgrondek/dotfiles.git

View File

@ -29,7 +29,7 @@
- name: checkout dwm - name: checkout dwm
git: git:
repo: "{{ dwm.repo }}" repo: "{{ git.dwm }}"
dest: "{{ desktop_src_dir }}/dwm" dest: "{{ desktop_src_dir }}/dwm"
clone: yes clone: yes
update: yes update: yes

View File

@ -46,7 +46,7 @@
- name: "polybar: checkout" - name: "polybar: checkout"
git: git:
repo: "{{ polybar.repo }}" repo: "{{ git.polybar }}"
dest: "{{ desktop_src_dir }}/polybar" dest: "{{ desktop_src_dir }}/polybar"
clone: yes clone: yes
update: yes update: yes

View File

@ -25,7 +25,7 @@
- name: checkout st - name: checkout st
git: git:
repo: "{{ st.repo }}" repo: "{{ git.st }}"
dest: "{{ desktop_src_dir }}/stterm" dest: "{{ desktop_src_dir }}/stterm"
clone: yes clone: yes
update: yes update: yes

View File

@ -1,9 +0,0 @@
---
dwm:
repo: ssh://git@git.grondek.dev:2222/pgrondek/dwm.git
st:
repo: ssh://git@git.grondek.dev:2222/pgrondek/stterm.git
dwmstatus:
repo: https://git.grondek.dev/pgrondek/dwmstatus.git
polybar:
repo: ssh://git@git.grondek.dev:2222/pgrondek/polybar-dwm.git

View File

@ -0,0 +1,14 @@
- name: Check if ssh keys exists
stat:
path: "{{ ansible_user_dir }}/.ssh/id_rsa"
register: ssh_key
- name: Use SSH repositories
set_fact:
git: "{{ git_repos.ssh }}"
when: ssh_key.stat.exists
- name: Use HTTPS repositories
set_fact:
git: "{{ git_repos.https }}"
when: not ssh_key.stat.exists

View File

@ -4,3 +4,5 @@
- import_tasks: arch.yml - import_tasks: arch.yml
when: ansible_distribution == "Archlinux" when: ansible_distribution == "Archlinux"
- import_tasks: git-repos.yml