- include_vars: 'users.yml'

- name: users | rene | add user to sudo group
  user:
    name: rene
    shell: "/usr/bin/zsh"
    groups: "{{ sudo_group }}"
    append: True
    password: "{{ rene_pass | password_hash('sha256') }}"

- name: users | rene | install public ssh keys
  authorized_key:
    user: rene
    state: present
    key: '{{ item }}'
  with_file:
    - public_keys/id_dsa.pub
    - public_keys/id_ed25519.pub
    - public_keys/rene_id_rsa.pub
    - public_keys/yubikey.pub

- name: users | rene | debug
  debug:
    msg: "copy_ssh_priv_keys: {{ copy_ssh_priv_keys }}"
  when: copy_ssh_priv_keys is defined

- name: users | rene | install private ssh keys
  copy:
    dest: "/home/rene/.ssh/"
    src: "{{ item }}"
    owner: rene
    group: rene
    mode: '0600'
  loop:
    - "private_keys/id_dsa"
    - "private_keys/id_ed25519"
    - "private_keys/id_rsa"
    - "private_keys/identity_for_kashyyyk"
    - "private_keys/yubikey"
  when: copy_ssh_priv_keys is defined and copy_ssh_priv_keys == true

# - name: users | rene | install known_hosts
#   copy:
#     dest: "/home/rene/.ssh/known_hosts"
#     src: "users/known_hosts"
#     backup: True
#     mode: '0600'
#     owner: 'rene'
#     group: 'rene'

# - name: users | rene | clone remote repos
#   become: yes
#   become_user: rene
#   git:
#     repo: '{{ item.repo }}'
#     dest: '/home/rene/{{ item.dir }}'
#     key_file: '/home/rene/.ssh/gitlab_read_ed25519'
#   with_items:
#     - {repo: 'ssh://git@gitea.mewissen.site:22422/rene/dotfiles.git', dir: 'dotfiles'}
#     - {repo: 'https://github.com/romkatv/powerlevel10k.git', dir: 'powerlevel10k'}

# - name: users | rene | link dotfiles
#   become: yes
#   become_user: rene
#   file:
#     state: link
#     src: "/home/rene/dotfiles/{{ item.src }}"
#     path: "home/rene/{{ item.dest }}"
#   with_items:
#     - { src: 'vim/vimrc', dest: '.vimrc' }
#     - { src: 'bash/bashrc', dest: '.bashrc' }
#     - { src: 'zsh/zshrc', dest: '.zshrc' }
#     - { src: 'tmux/tmux.conf', dest: '.tmux.conf' }

########################################################
# Learn Linux TV examples
########################################################
# - name: users | rene | create config directories
#   file:
#     path: /rene/{{ item.dir }}
#     state: directory
#     owner: rene
#     group: rene
#     mode: 0700
#   with_items:
#     - {dir: '.vim'}
#     - {dir: '.vim/colors'}
#   tags: dotfiles

# - name: users | rene | copy dotfiles
#   copy:
#     src: users/rene/{{ item.src }}
#     dest: /rene/{{ item.dest }}
#     owner: rene
#     group: rene
#     mode: 0600
#   with_items:
#     - {src: 'bash/bashrc', dest: '.bashrc'}
#     - {src: 'bash/bash_profile', dest: '.bash_profile'}
#     - {src: 'bash/profile', dest: '.profile'}
#     - {src: 'tmux/tmux.conf', dest: '.tmux.conf'}
#     - {src: 'vim/vimrc', dest: '.vimrc'}
#     - {src: 'zsh/zshrc', dest: '.zshrc'}
#   tags: dotfiles
