-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
108 lines (98 loc) · 3.04 KB
/
Taskfile.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
version: "3"
vars:
VENV_PATH: "~/.virtualenvs/home-ops"
tasks:
op:vault:
desc: |
Ensure the op-ansible-vault.sh script is executable.
internal: true
dir: "{{.USER_WORKING_DIR}}"
cmds:
- chmod +x op-ansible-vault.sh
preconditions:
- sh: test -f op-ansible-vault.sh
msg: op-ansible-vault.sh file does not exist {{.USER_WORKING_DIR}}.
venv:build:
desc: Build Python virtual environment
internal: true
cmds:
- mkdir -pv $(dirname {{.VENV_PATH}})
- python -m venv {{.VENV_PATH}}
- "{{.VENV_PATH}}/bin/pip install --upgrade pip"
- "{{.VENV_PATH}}/bin/pip install -r {{.USER_WORKING_DIR}}/requirements.txt"
venv:
desc: Create Python virtual environment in {{.VENV_PATH}}
cmds:
- task: venv:build
ansible:hosts:
desc: List Ansible hosts
dir: "{{.USER_WORKING_DIR}}"
cmds:
- task: op:vault
- "{{.VENV_PATH}}/bin/ansible all --list-hosts"
preconditions:
- sh: command -v {{.VENV_PATH}}/bin/ansible
msg: ansible is not installed. Have you ran 'task venv'?
ansible:adhoc:
desc: |
Run Ansible adhoc command.
Example: task ansible:adhoc -- proxmox -m ping
dir: "{{.USER_WORKING_DIR}}"
cmds:
- task: op:vault
- "{{.VENV_PATH}}/bin/ansible {{.CLI_ARGS}}"
preconditions:
- sh: command -v {{.VENV_PATH}}/bin/ansible
msg: ansible is not installed. Have you ran 'task venv'?
ansible:play:
desc: |
Run Ansible playbook.
Example: task ansible:play -- playbooks/minecraft-playbook.yml
dir: "{{.USER_WORKING_DIR}}"
cmds:
- task: op:vault
- "{{.VENV_PATH}}/bin/ansible-playbook {{.CLI_ARGS}}"
preconditions:
- sh: command -v {{.VENV_PATH}}/bin/ansible-playbook
msg: ansible-playbook is not installed. Have you ran 'task venv'?
ansible:encrypt:
desc: |
Encrypt Ansible variable.
Example: task ansible:encrypt -- 'Secret!' --name 'my_secret'
interactive: true
dir: "{{.USER_WORKING_DIR}}"
cmds:
- task: op:vault
- "{{.VENV_PATH}}/bin/ansible-vault encrypt_string {{ .CLI_ARGS }}"
preconditions:
- sh: command -v {{.VENV_PATH}}/bin/ansible-vault
msg: ansible-vault is not installed. Have you ran 'task venv'?
ansible:requirements:
desc: Install Ansible requirements
dir: "{{.USER_WORKING_DIR}}"
cmds:
- "{{.VENV_PATH}}/bin/ansible-galaxy install {{ .CLI_ARGS }} -r requirements.yml"
preconditions:
- sh: command -v {{.VENV_PATH}}/bin/ansible-galaxy
msg: ansible-galaxy is not installed. Have you ran 'task venv'?
- sh: test -f requirements.yml
msg: requirements.yml does not exist.
tools:
desc: Install tooling
cmds:
- brew install {{.TOOLS}}
- brew install --cask {{.CASKS}}
preconditions:
- sh: command -v brew
msg: Homebrew is not installed. See https://brew.sh/
vars:
TOOLS: >-
sops
age
jq
yq
gettext
pyenv
CASKS: >-
1password-cli
orbstack