-
Notifications
You must be signed in to change notification settings - Fork 33
/
Makefile
71 lines (62 loc) · 2.67 KB
/
Makefile
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
# Catalina | 3.7
# Big Sur | 3.8
# Ventura | 3.9
SYSTEM_PYTHON := /usr/bin/python3
BOOTSTRAP_PYTHON_MAJOR_VERSION := $(shell ./semver.sh "$$($(SYSTEM_PYTHON) --version | cut -d' ' -f2)" | sed -n '1 p')
BOOTSTRAP_PYTHON_MINOR_VERSION := $(shell ./semver.sh "$$($(SYSTEM_PYTHON) --version | cut -d' ' -f2)" | sed -n '2 p')
BOOTSTRAP_PYTHON_VERSION := $(BOOTSTRAP_PYTHON_MAJOR_VERSION).$(BOOTSTRAP_PYTHON_MINOR_VERSION)
BOOTSTRAP_PYTHON := /usr/bin/python$(BOOTSTRAP_PYTHON_MAJOR_VERSION)
BOOTSTRAP_PYTHON_BIN_PATH := ~/Library/Python/$(BOOTSTRAP_PYTHON_VERSION)/bin
BOOTSTRAP_PIP := $(BOOTSTRAP_PYTHON) -m pip
# NOTE: this reflects the "python3_version" in the "python" role in main.yml.
PYTHON_VERSION := 3.11
PYTHON_BIN_PATH := ~/Library/Python/$(PYTHON_VERSION)/bin
PYTHON := /usr/local/bin/python$(PYTHON_VERSION)
PIP := $(PYTHON) -m pip
PROJECT_ROOT := $(shell pwd)
ANSIBLE_DIRECTORY := .
ANSIBLE_PLAYBOOKS_DIRECTORY := $(ANSIBLE_DIRECTORY)
ANSIBLE_ROLES_DIRECTORY := $(ANSIBLE_DIRECTORY)/roles
ANSIBLE_GROUP_VARS_DIRECTORY := $(ANSIBLE_DIRECTORY)/group_vars
ANSIBLE_INVENTORY := $(ANSIBLE_DIRECTORY)/hosts
ANSIBLE_VERBOSE := -v
ANSIBLE_GALAXY := $(PYTHON_BIN_PATH)/ansible-galaxy
ANSIBLE_LOCAL := \
$(PYTHON_BIN_PATH)/ansible-playbook $(ANSIBLE_VERBOSE) \
-i $(ANSIBLE_INVENTORY) \
--extra-vars "project_root=$(PROJECT_ROOT)" \
--extra-vars "@$(ANSIBLE_GROUP_VARS_DIRECTORY)/localhost/vars.yml" \
$(ARGS)
# NOTE: only required for Mojave?
.PHONY: get_bootstrap_pip
get_bootstrap_pip:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py --user --force-reinstall
rm -f get-pip.py
.PHONY: bootstrap
bootstrap:
$(BOOTSTRAP_PIP) install --user ansible
$(BOOTSTRAP_PYTHON_BIN_PATH)/ansible-playbook \
--extra-vars "project_root=$(PROJECT_ROOT)" \
$(ANSIBLE_PLAYBOOKS_DIRECTORY)/bootstrap.yml \
--ask-become-pass
$(PIP) install --user ansible
$(ANSIBLE_GALAXY) collection install \
-r $(ANSIBLE_DIRECTORY)/requirements.yml \
-p $(ANSIBLE_DIRECTORY)/galaxy
sudo softwareupdate --install-rosetta
# NOTE: this seems to be required for Big Sur. Without it, the 'cryptography'
# pip package (a transitive dependency for the 'ansible' package) fails to
# install.
.PHONY: bootstrap_upgrade_pip
bootstrap_upgrade_pip:
@sudo $(BOOTSTRAP_PIP) install --upgrade pip
.PHONY: upgrade_pip
upgrade_pip:
@$(PIP) install --upgrade pip
.PHONY: upgrade_ansible
upgrade_ansible:
@$(PIP) install --user --upgrade ansible
.PHONY: converge
converge:
@$(ANSIBLE_LOCAL) $(ANSIBLE_PLAYBOOKS_DIRECTORY)/main.yml