-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
77 lines (68 loc) · 1.91 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
72
73
74
75
76
77
SHELL=/bin/bash
.PHONY: help
help:
@echo ""
@echo "Usage: make COMMAND"
@echo ""
@echo "Ansible-Managed Dotfiles Makefile"
@echo ""
@echo "Commands:"
@echo " local Apply 'dev' dotfiles to localhost as current user"
@echo " server Apply 'server' dotfiles to a remote host"
@echo " dev Apply 'dev' dotfiles to a remote host"
@echo ""
@echo " lint Lint project with ansible-lint"
@echo " vault-open Open the Ansible vault for editing in '$$EDITOR'"
@echo " vault-decrypt Decrypt the Ansible Vault in-place"
@echo " vault-encrypt Re-encrypt the Ansible Vault"
@echo ""
.vault_password:
@echo ""
@echo "Creating .vault_password file."
@echo ""
@echo " Supply the password for the Ansible Vault,"
@echo " it will be saved in this file, and used on repeated runs:"
@read -s VAULTPASSWORD; \
echo "$$VAULTPASSWORD" > .vault_password;
@echo ""
.PHONY: lint
lint:
@ansible-lint
.PHONY: local
local: .vault_password
@ansible-playbook \
--connection=local \
--inventory=127.0.0.1, \
--tags=dev, \
site.yml
.PHONY: server
server: .vault_password
@echo "Enter remote host to deploy server dotfiles to:"; \
read REMOTE_HOST; \
echo "Enter remote user:"; \
read REMOTE_USER; \
echo "Enter SSH port:"; \
read REMOTE_PORT; \
ansible-playbook \
--inventory=$$REMOTE_HOST, \
--tags=server, \
-e ansible_ssh_user=$$REMOTE_USER \
-e ansible_ssh_port=$$REMOTE_PORT \
site.yml
.PHONY: dev
dev: .vault_password
@echo "Enter remote host to deploy dev dotfiles to:"
@read REMOTE_HOST; \
ansible-playbook \
--inventory=$$REMOTE_HOST, \
--tags=dev, \
site.yml
.PHONY: vault-open
vault-open: .vault_password
@ansible-vault edit group_vars/vault.yml
.PHONY: vault-decrypt
vault-decrypt: .vault_password
@ansible-vault decrypt group_vars/vault.yml
.PHONY: vault-encrypt
vault-encrypt: .vault_password
@ansible-vault encrypt group_vars/vault.yml