Skip to content

Proposal: Ability to run a task / included taskfile, as a distinct user #2037

@hugo-ricateau

Description

@hugo-ricateau

Description

It would be convenient to be able to run a specific task / included taskfile, as a distinct user: e.g. when using Homebrew in a multi-user environment, it must be invoked with its "owning" user, that definitely is distinct from the current one (according to the Homebrew's recommendation in this context).
I didn't find any previous request for such feature; I hope I didn't miss it.

This can already be achieved through

version: 3

vars:
  USER:
    sh: echo ${USER:-$(whoami)}

tasks:
  target:
    cmds:
      - sudo --login --user={{.USER}} command0
      - ...
      - sudo --login --user={{.USER}} commandN

but rapidly becomes cumbersome with lots of tasks / commands; such a syntax would be of a great help for readability and maintainability:

tasks:
  target:
    as: {{.USER}}
    cmds:
      - command0
      - ...
      - commandN

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions