-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaybook_macbook.yml
180 lines (168 loc) · 5.87 KB
/
playbook_macbook.yml
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
---
- name: Configure MacOS device.
hosts: localhost
connection: local
vars_files:
- vars/all.yml
- vars/macbook.yml
pre_tasks:
- name: Macos Admin Juggling
ansible.builtin.include_tasks: tasks/macos_admin_juggling.yml
when: testing is undefined or testing != 'true'
- name: Add homebrew to local env PATH
ansible.builtin.command: echo 'export PATH="/opt/homebrew/bin:$PATH"'
changed_when: false
roles:
- role: elliotweiser.osx-command-line-tools
- role: geerlingguy.mac.homebrew
tags: ["homebrew"]
vars:
# homebrew_upgrade_all_packages: true
homebrew_cask_accept_external_apps: true
- role: geerlingguy.mac.mas
when: mas_installed_apps or mas_uninstalled_apps
tags: ["mas"]
- role: geerlingguy.mac.dock
tags: ["dock"]
- role: dotfiles
tags: ["dotfiles"]
vars:
dotfiles_repo_url: "https://github.com/k4black/dotfiles.git"
dotfiles_dest: "/Users/{{ ansible_user_id }}/.dotfiles"
dotfiles_symlinks:
.zshrc: "/Users/{{ ansible_user_id }}/.zshrc"
.gitconfig: "/Users/{{ ansible_user_id }}/.gitconfig"
dotfiles_run_scripts:
- "/Users/{{ ansible_user_id }}/.dotfiles/.macos.sh"
- role: zsh_setup
vars:
zsh_setup_set_default_shell: true
zsh_setup_user: "{{ ansible_user_id }}"
tasks:
- name: Setup hostname
ansible.builtin.hostname:
name: "{{ device_name }}"
use: "macos"
become: true
- name: Create Projects directory at ~/
ansible.builtin.file:
path: "~/Projects"
state: directory
owner: "{{ ansible_user_id }}"
mode: "0700"
- name: Create Applications directory at ~/
ansible.builtin.file:
path: "~/Applications"
state: directory
owner: "{{ ansible_user_id }}"
mode: "0755"
- name: Create .ssh directory at ~/
ansible.builtin.file:
path: "~/.ssh"
state: directory
owner: "{{ ansible_user_id }}"
mode: "0700"
- name: Add ssh-agent to localrc
ansible.builtin.lineinfile:
path: ~/.localrc
line: 'eval "$(ssh-agent -s)"'
state: present
create: true
mode: 0600
insertafter: EOF
become: true
- name: Add brew to path in localrc
ansible.builtin.lineinfile:
path: ~/.localrc
line: 'export PATH="/opt/homebrew/bin:$PATH"'
state: present
create: true
mode: 0600
insertafter: EOF
become: true
- name: Ensure Host * line in ssh config
ansible.builtin.lineinfile:
path: ~/.ssh/config
line: "Host *\n"
state: present
create: true
mode: 0600
insertbefore: BOF
become: true
- name: Add AddKeysToAgent yes to ssh config Host *
ansible.builtin.lineinfile:
path: ~/.ssh/config
line: " AddKeysToAgent yes"
state: present
create: true
mode: 0600
insertafter: "Host *\n"
become: true
- name: Setup .gitconfig.local
ansible.builtin.template:
src: files/.gitconfig.local.j2
dest: ~/.gitconfig.local
mode: 0600
owner: "{{ ansible_user_id }}"
- name: Setup MonitorControl
when: not 'MonitorControl' in homebrew_cask_apps
block:
- name: Install MonitorControl
community.general.homebrew:
name: MonitorControl
state: present
# - name: Enable MonitorControl in System Preferences -> Privacy & Security -> Privacy -> Accessibility
# ansible.builtin.command: osascript -e 'tell application "System Events" to tell process "System Preferences"
# to tell window "Security & Privacy" to tell scroll area "Privacy" to tell table 1 to tell row 1 to tell checkbox 1 to if value is 0 then click'
# become: true
- name: Set Default browser
block:
- name: Check if Orion is installed
ansible.builtin.stat:
path: /Applications/Orion.app
register: orion_app
- name: Install defaultbrowser
community.general.homebrew:
name: defaultbrowser
state: present
when: orion_app.stat.exists
- name: Set Orion as default browser
ansible.builtin.command: osascript files/macbook/setDefaultBrowser.scpt kagimacos
when: orion_app.stat.exists
changed_when: false
become: true
- name: Setup Wireguard VPN
when: '"wireguard-tools" in homebrew_installed_packages or "WireGuard" in mas_installed_apps'
block:
- name: Install Wireguard and killswitch
community.general.homebrew:
name: "{{ item }}"
state: present
with_items:
- wireguard-tools
- killswitch
- name: Create wireguard configs directory
ansible.builtin.file:
path: "~/.config/wireguard"
state: directory
mode: 0755
- name: Copy the wineguard config file
ansible.builtin.template:
src: files/macbook/vps-client-wg0.conf.j2
dest: "~/.config/wireguard/vps_wg0.conf"
mode: 0600
- name: Copy the wineguard config file
ansible.builtin.template:
src: files/macbook/homelab-client-wg0.conf.j2
dest: "~/.config/wireguard/homelab_wg0.conf"
mode: 0600
- name: Copy the wineguard config file
ansible.builtin.template:
src: files/macbook/router-client-wg0.conf.j2
dest: "~/.config/wireguard/router_wg0.conf"
mode: 0600
- name: Copy the wineguard config file (guests)
ansible.builtin.template:
src: files/macbook/vpn-client-guests-sasha-bakalova.conf.j2
dest: "~/.config/wireguard/vpn_guests_sasha_bakalova.conf"
mode: 0600