<commit_before>---
# File: main.yml
# Type: task
# Part: Scott/Bootstrap

# Create user group and user
# Ensure only selected users can sudo
- name: Bootstrap | Group | create group admin
  action: group name=admin state=present
  register: new_group
- name: Bootstrap | Group | Protect su by limiting access only to admin group.
  action: command dpkg-statoverride --update --force --add root admin 4750 /bin/su
  when: new_group.changed
- name: Bootstrap | User | create custom user
  user: name={{ custom_user }} group=admin shell=/bin/bash state=present
  register: new_user
- name: Bootstrap | User | set custom user key
  authorized_key: user={{ custom_user }} key="{{ lookup('file', 'custom_user_sshkey') }}"
  when: new_user.changed
  ignore_errors: True
- name: Bootstrap | User | add custom user to admin group
  action: command usermod -a -G admin {{ custom_user }}
  when: new_user.changed
- name: Bootstrap | User | ensure the user can execute sudo commands without a password
  copy: content="{{ custom_user }} ALL=(ALL) NOPASSWD:ALL" dest=/etc/sudoers.d/{{ custom_user }} owner=root group=root mode=0440
  when: new_user.changed
- name: Bootstrap | User | ensure sudoers.d is enabled
  lineinfile: dest=/etc/sudoers state=present backup=yes regexp="^#includedir /etc/sudoers.d" line="#includedir /etc/sudoers.d"
  when: new_user.changed

# Transfer user preferences
- name: Bootstrap | Bash | transfer .bashrc
  copy: src={{ custom_user_bashrc }} dest=/home/{{ custom_user }}/.bashrc owner={{ custom_user }} group=admin
  when: new_user.changed
- name: Bootstrap | Vim | transfer .vimrc
  copy: src={{ custom_user_vimrc }} dest=/home/{{ custom_user }}/.vimrc owner={{ custom_user }} group=admin
  when: new_user.changed
- name: Bootstrap | Vim | create dir ~/.vim
  file: dest=/home/{{ custom_user }}/.vim state=directory owner={{ custom_user }} group=admin
  when: new_user.changed
- name: Bootstrap | Vim | create dir ~/.vim/colors
  file: dest=/home/{{ custom_user }}/.vim/colors state=directory owner={{ custom_user }} group=admin
  when: new_user.changed
- name: Bootstrap | Vim | transfer colorscheme - IR Black
  copy: src=ir_black.vim dest=/home/{{ custom_user }}/.vim/colors/ir_black.vim
  when: new_user.changed
- name: Bootstrap | Vim | transfer colorscheme - GRB 256
  copy: src=grb256.vim dest=/home/{{ custom_user }}/.vim/colors/grb256.vim
  when: new_user.changed

# Transfer git config and key
- name: Bootstrap | User | set custom git config
  copy: src={{ custom_user_gitconfig }} dest=/home/{{ custom_user }}/.gitconfig
  when: new_user.changed
- name: Bootstrap | User | set custom git key
  copy: src={{ custom_user_gitkey }} dest=/home/{{ custom_user }}/.ssh/GitKey
  when: new_user.changed
# Transfer ssh config to use various keys
- name: Bootstrap | User | set custom ssh config
  copy: src={{ custom_user_sshconfig }} dest=/home/{{ custom_user }}/.ssh/config
  when: new_user.changed

# Reboot
#- name: Bootstrap | reboot
#  action: command reboot<commit_msg>Add mode to gitkey - experimental<commit_after>---
# File: main.yml
# Type: task
# Part: Scott/Bootstrap

# Create user group and user
# Ensure only selected users can sudo
- name: Bootstrap | Group | create group admin
  action: group name=admin state=present
  register: new_group
- name: Bootstrap | Group | Protect su by limiting access only to admin group.
  action: command dpkg-statoverride --update --force --add root admin 4750 /bin/su
  when: new_group.changed
- name: Bootstrap | User | create custom user
  user: name={{ custom_user }} group=admin shell=/bin/bash state=present
  register: new_user
- name: Bootstrap | User | set custom user key
  authorized_key: user={{ custom_user }} key="{{ lookup('file', 'custom_user_sshkey') }}"
  when: new_user.changed
  ignore_errors: True
- name: Bootstrap | User | add custom user to admin group
  action: command usermod -a -G admin {{ custom_user }}
  when: new_user.changed
- name: Bootstrap | User | ensure the user can execute sudo commands without a password
  copy: content="{{ custom_user }} ALL=(ALL) NOPASSWD:ALL" dest=/etc/sudoers.d/{{ custom_user }} owner=root group=root mode=0440
  when: new_user.changed
- name: Bootstrap | User | ensure sudoers.d is enabled
  lineinfile: dest=/etc/sudoers state=present backup=yes regexp="^#includedir /etc/sudoers.d" line="#includedir /etc/sudoers.d"
  when: new_user.changed

# Transfer user preferences
- name: Bootstrap | Bash | transfer .bashrc
  copy: src={{ custom_user_bashrc }} dest=/home/{{ custom_user }}/.bashrc owner={{ custom_user }} group=admin
  when: new_user.changed
- name: Bootstrap | Vim | transfer .vimrc
  copy: src={{ custom_user_vimrc }} dest=/home/{{ custom_user }}/.vimrc owner={{ custom_user }} group=admin
  when: new_user.changed
- name: Bootstrap | Vim | create dir ~/.vim
  file: dest=/home/{{ custom_user }}/.vim state=directory owner={{ custom_user }} group=admin
  when: new_user.changed
- name: Bootstrap | Vim | create dir ~/.vim/colors
  file: dest=/home/{{ custom_user }}/.vim/colors state=directory owner={{ custom_user }} group=admin
  when: new_user.changed
- name: Bootstrap | Vim | transfer colorscheme - IR Black
  copy: src=ir_black.vim dest=/home/{{ custom_user }}/.vim/colors/ir_black.vim
  when: new_user.changed
- name: Bootstrap | Vim | transfer colorscheme - GRB 256
  copy: src=grb256.vim dest=/home/{{ custom_user }}/.vim/colors/grb256.vim
  when: new_user.changed

# Transfer git config and key
- name: Bootstrap | User | set custom git config
  copy: src={{ custom_user_gitconfig }} dest=/home/{{ custom_user }}/.gitconfig
  when: new_user.changed
- name: Bootstrap | User | set custom git key
  copy: src={{ custom_user_gitkey }} dest=/home/{{ custom_user }}/.ssh/GitKey mode=0600
  when: new_user.changed
# Transfer ssh config to use various keys
- name: Bootstrap | User | set custom ssh config
  copy: src={{ custom_user_sshconfig }} dest=/home/{{ custom_user }}/.ssh/config
  when: new_user.changed

# Reboot
#- name: Bootstrap | reboot
#  action: command reboot
{'fraction_non_alphanumeric': 0.12769485903814262, 'fraction_numerical': 0.006301824212271974, 'mean_word_length': 4.2443478260869565, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2362230', 'n_tokens_mistral': 2011, 'n_tokens_neox': 1858, 'n_words': 612}