-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.yaml
78 lines (70 loc) · 2.12 KB
/
setup.yaml
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
---
- name: Setup Mac Dev Environment
hosts: localhost
become: yes
tasks:
- name: Ensure necessary directories exist
file:
path: "{{ item }}"
state: directory
mode: "0700"
loop:
- "{{ lookup('env', 'HOME') }}/.ssh"
- "{{ lookup('env', 'HOME') }}/.gnupg"
- name: Install Homebrew
become: no
shell: |
if ! command -v brew &>/dev/null; then
echo "Homebrew not found. Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
args:
creates: /usr/local/bin/brew
- name: Ensure Homebrew is in the PATH
become: no
shell: |
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc
eval "$(/opt/homebrew/bin/brew shellenv)"
when: ansible_os_family == "Darwin"
- name: Update Homebrew
become: no
homebrew:
update_homebrew: yes
- name: Install Python
become: no
homebrew:
name: python
state: latest
- name: Ensure Python is in the PATH
become: no
shell: |
python_path="/opt/homebrew/opt/[email protected]/libexec/bin"
if ! echo $PATH | grep -q $python_path; then
export PATH="$python_path:$PATH"
fi
if ! grep -q "export PATH=\"$python_path:\$PATH\"" ~/.zshrc; then
echo "export PATH=\"$python_path:\$PATH\"" >> ~/.zshrc
fi
source ~/.zshrc
args:
executable: /bin/zsh
- name: Create Python virtual environment
become: no
command: python3 -m venv ~/.venv
args:
creates: "{{ lookup('env', 'HOME') }}/.venv"
- name: Activate virtual environment
become: no
shell: source ~/.venv/bin/activate
args:
executable: /bin/zsh
- name: Ensure Ansible is in the PATH
become: no
shell: |
if ! echo $PATH | grep -q "$HOME/.local/bin"; then
export PATH="$HOME/.local/bin:$PATH"
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
fi
source ~/.zshrc
args:
executable: /bin/zsh