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,530 points
642 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,280 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,810 points
535 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,890 points
777 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,890 points
959 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
220 views
+13 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 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
152 views
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,280 points
721 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,280 points

edited Jul 13, 2018 by ajs3033 60 views