-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaybook_work_macbook.yml
141 lines (130 loc) · 4.31 KB
/
playbook_work_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
---
- name: Configure Work MacOS device.
hosts: localhost
connection: local
vars_files:
- vars/all.yml
- vars/work_macbook.yml
pre_tasks:
- 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