SuperTux88's Diaspora Saltstack Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.9KB

  1. {%- from "diaspora/map.jinja" import diaspora with context %}
  2. diaspora_dependencies:
  3. pkg.installed:
  4. - pkgs: {{ diaspora.dependencies|json }}
  5. - require:
  6. - pkg: diaspora_database_dependency
  7. diaspora_database_dependency:
  8. pkg.installed:
  9. {%- if diaspora.database.type == "mysql" %}
  10. - name: {{ diaspora.mysql_package }}
  11. {%- else %}
  12. - name: {{ diaspora.postgresql_package }}
  13. {%- endif %}
  14. {%- if diaspora.install_redis %}
  15. redis_package:
  16. pkg.installed:
  17. - name: {{ diaspora.redis_package }}
  18. {%- endif %}
  19. diaspora_user:
  20. user.present:
  21. - name: {{ diaspora.user.username }}
  22. {%- if 'shell' in diaspora.user %}
  23. - shell: {{ diaspora.user.shell }}
  24. {%- endif %}
  25. {%- if 'home' in diaspora.user %}
  26. - home: {{ diaspora.user.home }}
  27. {%- endif %}
  28. diaspora_rvm_gpg_key:
  29. cmd.run:
  30. - name: gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
  31. - unless: gpg --list-keys 409B6B1796C275462A1703113804BB82D39DC0E3
  32. - runas: {{ diaspora.user.username }}
  33. - require:
  34. - user: diaspora_user
  35. diaspora_rvm_ruby:
  36. rvm.installed:
  37. - name: ruby-{{ diaspora.ruby_version }}
  38. - user: {{ diaspora.user.username }}
  39. - default: True
  40. - require:
  41. - pkg: diaspora_dependencies
  42. - cmd: diaspora_rvm_gpg_key
  43. diaspora_rvm_gemset:
  44. rvm.gemset_present:
  45. - name: diaspora
  46. - ruby: ruby-{{ diaspora.ruby_version }}
  47. - user: {{ diaspora.user.username }}
  48. - require:
  49. - rvm: diaspora_rvm_ruby
  50. diaspora_install_bundler:
  51. gem.installed:
  52. - name: bundler
  53. - user: {{ diaspora.user.username }}
  54. - ruby: ruby-{{ diaspora.ruby_version }}@diaspora
  55. - require:
  56. - rvm: diaspora_rvm_gemset
  57. diaspora_install_directory:
  58. file.directory:
  59. - name: {{ diaspora.install_path }}
  60. - user: {{ diaspora.user.username }}
  61. - mode: 755
  62. - require:
  63. - user: diaspora_user
  64. diaspora_git:
  65. git.latest:
  66. - name: {{ diaspora.repository }}
  67. - rev: {{ diaspora.version }}
  68. - target: {{ diaspora.install_path }}
  69. - user: {{ diaspora.user.username }}
  70. - require:
  71. - file: diaspora_install_directory
  72. diaspora_rvm_ruby_version_alias:
  73. cmd.run:
  74. - name: rvm alias create $(cat {{ diaspora.install_path }}/.ruby-version) ruby-{{ diaspora.ruby_version }}
  75. - runas: diaspora
  76. - unless: rvm alias list | grep "$(cat {{ diaspora.install_path }}/.ruby-version) => ruby-{{ diaspora.ruby_version }}"
  77. - require:
  78. - git: diaspora_git
  79. diaspora_bundle_install:
  80. cmd.run:
  81. - name: rvm ruby-{{ diaspora.ruby_version }}@diaspora do bin/bundle install --jobs $(nproc) --deployment --without test development --with {{ diaspora.database.type }}
  82. - runas: diaspora
  83. - cwd: {{ diaspora.install_path }}
  84. - unless: rvm ruby-{{ diaspora.ruby_version }}@diaspora do bin/bundle check
  85. - env:
  86. - RAILS_ENV: {{ diaspora.environment }}
  87. - require:
  88. - git: diaspora_git