rvm / rvm1-ansible

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

Rubies and Gems of non-root rvm installation owned by root #84

Closed wunzeco closed 8 years ago

wunzeco commented 8 years ago

It is expected that when rvm1_user variable is non-root user, the rubies and gems of rvm installation should not be owned by root even if ansible was applied as root user.

Playbook

- name: Jenkins instance
  sudo: yes
  hosts: localhost
  vars:
    jenkins_home: /var/lib/jenkins
    rvm1_install_flags: '--auto-dotfiles --user-install'
    rvm1_autolib_mode:  'disable'
    rvm1_install_path:  "{{ jenkins_home }}/.rvm"
    rvm1_rubies: [ ruby-2.2.3 ]
    rvm1_user: jenkins

  roles:
    - rvm_io.rvm1-ruby

files-not-rvm_user-owned.txt

==>>  AFTER installing rvm as jenkins user

root@ip-10-152-153-205:/opt/ansible# sudo su - jenkins
jenkins@ip-10-152-153-205:~$ ls -ld .rvm
drwxr-xr-x 25 jenkins jenkins 4096 Feb  9 10:22 .rvm

jenkins@ip-10-152-153-205:~$ ls -l .rvm
total 120
drwxr-xr-x  2 jenkins jenkins 4096 Feb  9 10:22 archives
drwxr-xr-x  2 jenkins jenkins 4096 Feb  9 10:22 bin
drwxr-xr-x  3 jenkins jenkins 4096 Feb  9 10:22 config
drwxr-xr-x  3 jenkins jenkins 4096 Feb  9 10:22 contrib
drwxr-xr-x  2 jenkins jenkins 4096 Feb  9 10:22 docs
drwxr-xr-x  2 jenkins jenkins 4096 Feb  9 10:22 environments
drwxr-xr-x  2 jenkins jenkins 4096 Feb  9 10:22 examples
drwxr-xr-x  2 jenkins jenkins 4096 Feb  9 10:22 gem-cache
drwxr-xr-x  4 jenkins jenkins 4096 Feb  9 10:22 gems
drwxr-xr-x  4 jenkins jenkins 4096 Feb  9 10:22 gemsets
drwxr-xr-x  4 jenkins jenkins 4096 Feb  9 10:22 help
drwxr-xr-x  2 jenkins jenkins 4096 Feb  9 10:22 hooks
-rw-r--r--  1 jenkins jenkins   11 Feb  9 10:22 installed.at
drwxr-xr-x  3 jenkins jenkins 4096 Feb  9 10:22 lib
-rw-r--r--  1 jenkins jenkins  603 Feb  9 10:22 LICENSE
drwxr-xr-x  5 jenkins jenkins 4096 Feb  9 10:22 log
drwxr-xr-x  3 jenkins jenkins 4096 Feb  9 10:22 man
drwxr-xr-x 10 jenkins jenkins 4096 Feb  9 10:22 patches
drwxr-xr-x  5 jenkins jenkins 4096 Feb  9 10:22 patchsets
-rw-r--r--  1 jenkins jenkins 9706 Feb  9 10:22 README
-rw-r--r--  1 jenkins jenkins    7 Feb  9 10:22 RELEASE
drwxr-xr-x  3 jenkins jenkins 4096 Feb  9 10:22 rubies
drwxr-xr-x  5 jenkins jenkins 4096 Feb  9 10:22 scripts
drwxr-xr-x  3 jenkins jenkins 4096 Feb  9 10:22 src
drwxr-xr-x  2 jenkins jenkins 4096 Feb  9 10:22 tmp
drwxr-xr-x  2 jenkins jenkins 4096 Feb  9 10:22 user
-rw-r--r--  1 jenkins jenkins    8 Feb  9 10:22 VERSION
drwxr-xr-x  2 jenkins jenkins 4096 Feb  9 10:22 wrappers

==>>  HOWEVER - ruby gems and rubies are not correctly owned by jenkins

jenkins@ip-10-152-153-205:~$ find .rvm/ -user root -exec ls -l {} \; | tee files-not-rvm_user-owned.txt
lrwxrwxrwx 1 root root 41 Feb  9 10:22 .rvm/wrappers/default -> /var/lib/jenkins/.rvm/wrappers/ruby-2.2.3
lrwxrwxrwx 1 root root 45 Feb  9 10:22 .rvm/environments/default -> /var/lib/jenkins/.rvm/environments/ruby-2.2.3
total 0
-rwxr-xr-x 1 root root 291 Feb  9 10:22 .rvm/gems/ruby-2.2.3/wrappers/bundle
-rwxr-xr-x 1 root root 292 Feb  9 10:22 .rvm/gems/ruby-2.2.3/wrappers/bundler
-rw-r--r-- 1 root root 263168 Feb  9 10:22 .rvm/gems/ruby-2.2.3/cache/bundler-1.11.2.gem
total 4
drwxr-xr-x 6 root root 4096 Feb  9 10:22 bundler-1.11.2
total 144
drwxr-xr-x 2 root root  4096 Feb  9 10:22 bin
-rw-r--r-- 1 root root  1421 Feb  9 10:22 bundler.gemspec
-rw-r--r-- 1 root root 74794 Feb  9 10:22 CHANGELOG.md
-rw-r--r-- 1 root root  3520 Feb  9 10:22 CODE_OF_CONDUCT.md
-rw-r--r-- 1 root root  2413 Feb  9 10:22 CONTRIBUTING.md
-rw-r--r-- 1 root root  9435 Feb  9 10:22 DEVELOPMENT.md
drwxr-xr-x 2 root root  4096 Feb  9 10:22 exe
-rw-r--r-- 1 root root  4443 Feb  9 10:22 ISSUES.md
drwxr-xr-x 3 root root  4096 Feb  9 10:22 lib
-rw-r--r-- 1 root root  1118 Feb  9 10:22 LICENSE.md
drwxr-xr-x 2 root root  4096 Feb  9 10:22 man
-rw-r--r-- 1 root root  9415 Feb  9 10:22 Rakefile
-rw-r--r-- 1 root root  2389 Feb  9 10:22 README.md
<...SNIP...>

See attached files 
wunzeco commented 8 years ago

FIX


root@ip-10-152-153-205:/opt/ansible# sudo su - jenkins
jenkins@ip-10-152-153-205:~$ ls -ld .rvm
drwxr-xr-x 25 jenkins jenkins 4096 Feb  9 10:38 .rvm
jenkins@ip-10-152-153-205:~$ ls -l .rvm
total 120
drwxr-xr-x  2 jenkins jenkins 4096 Feb  9 10:39 archives
drwxr-xr-x  2 jenkins jenkins 4096 Feb  9 10:38 bin
drwxr-xr-x  3 jenkins jenkins 4096 Feb  9 10:39 config
drwxr-xr-x  3 jenkins jenkins 4096 Feb  9 10:38 contrib
drwxr-xr-x  2 jenkins jenkins 4096 Feb  9 10:38 docs
drwxr-xr-x  2 jenkins jenkins 4096 Feb  9 10:39 environments
drwxr-xr-x  2 jenkins jenkins 4096 Feb  9 10:38 examples
drwxr-xr-x  2 jenkins jenkins 4096 Feb  9 10:38 gem-cache
drwxr-xr-x  4 jenkins jenkins 4096 Feb  9 10:39 gems
drwxr-xr-x  4 jenkins jenkins 4096 Feb  9 10:38 gemsets
drwxr-xr-x  4 jenkins jenkins 4096 Feb  9 10:38 help
drwxr-xr-x  2 jenkins jenkins 4096 Feb  9 10:38 hooks
-rw-r--r--  1 jenkins jenkins   11 Feb  9 10:38 installed.at
drwxr-xr-x  3 jenkins jenkins 4096 Feb  9 10:38 lib
-rw-r--r--  1 jenkins jenkins  603 Feb  9 10:38 LICENSE
drwxr-xr-x  5 jenkins jenkins 4096 Feb  9 10:39 log
drwxr-xr-x  3 jenkins jenkins 4096 Feb  9 10:38 man
drwxr-xr-x 10 jenkins jenkins 4096 Feb  9 10:38 patches
drwxr-xr-x  5 jenkins jenkins 4096 Feb  9 10:38 patchsets
-rw-r--r--  1 jenkins jenkins 9706 Feb  9 10:38 README
-rw-r--r--  1 jenkins jenkins    7 Feb  9 10:38 RELEASE
drwxr-xr-x  3 jenkins jenkins 4096 Feb  9 10:39 rubies
drwxr-xr-x  5 jenkins jenkins 4096 Feb  9 10:38 scripts
drwxr-xr-x  3 jenkins jenkins 4096 Feb  9 10:38 src
drwxr-xr-x  2 jenkins jenkins 4096 Feb  9 10:39 tmp
drwxr-xr-x  2 jenkins jenkins 4096 Feb  9 10:39 user
-rw-r--r--  1 jenkins jenkins    8 Feb  9 10:38 VERSION
drwxr-xr-x  2 jenkins jenkins 4096 Feb  9 10:39 wrappers
jenkins@ip-10-152-153-205:~$ find .rvm/ -user root -exec ls -l {} \;
jenkins@ip-10-152-153-205:~$

files-not-rvm_user-owned-after-fix.txt

wunzeco commented 8 years ago

Fix merged into master. For further details see https://github.com/rvm/rvm1-ansible/pull/85

Nothing more to do.