summaryrefslogtreecommitdiff
path: root/roles/custom-config/tasks/main.yml
blob: 832a64a9c9ff34f472aec500a88162949d9df9a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
---
# tasks file for custom-config
- name: Getting all interactive users
  ansible.builtin.shell: "awk -F: '{ if (($3 >= 1000 && $3 != 65534) || $3 == 0) print $1}' /etc/passwd"
  register: users

- name: Install Kitty Terminal Emulator 🐱
  ansible.builtin.shell:
    cmd: "/usr/bin/curl -sL {{ kitty_installer }} | sh /dev/stdin dest=/opt launch=n"

- name: Create Desktop Icon for Kitty 🐱
  ansible.builtin.copy:
    dest: "/usr/share/applications/kitty.desktop"
    content: |
      [Desktop Entry]
      Version=0.26.2
      Type=Application
      Name=Kitty Terminal Emulator
      Exec=/opt/kitty.app/bin/kitty
      Icon=/opt/kitty.app/share/icons/hicolor/256x256/apps/kitty.png
      Categories=Utility

- name: Prepare kitty.conf files for all interactive users 🐱
  loop: "{{ users.stdout_lines }}"
  ansible.builtin.file:
    dest: "~{{ item }}/.config/kitty/"
    state: directory
    recurse: yes
    owner: "{{ item }}"
    group: "{{ item }}"
    mode: 0755

- name: Prepare personalized configs for Kitty 🐱
  loop: "{{ users.stdout_lines }}"
  ansible.builtin.blockinfile:
    path: "~{{ item }}/.config/kitty/kitty.conf"
    insertafter: EOF
    create: yes
    state: present
    block: |
      # New windows open in current directory
      map ctrl+shift+enter launch --cwd=current

      # New tabs open in current directory
      map ctrl+t new_tab --cwd=current

      # The coveted "zoom" function
      map ctrl+shift+z toggle_layout stack
      
      # disable mouse-click a link to open in a browser
      mouse_map left click ungrabbed no_op

- name: Disable mouse interactivity in vim (╯°□°)╯︵ ┻━┻
  ansible.builtin.blockinfile:
    path: /etc/vim/vimrc
    marker: "\" {mark} ANSIBLE MANAGED BLOCK"
    insertafter: EOF
    state: present
    block: |
      set mouse=
      set ttymouse=

- name: Add sudo-NOPASSWD to users
  loop: "{{ users.stdout_lines }}"
  ansible.builtin.lineinfile:
    path: /etc/sudoers
    state: present
    insertafter: EOF
    line: "{{ item }} ALL=(ALL) NOPASSWD: ALL"
    validate: /usr/sbin/visudo -cf %s

- name: Initialize Gef for all users
  ansible.builtin.script: /opt/gef/scripts/gef.sh
  become_user: "{{ item }}"
  loop: "{{ users.stdout_lines }}"

- name: Copying over zsh functions file for all users
  ansible.builtin.copy:
    src: zsh_functions.zsh
    dest: "~{{ item }}/.zsh_functions"
    owner: "{{ item }}"
    group: "{{ item }}"
    mode: '0640'
  loop: "{{ users.stdout_lines }}"

- name: Enabling zsh functions
  loop: "{{ users.stdout_lines }}"
  ansible.builtin.blockinfile:
    path: "~{{ item }}/.zshrc"
    state: present
    insertafter: EOF
    owner: "{{ item }}"
    block: |
      if [ -f ~/.zsh_functions]; then
        source ~/.zsh_functions
      fi

- name: Copying over tmux config to all users
  ansible.builtin.copy:
    src: tmux_conf
    dest: "~{{ item }}/.tmux.conf"
    owner: "{{ item }}"
    group: "{{ item }}"
    mode: '0640'
  loop: "{{ users.stdout_lines }}"

- name: Enable SSH Subshell
  ansible.builtin.lineinfile:
    path: /etc/ssh/ssh_config
    state: present
    insertafter: EOF
    line: 'EnableEscapeCommandline=yes'

- name: Create /srv/smb/ directory for payload population
  ansible.builtin.file:
    path: /srv/smb
    state: directory
    mode: '0755'

- name: Creating IWR share in samba config
  ansible.builtin.blockinfile:
    path: /etc/samba/smb.conf
    insertafter: EOF
    state: present
    block: |
      [iwr]
        comment = Invoke-WebReq'd em? Damn near killed em!
        path = /srv/smb
        guest ok = yes
        browseable = yes
        create mask = 0600
        directory mask = 0755

- name: Ensure that samba doesn't start on boot
  ansible.builtin.systemd:
    name: smbd
    enabled: no
    state: stopped