--- - name: include env vars include_vars: "{{ rbenv.env }}.yml" - include: apt_build_depends.yml when: ansible_pkg_mgr == 'apt' - name: set rbenv_owner set_fact: 'rbenv_owner={{ rbenv_owner | default("root", true) }}' - name: checkout rbenv_repo for system remote_user: '{{ rbenv_owner }}' git: > repo={{ rbenv_repo }} dest={{ rbenv_root }} version={{ rbenv.version }} accept_hostkey=yes force=yes when: rbenv.env == "system" - name: create plugins directory for system remote_user: '{{ rbenv_owner }}' file: state=directory path={{ rbenv_root }}/plugins when: rbenv.env == "system" - name: install plugins for system remote_user: '{{ rbenv_owner }}' git: > repo=https://github.com/rbenv/ruby-build.git dest={{ rbenv_root }}/plugins/ruby-build accept_hostkey=yes force=yes - name: Set group ownership of content under rbenv_root shell: find '{{ rbenv_root }}' \( -iname ".git" -prune \) -o ! -group '{{ item }}' -exec chgrp -v '{{ item }}' {} + | head -n 1 with_items: '{{ rbenv_group }}' when: - rbenv.env == "system" - rbenv_group is defined - rbenv_group != None register: rbenv_chgrp changed_when: '"changed group" in rbenv_chgrp.stdout' - name: Set group permissions of content under rbenv_root shell: find '{{ rbenv_root }}' \( -iname ".git" -prune \) -o -type d ! -perm -g+s -exec chmod -v g+rwxs {} + | head -n 1 when: - rbenv.env == "system" - rbenv_group is defined - rbenv_group != None register: rbenv_chmod changed_when: '"changed from" in rbenv_chmod.stdout' - name: add rbenv initialization to profile system-wide template: src=rbenv.sh.j2 dest=/etc/profile.d/rbenv.sh owner=root group=root mode=0755 when: - ansible_os_family != 'OpenBSD' - name: check ruby {{ rbenv.ruby_version }} installed for system shell: $SHELL -lc "rbenv versions | grep {{ rbenv.ruby_version }}" register: ruby_installed changed_when: false ignore_errors: yes always_run: yes when: rbenv.env == "system" - name: install ruby {{ rbenv.ruby_version }} for system shell: bash -lc "rbenv install {{ rbenv.ruby_version }}" when: - rbenv.env == "system" - ruby_installed.rc != 0 - name: check if current system ruby version is {{ rbenv.ruby_version }} shell: $SHELL -lc "rbenv version | cut -d ' ' -f 1 | grep -Fx '{{ rbenv.ruby_version }}'" register: ruby_selected changed_when: false ignore_errors: yes always_run: yes when: rbenv.env == "system" - name: set ruby {{ rbenv.ruby_version }} for system shell: bash -lc "rbenv global {{ rbenv.ruby_version }} && rbenv rehash" when: - rbenv.env == "system" - ruby_selected.rc != 0