main.yml 967 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. ---
  2. - name: install required packages
  3. sudo: true
  4. apt: pkg={{ item }}
  5. with_items:
  6. - python-pycurl
  7. - apt-transport-https
  8. - name: add nodesource apt key
  9. sudo: true
  10. apt_key: >
  11. id=68576280
  12. url=https://deb.nodesource.com/gpgkey/nodesource.gpg.key
  13. state=present
  14. - name: add nodesource apt repository
  15. sudo: true
  16. template: >
  17. src=nodesource.list.j2
  18. dest=/etc/apt/sources.list.d/nodesource.list
  19. owner=root
  20. group=root
  21. mode=644
  22. register: result
  23. - name: apt-get update
  24. sudo: true
  25. apt: update_cache=yes
  26. when: result | changed
  27. - name: install package
  28. sudo: true
  29. apt: pkg=nodejs
  30. - name: generate ~/.npmrc
  31. template: >
  32. src=npmrc.j2
  33. dest=~/.npmrc
  34. mode=0644
  35. when: nodejs.npmrc|length > 0
  36. - name: add `./node_modules/.bin` to PATH
  37. sudo: true
  38. copy: >
  39. content='export PATH="./node_modules/.bin:$PATH"'
  40. dest=/etc/profile.d/nodejs_path.sh
  41. mode=0644
  42. when: nodejs.add_node_modules_bin_to_path