-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile.infra
68 lines (49 loc) · 2.37 KB
/
justfile.infra
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
# Justfile for infra
# This list of actions.
infra:
@ just -l --unsorted | grep infra
# Sample calls
infra-tldr:
# Sample of calls:
@ echo ""
# $ just infra-help # Just in case you like to read.
# $ just infra-list # For a detailed list of actions.
# $ just infra-install-ansible # Install ansible in your local machine
# $ just infra-run info-ps $SERVER -K # TEST: if you can reach your remote server
# $ just infra-dist-upgrade $SERVER # Upgrades the full system (-K is implicit)
# $ just infra-run install-basic $SERVER # Essential tooling (curl, rsync, pip...)
# $ just infra-run install-docker $SERVER # Docker and compose are also essential.
# $ just infra-run info-docker $SERVER # TEST: docker and docker-compose.
# $ just infra-run create-user $SERVER # Create docker user and group and folders.
@echo ""
# > To get a commented list of actions use "just infra"
# Shows how to use the script
infra-help:
# README for infrastructure playbooks
@ cat {{ infraPath }}/README.md
@ echo ""
# An alias for "just list infra" that shows a full list of infra's actions
infra-list:
@ just list infra
# Installs ansible the required roles in your laptop.
infra-install-ansible:
sudo apt install ansible git
sudo python3 -m venv venv
# Activates the virtual environment (in Unix/Linux systems)
bash -c "source venv/bin/activate"
ansible-galaxy install -r requirements.yml
# Runs an action (playbook) from /playbooks/infra as root.
infra-run action host *args:
ansible-playbook -i {{ inventoryPath }}/hosts.yml \
--limit {{ host }} {{ infraPath }}/{{ action }}.yml -K {{ args }}
# Shows the description of the specified playbook. Run "just infra-list" for a list.
infra-show playbook:
cat {{ infraPath }}/{{ playbook }}.yml
# Runs a dist-upgrade, remove unused dependences and reboot.
infra-dist-upgrade host:
ansible-playbook -i {{ inventoryPath }}/hosts.yml \
--limit {{ host }} {{ infraPath }}/dist-upgrade.yml -K
# Runs an "apt update" and "apt ugrade" and show the result.
infra-update-upgrade host:
ansible-playbook -i {{ inventoryPath }}/hosts.yml \
--limit {{ host }} {{ infraPath }}/update-upgrade.yml -K