Ansible 如何获取可更新路径

Ansible 如何获取可更新路径,ansible,Ansible,有没有办法做到: export PATH=$PATH:/new/path/to/bin 在Ansible中,如果可能,不使用shell或命令 我试过这个 - name: Add another bin dir to system-wide $PATH. copy: dest: /etc/profile.d/custom-path.sh content: 'PATH=$PATH:{{ my_custom_path_var }}' 我从以下方面得到: 但它不起作用,因为路

有没有办法做到:

export PATH=$PATH:/new/path/to/bin
在Ansible中,如果可能,不使用shell或命令

我试过这个

 - name: Add another bin dir to system-wide $PATH.
  copy:
    dest: /etc/profile.d/custom-path.sh
    content: 'PATH=$PATH:{{ my_custom_path_var }}'
我从以下方面得到:

但它不起作用,因为路径会导致:

\$PATH:/new/path/to/bin
打破系统的轨道


谢谢

使用shell或命令将是:

  - name: Add pm2 to PATH
    shell: echo "PATH=$PATH:/new/path/to/bin" > /etc/environment
    become: true

但我还是更喜欢不使用shell/command的选项。

不使用shell模块的解决方案 而不是

    content: 'PATH=$PATH:{{ my_custom_path_var }}'
使用


变量扩展在/etc/environment中不起作用,这将破坏您的设置
    content: 'export PATH=$PATH:{{ my_custom_path_var }}'