question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

_env cannot be set for multiple tasks

See original GitHub issue

Scenario

I am using the mysql command line executable plus the sh operator to perform various MySQL operations in DigDag. mysql automatically checks for MYSQL_PWD in the environment for the password to use. I am trying to set that environment variable with a Digdag secret.

I’d like to set that once and have the environment set up for child tasks.

Complications

Root _env

Setting an _env at the .dig root gives an error.

_env:
  MYSQL_PWD: ${secret:mysql.password}

gives error:

Workflow 'td_to_mysql' includes unknown keys: [_env] (model validation)

Parent Task _env

+many_mysql_comments:
  _env:
    MYSQL_PWD: ${secret:mysql.password}
  +command_1:
    sh>: mysql --execture "${SQL}"
  +command_2:
    sh>: mysql --execture "${MORE_SQL}"

gives the error +td_to_mysql+many_mysql_comments contains invalid keys: '_env': "{"_env":{"MYSQL_PWD":"${secret:mysql.password}"}}" (config)

Question

What is the best way to set up the environment so multiple tasks can use it? Thanks!

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
sonotscommented, Jan 21, 2019

I am also suffering with _env. I want to configure _env globally.

My scenario is like:

  1. Set _export: docker: globally so that I can run all tasks in a docker container.
  2. Want to get secrets in docker-entrypoint.sh from environment variables so that I can avoid embed secrets into docker images.
  3. It requires me to map all secrets to environment variables using _env for all tasks.

If it is possible to configure _env globally with a giant task or with a global _export, my suffering should be relieved.

1reaction
hiroyuki-satocommented, Jan 15, 2019

Hello, @friendofasquid

I’m thinking about another solution. I’ll let you know if I find it.

BTW, I’m maintaining mysql> operator. It uses secrets so You don’t need to set MYSQL_PWD environment variables.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to set environment variables for use in ansible roles
I have playbook running fine when I have environment variables and tasks defined in one single playbook without roles.
Read more >
Troubleshoot issues when passing environment variables to ...
I want to troubleshoot issues when passing environment variables to my Amazon Elastic Container Service (Amazon ECS) task.
Read more >
Use environment variables | Cloud Run Documentation
When you set environment variables, they are injected into the container and are accessible to your code. Environment variables are set as key/value...
Read more >
Introduction to environment variables - CircleCI
Use environment variables to set up various configuration options, and keep your set-up secure with secrets, private keys, and contexts.
Read more >
Using Variables - Ansible Documentation
Ansible uses variables to manage differences between systems. With Ansible, you can execute tasks and playbooks on multiple different systems with a single ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found