Hey!
We're working on reusable tasks to be able to run the same tasks from different Terraform configuration directories.
The content of my root Taskfile is:
version: "3"
includes:
terraform:
taskfile: ./taskfiles/terraform
aliases: [tf]
My terraform taskfile looks like:
init:
silent: true
# dir: "{{.USER_WORKING_DIR}}"
vars:
ENV:
sh: echo "{{.CLI_ARGS}}" | cut -d ' ' -f1 | xargs
TF_ARGS:
sh: echo "{{.CLI_ARGS}}" | cut -s -d ' ' -f2- | xargs
BACKEND_CONFIG_FILE:
sh: echo "./backend-configurations/{{.ENV}}.backend.tf"
preconditions:
- sh: test -f {{.BACKEND_CONFIG_FILE}}
msg: "Backend configuration file does not exist: {{.BACKEND_CONFIG_FILE}}"
cmds:
- terraform init -backend-config {{.BACKEND_CONFIG_FILE}} {{.TF_ARGS}}
When uncommenting and enabling dir: "{{.USER_WORKING_DIR}}", task run fails with a weird error:
task: Command "echo "automation" | cut -d ' ' -f1 | xargs" failed: chdir /Users/gberenice/work/mp/infra/Users/gberenice/work/mp/infra/components/network: no such file or directory
I run this task from /Users/gberenice/work/mp/infra/components/network, while /Users/gberenice/work/mp/infra/ is a directory where my root Taskfile.yaml is located.
If I set dir equal to a specific directory, everything works as expected. Please advise.
- Task version: 3.28.0
- Operating system: macOS 13.4
- Experiments enabled: no
Hey!
We're working on reusable tasks to be able to run the same tasks from different Terraform configuration directories.
The content of my root Taskfile is:
My terraform taskfile looks like:
When uncommenting and enabling
dir: "{{.USER_WORKING_DIR}}", task run fails with a weird error:I run this task from
/Users/gberenice/work/mp/infra/components/network, while/Users/gberenice/work/mp/infra/is a directory where my root Taskfile.yaml is located.If I set
direqual to a specific directory, everything works as expected. Please advise.