---

- name: MY USER | dotfiles
  become: yes
  ansible.builtin.copy:
    src: "{{ item }}"
    dest: "/home/{{ my_user }}/.{{ item | basename }}"
    mode: 0640
    owner: "{{ my_user }}"
    group: "{{ my_user }}"
  with_fileglob:
    files/dotfiles/*
  loop_control:
    label: "{{ item | basename }}"

- name: MY USER | Set ZSH for shell
  become: no
  ansible.builtin.user:
    name: "{{ my_user }}"
    shell: /bin/zsh
    state: present

- name: MY USER | Git directory presence
  become: yes
  when: inventory_hostname in groups.station
  ansible.builtin.file:
    group: "{{ my_user }}"
    mode: '0750'
    owner: "{{ my_user }}"
    path: "/home/{{ my_user }}/git"
    state: directory

- name: INCLUDE_VARS | git
  ansible.builtin.include_vars: "vars/git.yml"

- name: MY USER | Clone git repos
  become: yes
  when: inventory_hostname in groups.station
  ansible.builtin.git:
    dest: "/home/{{ my_user }}/git/{{ item.local_name }}"
    repo:  "{{ item.url_https }}"
    remote: "origin"
    update: no
    accept_hostkey: yes
  with_items: "{{ git_repositories }}"
  loop_control:
    label: "{{ item.local_name }}"

- name: MY USER | OSM cache dir presence
  become: yes
  when: inventory_hostname in groups.station
  ansible.builtin.file:
    group: "{{ my_user }}"
    mode: '0750'
    owner: "{{ my_user }}"
    path: "/home/{{ my_user }}/.osm-tiles/"
    state: directory

- name: MY USER | GPS Prune config
  ansible.builtin.template:
    src: templates/pruneconfig.j2
    dest: "/home/{{ my_user }}/.pruneconfig"
    owner: "{{ my_user }}"
    group: "{{ my_user }}"
    mode: '0640'
