-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmain.yml
108 lines (98 loc) · 2.51 KB
/
main.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
#!/usr/bin/env ansible-playbook
---
- name: Configure the machine.
hosts: all
connection: local
pre_tasks:
- name: Check if ~/.provision_profile exists.
ansible.builtin.stat:
path: "~/.provision_profile"
register: provision_profile_file_stat
tags:
- always
- block:
- name: Detect if the work profile for this machine was already chosen
ansible.builtin.lineinfile:
path: "~/.provision_profile"
line: 'work'
state: present
check_mode: true
register: provision_profile
- set_fact:
on_work_machine: "{{ not provision_profile.changed }}"
when: provision_profile_file_stat.stat.exists
tags:
- always
- block:
- pause:
prompt: Is this a work machine?
register: prompt_work_machine
- set_fact:
on_work_machine: "{{ prompt_work_machine.user_input | bool }}"
- name: Save the chosen profile
lineinfile:
path: "~/.provision_profile"
line: "{{ on_work_machine | ternary('work', 'nonwork') }}"
state: present
create: true
when: not provision_profile_file_stat.stat.exists
tags:
- always
- name: Detect if on macOS
set_fact:
# XXX(andrea): I hate this name... maybe just "macOS" or simply "macbook"
is_macOS: "{{ ansible_os_family | lower == 'darwin' }}"
tags:
- always
- include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_os_family }}_{{ ansible_architecture }}.yml"
- "{{ ansible_os_family }}.yml"
tags:
- always
roles:
# XXX(andrea): add tags on roles so we can run specific section of the configuration
- role: machine
tags:
- machine
when: not is_macOS
- role: compiler
tags:
- compiler
when: not is_macOS
- role: homebrew
tags:
- homebrew
- role: tmux
- role: fish
- role: git
tags:
- git
- role: ssh
tags:
- ssh
- role: go
- role: neovim
tags:
- neovim
- role: virtualization
when: not is_macOS
tags:
- virtualization
- role: karabiner
when: is_macOS
tags:
- karabiner
- role: wezterm
tags:
- wezterm
- role: iterm
when: is_macOS
tags:
- iterm
- role: hammerspoon
when: is_macOS
tags:
- hammerspoon
# XXX(andrea): next steps to implement
# - role: macOS