Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

97 wiersze
2.2KB

  1. ---
  2. - name: install dependencies
  3. apt: name={{item}}
  4. with_items:
  5. - zlib1g-dev
  6. - build-essential
  7. - libssl-dev
  8. - libreadline-dev
  9. - libyaml-dev
  10. - libgdbm-dev
  11. - libncurses5-dev
  12. - automake
  13. - libtool
  14. - bison
  15. - libffi-dev
  16. - git
  17. - curl
  18. - libxml2
  19. - libxml2-dev
  20. - libxslt1-dev
  21. - name: clone rbenv
  22. git:
  23. repo: https://github.com/rbenv/rbenv.git
  24. dest: "{{rbenv_directory}}"
  25. depth: 1
  26. register: cloned_rbenv
  27. - name: setup rbenv
  28. lineinfile:
  29. dest: ~{{rbenv_user}}/.profile
  30. line: '{{item}}'
  31. with_items:
  32. - 'export PATH="{{rbenv_directory}}/bin:$PATH"'
  33. - 'eval "$(rbenv init -)"'
  34. - name: setup ruby-build
  35. git:
  36. repo: https://github.com/rbenv/ruby-build.git
  37. dest: "{{rbenv_directory}}/plugins/ruby-build"
  38. depth: 1
  39. register: cloned_ruby_build
  40. # do not run this as a handler but as a task here because we will need this before
  41. # end of playbook execution.
  42. - name: change ownership of rbenv
  43. file:
  44. path: "{{rbenv_directory}}"
  45. owner: '{{rbenv_user}}'
  46. group: '{{rbenv_group}}'
  47. recurse: yes
  48. when: cloned_ruby_build.changed or cloned_rbenv.changed
  49. - name: get installed ruby versions
  50. command: rbenv versions
  51. register: rbenv_versions
  52. changed_when: False
  53. failed_when: False
  54. become: yes
  55. become_user: '{{rbenv_user}}'
  56. become_method: su
  57. environment:
  58. PATH: "{{rbenv_directory}}/bin:{{ ansible_env.PATH }}"
  59. - name: install ruby
  60. command: rbenv install {{ruby_version}}
  61. when: ruby_version not in rbenv_versions.stdout
  62. async: 3600
  63. poll: 5
  64. become: yes
  65. become_user: '{{rbenv_user}}'
  66. become_method: su
  67. environment:
  68. PATH: "{{rbenv_directory}}/bin:{{ ansible_env.PATH }}"
  69. # no need to rbenv rehash here since su -c will re-source .profile anyways
  70. - name: get selected rbenv ruby version
  71. command: rbenv version
  72. register: rbenv_version
  73. changed_when: False
  74. become: yes
  75. become_user: '{{rbenv_user}}'
  76. become_method: su
  77. environment:
  78. PATH: "{{rbenv_directory}}/bin:{{ ansible_env.PATH }}"
  79. - name: select ruby version
  80. command: rbenv global {{ruby_version}}
  81. when: ruby_version not in rbenv_version.stdout
  82. become: yes
  83. become_user: '{{rbenv_user}}'
  84. become_method: su
  85. environment:
  86. PATH: "{{rbenv_directory}}/bin:{{ ansible_env.PATH }}"