Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

77 строки
2.0KB

  1. ---
  2. - name: clone nodenv
  3. git:
  4. repo: https://github.com/nodenv/nodenv.git
  5. dest: "{{nodenv_directory}}"
  6. depth: 1
  7. register: cloned_nodenv
  8. - name: setup nodenv
  9. lineinfile:
  10. dest: ~{{nodenv_user}}/.profile
  11. line: '{{item}}'
  12. with_items:
  13. - 'export PATH="{{nodenv_directory}}/bin:$PATH"'
  14. - 'eval "$(nodenv init -)"'
  15. - name: setup node-build
  16. git:
  17. repo: https://github.com/nodenv/node-build.git
  18. dest: "{{nodenv_directory}}/plugins/node-build"
  19. depth: 1
  20. register: cloned_node_build
  21. # do not run this as a handler but as a task here because we will need this before
  22. # end of playbook execution.
  23. - name: change ownership of nodenv
  24. file:
  25. path: "{{nodenv_directory}}"
  26. owner: '{{nodenv_user}}'
  27. group: '{{nodenv_group}}'
  28. recurse: yes
  29. when: cloned_node_build.changed or cloned_nodenv.changed
  30. - name: get installed node versions
  31. command: nodenv versions
  32. register: nodenv_versions
  33. changed_when: False
  34. failed_when: False
  35. become: yes
  36. become_user: '{{nodenv_user}}'
  37. become_method: su
  38. environment:
  39. PATH: "{{nodenv_directory}}/bin:{{ ansible_env.PATH }}"
  40. - name: install node
  41. command: nodenv install {{node_version}}
  42. when: node_version not in nodenv_versions.stdout
  43. async: 3600
  44. poll: 5
  45. become: yes
  46. become_user: '{{nodenv_user}}'
  47. become_method: su
  48. environment:
  49. PATH: "{{nodenv_directory}}/bin:{{ ansible_env.PATH }}"
  50. # no need to nodenv rehash here since su -c will re-source .profile anyways
  51. - name: get selected nodenv node version
  52. command: nodenv version
  53. register: nodenv_version
  54. changed_when: False
  55. become: yes
  56. become_user: '{{nodenv_user}}'
  57. become_method: su
  58. environment:
  59. PATH: "{{nodenv_directory}}/bin:{{ ansible_env.PATH }}"
  60. - name: select node version
  61. command: nodenv global {{node_version}}
  62. when: node_version not in nodenv_version.stdout
  63. become: yes
  64. become_user: '{{nodenv_user}}'
  65. become_method: su
  66. environment:
  67. PATH: "{{nodenv_directory}}/bin:{{ ansible_env.PATH }}"