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

win_environment doesnt resolve %var% #535

Open
markatdxb opened this issue Aug 2, 2023 · 1 comment
Open

win_environment doesnt resolve %var% #535

markatdxb opened this issue Aug 2, 2023 · 1 comment

Comments

@markatdxb
Copy link

SUMMARY

im trying to set 2 env vars when the second one should resolve the first one
when using SETX command this works fine but using module the resolv doesnt work

ISSUE TYPE
  • Bug Report
COMPONENT NAME

win_environment

ANSIBLE VERSION
8.1.0
2.15.1
COLLECTION VERSION

CONFIGURATION

OS / ENVIRONMENT
STEPS TO REPRODUCE
- name: Update Env vars
      ansible.windows.win_environment:
        state: present
        name: "{{ item.var_name }}"
        value: "{{ item.var_value }}"
        level: machine
      loop:
        - var_name: VAR_A
          var_value: VALUE_A
        - var_name: VAR_B
          var_value: '%VAR_A%-VALUE_B'
EXPECTED RESULTS
set
VAR_A=VALUE_A
VAR_B=VALUE_A-VALUE_B
ACTUAL RESULTS
set
VAR_A=VALUE_A
VAR_B=%VAR_A%-VALUE_B
@jborean93
Copy link
Collaborator

jborean93 commented Aug 7, 2023

I think this might be related to dotnet/runtime#1442 where the dotnet function SetEnvironmentVariable sets the raw registry value as a REG_SZ instead of a REG_EXPAND_SZ needed to expand %env_var%. The fix would be to have win_environment just edit the registry directly which requires a change in the module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants