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 Atul
• 5,470 points
337 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,000 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,520 points
177 views
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
• 6,480 points
218 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 16, 2018 in Ansible by shubham
• 6,480 points
581 views
0 votes
1 answer

Using hyphen in ansible

Hyphen - is used to specify list ...READ MORE

answered Jul 10, 2018 in Ansible by Kalgi
• 2,620 points
104 views
+13 votes
2 answers
0 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,000 points
465 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,000 points

edited Jul 13, 2018 by ajs3033 38 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.