I want to run Ansible task similar to this one:
---
- name: symlink the nodejs executable to node
command: ln -sf "$(which nodejs)" /usr/bin/node
sudo: True
I found that the part "$(which nodejs)" would not be interpolated to string, but taken literalle - consequently, creating a malformed symlink.
How can I interpolate this part to a proper string with Ansible command module?
Well,
I was probably to eager to ask first rather than try to find solution myself. Here is one solution:
---
- name: Find path to nodejs
command: which nodejs
register: nodejs_path
- name: symlink the nodejs executable to node
command: "ln -sf {{ item }} /usr/bin/node"
sudo: True
with_items: nodejs_path.stdout
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With