Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The env option of the shell dependency has no effect #4167

Open
7 tasks done
gardar opened this issue Apr 15, 2024 · 0 comments
Open
7 tasks done

The env option of the shell dependency has no effect #4167

gardar opened this issue Apr 15, 2024 · 0 comments
Labels

Comments

@gardar
Copy link
Contributor

gardar commented Apr 15, 2024

Prerequisites

  • This was not already reported in the past (duplicate check)
  • It does reproduce it with code from main branch (latest unreleased version)
  • I include a minimal example for reproducing the bug
  • The bug is not trivial, as for those a direct pull-request is preferred
  • Running pip check does not report any conflicts
  • I was able to reproduce the issue on a different machine
  • The issue is not specific to any driver other than 'default' one

Environment

molecule 24.2.0 using python 3.11
    ansible:2.16.5
    azure:23.5.0 from molecule_plugins
    containers:23.5.0 from molecule_plugins requiring collections: ansible.posix>=1.3.0 community.docker>=1.9.1 containers.podman>=1.8.1
    default:24.2.0 from molecule
    docker:23.5.0 from molecule_plugins requiring collections: community.docker>=3.0.2 ansible.posix>=1.4.0
    ec2:23.5.0 from molecule_plugins
    gce:23.5.0 from molecule_plugins requiring collections: google.cloud>=1.0.2 community.crypto>=1.8.0
    podman:23.5.0 from molecule_plugins requiring collections: containers.podman>=1.7.0 ansible.posix>=1.3.0
    vagrant:23.5.0 from molecule_plugins

What happened

The env option of the shell dependency has no effect, despite what the documentation claims.

Environment variables can be passed to the dependency.

    dependency:
      name: shell
      command: path/to/command --flag1 subcommand --flag2
      env:
        FOO: bar

I suspect this has been broken since #3958

I tried the fix proposed in #4047, but it did not fully resolve the issue. It populates the environment variable in the shell; however, it doesn't make the environment variable available in the command section itself. That is, it made the environment variable accessible via $(env), but referencing it with ${MY_ENV_VAR} yields no results.

Reproducing example

---
dependency:
  name: shell
  command: "echo ${TEST_ENV_VAR} > /tmp/test.txt"
  env:
    TEST_ENV_VAR: hello
---
dependency:
  name: shell
  command: "echo $$(env) > /tmp/test.txt"
  env:
    TEST_ENV_VAR: hello
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Roadmap
Development

No branches or pull requests

2 participants