-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.yml
90 lines (81 loc) · 2.71 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
version: "3"
vars:
PROJECT_ROOT:
sh: git rev-parse --show-toplevel
VENV_PATH: "{{ .PROJECT_ROOT }}/.venv"
ANSIBLE_PROJECT_PATH: "{{ .PROJECT_ROOT }}/ansible"
tasks:
op:vault:
desc: |
Ensure the op-ansible-vault.sh script is executable.
internal: true
dir: "{{ .ANSIBLE_PROJECT_PATH }}"
cmds:
- chmod +x op-ansible-vault.sh
preconditions:
- sh: test -f op-ansible-vault.sh
msg: op-ansible-vault.sh file does not exist {{ .ANSIBLE_PROJECT_PATH }}.
venv:build:
desc: |
Build Python virtual environment using uv.
internal: true
cmds:
- uv venv {{ .VENV_PATH }}
- uv pip install -r {{ .ANSIBLE_PROJECT_PATH }}/requirements.txt
venv:
desc: Create Python virtual environment in {{ .VENV_PATH }}
cmds:
- task: venv:build
ansible:hosts:
desc: List Ansible hosts configured in the inventory.
dir: "{{ .ANSIBLE_PROJECT_PATH }}"
cmds:
- task: op:vault
- uv run 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: "{{ .ANSIBLE_PROJECT_PATH }}"
cmds:
- task: op:vault
- "uv run 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: "{{ .ANSIBLE_PROJECT_PATH }}"
cmds:
- task: op:vault
- "uv run 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: "{{ .ANSIBLE_PROJECT_PATH }}"
cmds:
- task: op:vault
- "uv run 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: "{{ .ANSIBLE_PROJECT_PATH }}"
cmds:
- "uv run 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.