Ansible setting profile source in ansible config

0 votes

I'm trying to install ruby from source and am using the template to export the path. This is my yaml file:

- name: clone rbenv
  git: repo=git://github.com/sstephenson/rbenv.git dest=/usr/local/rbenv
  become: yes

- template: src=templates/rbenv.sh.j2 dest=/etc/profile.d/rbenv.sh
  become: true

- name: clone ruby-build repo
  git: repo=git://github.com/sstephenson/ruby-build.git dest=~/ruby-build

- name: Install ruby-build
  shell: ./ruby-build/install.sh
  become: yes

- name: install jruby
  shell: . /etc/profile.d/rbenv.sh && rbenv install jruby-9.0.5.0
  become: yes

This playbook runs successfully but here I need to source profile with every command. I there any way I could set the source profile once in ansible.config file or any other way at all to achieve this without having to source it with every command.

Jul 10, 2018 in Ansible by ffdfd
• 5,550 points
6,518 views

1 answer to this question.

0 votes

Try and add path in .bashrc or

- name: install jruby
  shell: . /etc/profile.d/rbenv.sh && rbenv install jruby-9.0.5.0
  become: yes
  args:
   executable: /bin/bash -l

/bin/bash -l behaves as login shell
answered Jul 10, 2018 by ajs3033
• 7,300 points

Related Questions In Ansible

0 votes
1 answer

Using multiple config files using same template in a role in ansible

Go through this include_role module: tasks: - ...READ MORE

answered Jun 5, 2018 in Ansible by DareDev
• 6,890 points
4,224 views
0 votes
1 answer
0 votes
1 answer

How do I execute a shell script and then use the result in ansible

This can work out for you: - name: ...READ MORE

answered Apr 11, 2018 in Ansible by shubham
• 7,340 points
6,892 views
0 votes
1 answer

How to regex replace nested values in Ansible

I'm not aware of any built-in method ...READ MORE

answered Jun 17, 2018 in Ansible by shubham
• 7,340 points
5,503 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,035 views
+2 votes
1 answer
0 votes
1 answer

When conditional not working in Ansible

Your identation is wrong and when is ...READ MORE

answered Apr 27, 2018 in Ansible by ajs3033
• 7,300 points
5,591 views
0 votes
1 answer

Ansible: List all installed Apps in RedHat

Try this to get a list of ...READ MORE

answered Jul 13, 2018 in Ansible by ajs3033
• 7,300 points

edited Jul 13, 2018 by ajs3033 2,531 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP