Skip to content
Permalink
Browse files

Use rake-tasks script for OBS API setup

/usr/share/obs/api/script/rake-tasks.sh script already sets proper file
permissions and run the tasks needed to setup the database and compile
the assets needed. We now run this script instead of manually
replicating those steps.
  • Loading branch information
athos-ribeiro committed May 29, 2018
1 parent 2a52be6 commit 4382e1ebe80367dc099a8e3096c390820d247b99
Showing with 6 additions and 64 deletions.
  1. +6 −64 salt/obs.sls
@@ -25,77 +25,19 @@ enable_obs_workers:
- repl: 'ENABLED=1'
- count: 1

patch1_obs_api_gemfile_lock:
{% if salt['grains.get']('api_setup') != 'done' %}
setup_obs_api:
cmd.run:
- name: sed -i 's/sass (3.4.22)/sass (3.4.23)/' /usr/share/obs/api/Gemfile.lock

patch2_obs_api_gemfile:
cmd.run:
- name: sed -i 's/^group :assets do$//' /usr/share/obs/api/Gemfile

patch3_obs_api_gemfile:
cmd.run:
- name: sed -i '93s/^end$//' /usr/share/obs/api/Gemfile

enable_apache_ssl_module:
cmd.run:
- name: a2enmod ssl

enable_apache_headers_module:
cmd.run:
- name: a2enmod headers

enable_apache_expires_module:
cmd.run:
- name: a2enmod expires

disable_default_apache2_site:
cmd.run:
- name: a2dissite 000-default.conf

enable_obs_site:
cmd.run:
- name: a2ensite obs

# set files on log and api dir to www-data
/usr/share/obs/api:
file.directory:
- user: www-data
- group: www-data
- recurse:
- user
- group

/var/log/obs:
file.directory:
- user: www-data
- group: www-data
- recurse:
- user
- group

{% if salt['grains.get']('db_setup') != 'done' %}
setup_database:
cmd.run:
- name: "RAILS_ENV=production bundle exec rake db:setup"
- name: /usr/share/obs/api/script/rake-tasks.sh setup
- cwd: /usr/share/obs/api
grains.present:
- name: db_setup
- name: api_setup
- value: done
{% endif %}

compile_assets:
cmd.run:
- name: "RAILS_ENV=production bundle exec rake assets:precompile"
- cwd: /usr/share/obs/api

restart_apache:
service.running:
- name: apache2
- enable: True
- watch_any:
- enable_obs_site
- disable_default_apache2_site
- file: /var/log/obs
- file: /usr/share/obs/api
- compile_assets
- watch:
- setup_obs_api

0 comments on commit 4382e1e

Please sign in to comment.
You can’t perform that action at this time.