rvm / rvm1-ansible

The official ansible RVM role to install and manage your Ruby versions.
MIT License
271 stars 136 forks source link

CentOS/RHEL: conditionally install which #165

Closed sbesson closed 5 years ago

sbesson commented 6 years ago

The default CentOS/RHEL installation does not include which which is a prerequisite for the role installation. The CentOS Docker image used for testing in Travis works around this limitation by installing which on top of the base centos:centos7 image.

Consumers of the role either in a playbook or as a dependency of a downstream role need to use pre_task, include_role or have another role installing the prerequisites - see https://github.com/openmicroscopy/ansible-role-jekyll-build/pull/10.

This PR proposes to tackle this limitation by conditionally installing the which package when appropriate using the ansible_distribution. The main impact of this change is its requirement for setting gather_facts to its default true value in the consuming playbooks.

Similar issues have been reported for other distributions and could be addressed the same way - see https://github.com/rvm/rvm1-ansible/issues/32

lpaulmp commented 6 years ago

@sbesson Thank for contributing. This PR fixes the issue in RHEL distros then I tend to agree, doesn't like to add external dependencies because of security issues but which is pretty standard and widely used. Then would you mind adding a short description on in the CHANGELOG.md about this change?

lpaulmp commented 6 years ago

@sbesson you may not need to be a root install a package, This lines allows the user user perform sudo task https://github.com/rvm/rvm1-ansible/blob/master/tests/dockerfiles/centos7/Dockerfile#L9-L10.

lpaulmp commented 6 years ago

@sbesson I think we have to append sudo group to the user

RUN useradd -ms /bin/bash user \
                 -G sudo user \
        && echo 'user ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
sbesson commented 6 years ago

@lpaulmp: 8d6e454 should implement the suggestion from https://github.com/rvm/rvm1-ansible/pull/165#discussion_r169755320 i.e. the system dependencies installation are handled in a dedicated sub-playbook included with ignore_errors: true to prevent breakages when the remote user cannot perform privilege escalation.