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

Add support for passing environment variables to convert2rhel during convert. #52

Merged
merged 4 commits into from
May 3, 2024

Conversation

jeffmcutter
Copy link
Contributor

No description provided.

@@ -6,7 +6,7 @@

- name: Convert2RHEL convert
ansible.builtin.shell: >
export PATH={{ convert_os_path }};
export PATH={{ convert_os_path }} {{ convert_convert2rhel_env_vars }};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move this down? I'm wondering if that could not allow for some incorrect usage, for example:

convert_convert2rhel_env_vars = "foo_bar"
...
export PATH={{ convert_os_path }} foo_bar

Thus overriding the PATH variable.

I think it should be safer if we used like:

Suggested change
export PATH={{ convert_os_path }} {{ convert_convert2rhel_env_vars }};
export PATH={{ convert_os_path }};
export {{ convert_convert2rhel_env_vars }};

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, doing a quick search, it seems that ansible.builtin.shell has a environment option, maybe we could try to adapt this code to use it?

https://stackoverflow.com/a/27736434

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my original plan, but I found the export already there and followed that lead. I'm hesitant to move that because I'm not sure I can test it, having never ran into the PATH issue myself.

redhat-cop/infra.leapp#117

@scott-vick Was there a reason you added the export like this and not using the task environment parameter? Can you share any pointers on how I could test this if I were to move it?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never touched that one, so not sure why it was done that way. Think you are confusing my work on infra.leapp.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think his question was more towards: "why are infra.leapp using export PATH=... instead of using the environment field for the shell command?"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @scott-vick,

infra.convert2rhel started out as a copy of infra.leapp as both do similar things. It was then adapted from leapp to convert2rhel. The PR I shared (redhat-cop/infra.leapp#117) is from your PR to infra.leapp which added the export to infra.leapp.

The question is the same in either case. Is there a reason that you did the export and not the environment? Seems like not, but I don't want to undo it if there's a reason for it. If there's no reason, then I'll try to move all the ENV vars to environment on the task instead of export in the command.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot remember if we tried env or not... I thought we did and it didn't work but I am not positive it would be worth testing again... but this was related to duzo issues so might be hard to test.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @scott-vick,

infra.convert2rhel started out as a copy of infra.leapp as both do similar things. It was then adapted from leapp to convert2rhel. The PR I shared (redhat-cop/infra.leapp#117) is from your PR to infra.leapp which added the export to infra.leapp.

The question is the same in either case. Is there a reason that you did the export and not the environment? Seems like not, but I don't want to undo it if there's a reason for it. If there's no reason, then I'll try to move all the ENV vars to environment on the task instead of export in the command.

When I created it, I had forgotten about the "environment" attribute being available so I just did it as an inline setting for the shell commands. If you want to change it around, I don't see any issue with it.

Copy link
Collaborator

@r0x0d r0x0d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a small comment about the way we export the env vars

@jeffmcutter
Copy link
Contributor Author

jeffmcutter commented May 3, 2024

I have tried moving the export $PATH to the task environment and it doesn't work with $PATH, nor does it work with not setting analysis_os_path at all and using default(omit). It does work if you explicitly set the path (analysis_os_path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin).

  environment:
    PATH: "{{ analysis_os_path | default(omit) }}"

That said, I don't think we want to move the export PATH. I did convert the convert_convert2rhel_env_vars to use the task environment parameter though.

@r0x0d r0x0d merged commit 1ec5dfd into redhat-cop:main May 3, 2024
21 checks passed
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

Successfully merging this pull request may close these issues.

4 participants