From dc6cc3528d8241424dc2cad1c0f25d110b9d83e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= <15726+Senen@users.noreply.github.com> Date: Mon, 16 Oct 2023 16:20:29 +0200 Subject: [PATCH] Simplify commands by using the newly added variable --- roles/errbit/tasks/main.yml | 14 +++++++------- roles/errbit/templates/errbit.service | 2 +- roles/rails/tasks/main.yml | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/roles/errbit/tasks/main.yml b/roles/errbit/tasks/main.yml index 95e8070a..b3b4811a 100644 --- a/roles/errbit/tasks/main.yml +++ b/roles/errbit/tasks/main.yml @@ -35,7 +35,7 @@ executable: /bin/bash - name: Install libv8-node for the right platform - shell: "source /home/{{ deploy_user }}/.rvm/scripts/rvm && gem install libv8-node --version '{{ libv8_version.stdout }}' --platform x86_64-linux-libc" + shell: "{{ rvm_command }} && gem install libv8-node --version '{{ libv8_version.stdout }}' --platform x86_64-linux-libc" args: chdir: "{{ errbit_dir }}" executable: /bin/bash @@ -48,13 +48,13 @@ executable: /bin/bash - name: Install the mini_racer gem - shell: "source /home/{{ deploy_user }}/.rvm/scripts/rvm && gem install mini_racer --version '{{ mini_racer_version.stdout }}'" + shell: "{{ rvm_command }} && gem install mini_racer --version '{{ mini_racer_version.stdout }}'" args: chdir: "{{ errbit_dir }}" executable: /bin/bash - name: Install Errbit dependencies - shell: "source /home/{{ deploy_user }}/.rvm/scripts/rvm && bundle install" + shell: "{{ rvm_command }} && bundle install" args: chdir: "{{ errbit_dir }}" executable: /bin/bash @@ -81,7 +81,7 @@ - when: not existing_secret_key_base.found block: - name: Generate secret key - shell: "source /home/{{ deploy_user }}/.rvm/scripts/rvm && bin/rake secret" + shell: "{{ rvm_command }} && bin/rake secret" register: secret_key_base args: chdir: "{{ errbit_dir }}" @@ -93,13 +93,13 @@ line: "SECRET_KEY_BASE={{ secret_key_base.stdout }}" - name: Setup Errbit - shell: "source /home/{{ deploy_user }}/.rvm/scripts/rvm && RAILS_ENV={{ env }} bin/rake errbit:bootstrap" + shell: "{{ rvm_command }} && RAILS_ENV={{ env }} bin/rake errbit:bootstrap" args: chdir: "{{ errbit_dir }}" executable: /bin/bash - name: Precompile Errbit assets - shell: "source /home/{{ deploy_user }}/.rvm/scripts/rvm && RAILS_ENV={{ env }} bin/rake assets:precompile" + shell: "{{ rvm_command }} && RAILS_ENV={{ env }} bin/rake assets:precompile" args: chdir: "{{ errbit_dir }}" executable: /bin/bash @@ -121,7 +121,7 @@ enabled: true - name: Create app if it does not exist - shell: 'source /home/{{ deploy_user }}/.rvm/scripts/rvm && bin/rails runner -e {{ env }} "App.create(name: \"{{ domain }}\")"' + shell: '{{ rvm_command }} && bin/rails runner -e {{ env }} "App.create(name: \"{{ domain }}\")"' args: chdir: "{{ errbit_dir }}" executable: /bin/bash diff --git a/roles/errbit/templates/errbit.service b/roles/errbit/templates/errbit.service index 8d496270..00f03365 100644 --- a/roles/errbit/templates/errbit.service +++ b/roles/errbit/templates/errbit.service @@ -7,7 +7,7 @@ After=mongodb.service network.target Type=simple WorkingDirectory={{ errbit_dir }} Environment=RAILS_ENV={{ env }} -ExecStart=/bin/bash -lc 'source {{ home_dir }}/.rvm/scripts/rvm && bundle exec puma -C {{ errbit_dir }}/config/puma.default.rb -e {{ env }}' +ExecStart=/bin/bash -lc '{{ rvm_command }} && bundle exec puma -C {{ errbit_dir }}/config/puma.default.rb -e {{ env }}' Restart=always User={{ errbit_user }} Group={{ errbit_group }} diff --git a/roles/rails/tasks/main.yml b/roles/rails/tasks/main.yml index a252fb9e..35bc6419 100644 --- a/roles/rails/tasks/main.yml +++ b/roles/rails/tasks/main.yml @@ -1,12 +1,12 @@ --- - name: Configure Bundler path - shell: "source /home/{{ deploy_user }}/.rvm/scripts/rvm && bundle config --local path {{ shared_dir }}/bundle" + shell: "{{ rvm_command }} && bundle config --local path {{ shared_dir }}/bundle" args: chdir: "{{ release_dir }}" executable: /bin/bash - name: Configure Bundler environments - shell: "source /home/{{ deploy_user }}/.rvm/scripts/rvm && bundle config --local without development:test" + shell: "{{ rvm_command }} && bundle config --local without development:test" args: chdir: "{{ release_dir }}" executable: /bin/bash @@ -26,7 +26,7 @@ when: not usr_bin_mkdir.stat.exists - name: Install gems (this may take a few minutes) - shell: "source /home/{{ deploy_user }}/.rvm/scripts/rvm && bundle install" + shell: "{{ rvm_command }} && bundle install" args: chdir: "{{ release_dir }}" executable: /bin/bash