Skip to content

Commit

Permalink
[skip ci]taskfile(refactor): other tasks need vault script to be exec…
Browse files Browse the repository at this point in the history
…utable
  • Loading branch information
dbrennand committed Dec 21, 2023
1 parent 9a4adc5 commit 3283849
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,43 @@ vars:
ANSIBLE_VERSION: "8.5.0"

tasks:
ansible-preconditions: &ansible-preconditions
preconditions:
- sh: command -v ansible
msg: ansible is not installed. Have you ran `task venv`?

ansible:hosts:
desc: List Ansible hosts
dir: "{{.USER_WORKING_DIR}}"
cmds:
- task: op:vault
- task: venv:source
- ansible all --list-hosts
<<: *ansible-preconditions

ansible:adhoc:
desc: |
Run Ansible adhoc command.
Example: task ansible:adhoc -- -m ping
dir: "{{.USER_WORKING_DIR}}"
cmds:
- task: op:vault
- task: venv:source
- ansible all {{.CLI_ARGS}}
<<: *ansible-preconditions

ansible:play:
desc: |
Run Ansible playbook.
Example: task ansible:play -- playbooks/minecraft-playbook.yml
dir: "{{.USER_WORKING_DIR}}"
cmds:
- task: op:vault
- task: venv:source
- ansible-playbook {{.CLI_ARGS}}
preconditions:
- sh: command -v ansible-playbook
msg: ansible-playbook is not installed. Have you ran `task venv`?

ansible:encrypt:
desc: |
Expand All @@ -36,12 +49,12 @@ tasks:
dir: "{{.USER_WORKING_DIR}}"
interactive: true
cmds:
- chmod +x op-ansible-vault.sh
- task: op:vault
- task: venv:source
- ansible-vault encrypt_string {{ .CLI_ARGS }}
preconditions:
- sh: test -f op-ansible-vault.sh
msg: op-ansible-vault.sh file does not exist.
- sh: command -v ansible-vault
msg: ansible-vault is not installed. Have you ran `task venv`?

ansible:requirements:
desc: Install Ansible requirements
Expand All @@ -55,6 +68,17 @@ tasks:
- sh: test -f requirements.yml
msg: requirements.yml does not exist.

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.

venv:source:
desc: Source Python virtual environment
internal: true
Expand Down

0 comments on commit 3283849

Please sign in to comment.