Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ coverage

spec/fixtures/testapp1/railsbox

#ignore ansible retries
*.retry
#ignore gedit backup files
*.*~
4 changes: 4 additions & 0 deletions templates/ansible/roles/base/tasks/main.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
- name: Create application user
user: name={{ user_name }} group={{ group_name }} shell=/bin/bash home={{ user_home_path }}

- name: Add ansible user '{{ ansible_user }}' to group '{{ group_name }}'
user: name={{ ansible_user }} groups={{ group_name }} append=yes


- name: Setup script to read application environment
template: src=read_environment.sh.j2 dest=/etc/profile.d/read_environment.sh
notify:
Expand Down
15 changes: 12 additions & 3 deletions templates/ansible/roles/deploy/tasks/main.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,32 @@
- vendor/bundle

- name: Install gems
command: /bin/bash -lc 'bundle install --deployment --without="development test"'
# "/bin/basg -lc" didn't start a login shell, so RVM not properly loaded and "bundle not installed" error appear.
# however shell with " -i" become_user did the thing
shell: bundle install --deployment --without="development test"
args:
chdir: '{{ this_release_path }}'
become: yes
become_user: "'{{ ruby_user_name }}' -i"


- name: Precompile assets
command: /bin/bash -lc 'bundle exec rake assets:precompile'
shell: bundle exec rake assets:precompile
environment:
RAILS_ENV: '{{ rails_env }}'
args:
chdir: '{{ this_release_path }}'
become: yes
become_user: "'{{ ruby_user_name }}' -i"

- name: Migrate database
command: /bin/bash -lc 'bundle exec rake db:migrate'
shell: bundle exec rake db:migrate
environment:
RAILS_ENV: '{{ rails_env }}'
args:
chdir: '{{ this_release_path }}'
become: yes
become_user: "'{{ ruby_user_name }}' -i"

- name: Symlink new release
file: src={{ this_release_path }} dest={{ app_path }} state=link force=yes
Expand Down