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 check for binary to determine whether to execute script #12

Open
decentral1se opened this issue Aug 8, 2024 · 1 comment
Open

Comments

@decentral1se
Copy link

- name: Execute the nvm installation script
command: "{{ nvm_dir }}/install_nvm_{{ nvm_node_version }}.script"
when: nvm_installation_script_template is defined and nvm_installation_script_template.changed
# the tag is needed so that linter wouldn't complain about this not being handler,
# and handlers are so unstable I eventually decided not to use them in this role
tags: skip_ansible_lint

I saw a case where the script was put in place but for some reason didn't run the install (maybe ctrl-c was the culprit during runtime) and then on 2nd run, it failed at the symlink task because it never ran the script.

@grzegorznowak
Copy link
Owner

grzegorznowak commented Aug 13, 2024

Hey @decentral1se !
Yeah I can see how it might not be handling edge cases properly with half-ran envs etc.
It would be more idempotent had we have a variable registered that denotes whether the installation ran or not at all.

Can you put this before the installation step

- name: Probe the env for the nvm binary
  shell: which nvm || echo "nvm missing"
  register: nvm_probe

and then augment the install step with

when: nvm_installation_script_template is defined and (nvm_installation_script_template.changed or nvm_probe.stdout == "nvm missing")

EDIT: tweaked the when: part for more sense

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