97 lines
2.3 KiB
YAML
97 lines
2.3 KiB
YAML
---
|
|
- name: add ssh hostkey for git into global ssh_known_hosts
|
|
lineinfile:
|
|
path: /etc/ssh/ssh_known_hosts
|
|
line: "{{ item.key }}"
|
|
create: true
|
|
loop_control:
|
|
label: "{{ item.name }}"
|
|
with_items:
|
|
- key: "{{ github_hostkey }}"
|
|
name: github
|
|
- key: "{{ sudo_hostkey }}"
|
|
name: sudo.is
|
|
|
|
- name: create dir structure
|
|
file:
|
|
path: "{{ dotfiles_path }}"
|
|
state: directory
|
|
mode: 0750
|
|
owner: "{{ myusername }}"
|
|
group: "{{ myusername }}"
|
|
|
|
- name: pull my dotfiles repo
|
|
git:
|
|
repo: "{{ dotfiles_repo }}"
|
|
dest: "{{ dotfiles_path }}/dotfiles"
|
|
version: main
|
|
clone: true
|
|
update: true
|
|
force: true
|
|
no_log: true
|
|
become_user: "{{ myusername }}"
|
|
register: gitpull
|
|
|
|
- name: check if the dotfiles repo is managed in ~/projects/dotfiles
|
|
stat:
|
|
path: "~{{ myusername }}/projects/dotfiles"
|
|
register: projects_dotfiles
|
|
|
|
- name: check if the dotfiles are managed by yadm
|
|
stat:
|
|
path: "~/.local/share/yadm/repo.git/"
|
|
register: yadm_dotfiles
|
|
|
|
- name: put my dotfiles in place if dotfiles repo isnt human-managed
|
|
copy:
|
|
remote_src: true
|
|
src: "{{ dotfiles_path }}/dotfiles/{{ item.src }}"
|
|
dest: "~/{{ item.dest }}"
|
|
with_items:
|
|
- "{{ dotfiles }}"
|
|
become_user: "{{ myusername }}"
|
|
loop_control:
|
|
label: "{{ item.dest }}"
|
|
when:
|
|
- not (yadm_dotfiles.stat.exists or projects_dotfiles.stat.exists)
|
|
|
|
- name: clone ohmyzsh if not human-managed
|
|
git:
|
|
repo: "https://github.com/ohmyzsh/ohmyzsh"
|
|
dest: "~/.local/share/ohmyzsh"
|
|
clone: true
|
|
update: false
|
|
force: true
|
|
no_log: true
|
|
become_user: "{{ myusername }}"
|
|
when:
|
|
- not (yadm_dotfiles.stat.exists or projects_dotfiles.stat.exists)
|
|
|
|
- name: put dotfiles for root in place
|
|
copy:
|
|
remote_src: true
|
|
src: "{{ dotfiles_path }}/dotfiles/{{ item.src }}"
|
|
dest: "/root/{{ item.dest }}"
|
|
owner: root
|
|
group: root
|
|
no_log: true
|
|
loop_control:
|
|
label: "{{ item.dest }}"
|
|
with_items:
|
|
- "{{ dotfiles }}"
|
|
when:
|
|
- gitpull.changed
|
|
- item.root|bool
|
|
|
|
- name: rm outdated dotfile links
|
|
file:
|
|
path: "~/{{ item }}"
|
|
state: absent
|
|
loop_control:
|
|
label: "{{ item }}"
|
|
become_user: "{{ myusername }}"
|
|
with_items:
|
|
- "{{ dotfiles_rm }}"
|
|
when:
|
|
- not (yadm_dotfiles.stat.exists or projects_dotfiles.stat.exists)
|