78 lines
1.7 KiB
YAML
78 lines
1.7 KiB
YAML
---
|
|
- name: add ssh hostkey for git into global ssh_known_hosts
|
|
lineinfile:
|
|
path: /etc/ssh/ssh_known_hosts
|
|
line: "{{ item.key }}"
|
|
create: yes
|
|
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
|
|
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: put my dotfiles in place if dotfiles repo isnt human-managed
|
|
copy:
|
|
remote_src: yes
|
|
src: "{{ dotfiles_path }}/dotfiles/{{ item.src }}"
|
|
dest: "~/{{ item.dest }}"
|
|
with_items:
|
|
- "{{ dotfiles }}"
|
|
become_user: "{{ myusername }}"
|
|
loop_control:
|
|
label: "{{ item.dest }}"
|
|
when:
|
|
- gitpull.changed
|
|
- not projects_dotfiles.stat.exists
|
|
|
|
- name: put dotfiles for root in place
|
|
copy:
|
|
remote_src: yes
|
|
src: "{{ dotfiles_path }}/dotfiles/{{ item.src }}"
|
|
dest: "/root/{{ item.dest }}"
|
|
owner: root
|
|
group: root
|
|
loop_control:
|
|
label: "{{ item.dest }}"
|
|
with_items:
|
|
- "{{ dotfiles }}"
|
|
when:
|
|
- gitpull.changed
|
|
- item.root|bool
|
|
|
|
- name: rm dotfiles that root should not have
|
|
file:
|
|
path: "/root/{{ item.dest }}"
|
|
state: absent
|
|
loop_control:
|
|
label: "{{ item.dest }}"
|
|
with_items:
|
|
- "{{ dotfiles }}"
|
|
when:
|
|
- not item.root|bool
|