Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify rbenv_users interface: Username only #25

Merged
merged 1 commit into from Jan 15, 2015
Merged

Conversation

@leonelgalan
Copy link
Contributor

@leonelgalan leonelgalan commented Jan 15, 2015

Based on my own incapacity of reading the README (#24) I thought we could simplify the interface for the rbenv_users variable. Instead of a hash with the user information including home, use ~ to figure it out. I was trying to use $HOME, but came across http://stackoverflow.com/questions/22873409/ansible-sudo-user-not-using-the-correct-home-directory, long story short, ~ seems to do the trick just fine.

{{ item[1].home }}/.rbenv, or {{ rbenv_root }} as I prefer to call it, was created when each user cloned the repo, so there is no need to chown it. Also user and group name might be different.

Here is the configuration and output for a local run with two users:

  - role: ../ansible-rbenv-role
    rbenv:
      env: user
      version: v0.4.0
      ruby_version: 2.1.5
    rbenv_users:
      - deploy
      - vagrant
TASK: [../ansible-rbenv-role | include env vars] ******************************
ok: [default]

TASK: [../ansible-rbenv-role | install build depends] *************************
changed: [default] => (item=build-essential,git,libcurl4-openssl-dev,libreadline-dev,libssl-dev,libxml2-dev,libxslt1-dev,zlib1g-dev)

TASK: [../ansible-rbenv-role | install build depends] *************************
skipping: [default]

TASK: [../ansible-rbenv-role | homebrew name={{ item }} state=present] ********
skipping: [default] => (item=openssl)
skipping: [default] => (item=libyaml)

TASK: [../ansible-rbenv-role | homebrew_tap tap=homebrew/dupes state=present] ***
skipping: [default]

TASK: [../ansible-rbenv-role | homebrew name=apple-gcc42 state=present] *******
skipping: [default]

TASK: [../ansible-rbenv-role | checkout rbenv_repo for system] ****************
skipping: [default]

TASK: [../ansible-rbenv-role | create plugins directory for system] ***********
skipping: [default]

TASK: [../ansible-rbenv-role | install plugins for system] ********************
skipping: [default] => (item={'repo': 'git://github.com/sstephenson/rbenv-vars.git', 'version': 'v1.2.0', 'name': 'rbenv-vars'})
skipping: [default] => (item={'repo': 'git://github.com/sstephenson/ruby-build.git', 'version': 'v20141225', 'name': 'ruby-build'})
skipping: [default] => (item={'repo': 'git://github.com/sstephenson/rbenv-default-gems.git', 'version': 'v1.0.0', 'name': 'rbenv-default-gems'})
skipping: [default] => (item={'repo': 'git://github.com/fesplugas/rbenv-installer.git', 'version': '22cc96aa45d06faca5958b1aa1688596198407a3', 'name': 'rbenv-installer'})
skipping: [default] => (item={'repo': 'git://github.com/rkh/rbenv-update.git', 'version': 'f0ff6e3264c45fdf2a8064205db6c8b3a707894e', 'name': 'rbenv-update'})
skipping: [default] => (item={'repo': 'git://github.com/rkh/rbenv-whatis.git', 'version': 'v1.0.0', 'name': 'rbenv-whatis'})
skipping: [default] => (item={'repo': 'git://github.com/rkh/rbenv-use.git', 'version': 'v1.0.0', 'name': 'rbenv-use'})

TASK: [../ansible-rbenv-role | checkout rbenv_repo for selected users] ********
changed: [default] => (item=deploy)
changed: [default] => (item=vagrant)

TASK: [../ansible-rbenv-role | create plugins directory for selected users] ***
changed: [default] => (item=deploy)
changed: [default] => (item=vagrant)

TASK: [../ansible-rbenv-role | install plugins for selected users] ************
changed: [default] => (item=[u'deploy', {'repo': 'git://github.com/sstephenson/rbenv-vars.git', 'version': 'v1.2.0', 'name': 'rbenv-vars'}])
changed: [default] => (item=[u'deploy', {'repo': 'git://github.com/sstephenson/ruby-build.git', 'version': 'v20141225', 'name': 'ruby-build'}])
changed: [default] => (item=[u'deploy', {'repo': 'git://github.com/sstephenson/rbenv-default-gems.git', 'version': 'v1.0.0', 'name': 'rbenv-default-gems'}])
changed: [default] => (item=[u'deploy', {'repo': 'git://github.com/fesplugas/rbenv-installer.git', 'version': '22cc96aa45d06faca5958b1aa1688596198407a3', 'name': 'rbenv-installer'}])
changed: [default] => (item=[u'deploy', {'repo': 'git://github.com/rkh/rbenv-update.git', 'version': 'f0ff6e3264c45fdf2a8064205db6c8b3a707894e', 'name': 'rbenv-update'}])
changed: [default] => (item=[u'deploy', {'repo': 'git://github.com/rkh/rbenv-whatis.git', 'version': 'v1.0.0', 'name': 'rbenv-whatis'}])
changed: [default] => (item=[u'deploy', {'repo': 'git://github.com/rkh/rbenv-use.git', 'version': 'v1.0.0', 'name': 'rbenv-use'}])
changed: [default] => (item=['vagrant', {'repo': 'git://github.com/sstephenson/rbenv-vars.git', 'version': 'v1.2.0', 'name': 'rbenv-vars'}])
changed: [default] => (item=['vagrant', {'repo': 'git://github.com/sstephenson/ruby-build.git', 'version': 'v20141225', 'name': 'ruby-build'}])
changed: [default] => (item=['vagrant', {'repo': 'git://github.com/sstephenson/rbenv-default-gems.git', 'version': 'v1.0.0', 'name': 'rbenv-default-gems'}])
changed: [default] => (item=['vagrant', {'repo': 'git://github.com/fesplugas/rbenv-installer.git', 'version': '22cc96aa45d06faca5958b1aa1688596198407a3', 'name': 'rbenv-installer'}])
changed: [default] => (item=['vagrant', {'repo': 'git://github.com/rkh/rbenv-update.git', 'version': 'f0ff6e3264c45fdf2a8064205db6c8b3a707894e', 'name': 'rbenv-update'}])
changed: [default] => (item=['vagrant', {'repo': 'git://github.com/rkh/rbenv-whatis.git', 'version': 'v1.0.0', 'name': 'rbenv-whatis'}])
changed: [default] => (item=['vagrant', {'repo': 'git://github.com/rkh/rbenv-use.git', 'version': 'v1.0.0', 'name': 'rbenv-use'}])

TASK: [../ansible-rbenv-role | add rbenv initialization to profile system-wide] ***
changed: [default]

TASK: [../ansible-rbenv-role | set default-gems for select users] *************
changed: [default] => (item=deploy)
changed: [default] => (item=vagrant)

TASK: [../ansible-rbenv-role | set custom default-gems for select users] ******
skipping: [default] => (item=deploy)
skipping: [default] => (item=vagrant)

TASK: [../ansible-rbenv-role | set gemrc for select users] ********************
changed: [default] => (item=deploy)
changed: [default] => (item=vagrant)

TASK: [../ansible-rbenv-role | set vars for select users] *********************
changed: [default] => (item=deploy)
changed: [default] => (item=vagrant)

TASK: [../ansible-rbenv-role | check ruby {{ ruby.version }} installed for system] ***
skipping: [default]

TASK: [../ansible-rbenv-role | install ruby {{ ruby.version }} for system] ****
skipping: [default]

TASK: [../ansible-rbenv-role | install ruby {{ ruby.version }} for system] ****
skipping: [default]

TASK: [../ansible-rbenv-role | check ruby {{ ruby.version }} installed for select users] ***
failed: [default] => (item=deploy) => {"changed": true, "cmd": "$SHELL -lc \"rbenv versions | grep 2.1.5\"", "delta": "0:00:00.136393", "end": "2015-01-15 17:55:19.453083", "item": "deploy", "rc": 1, "start": "2015-01-15 17:55:19.316690"}
...ignoring
failed: [default] => (item=vagrant) => {"changed": true, "cmd": "$SHELL -lc \"rbenv versions | grep 2.1.5\"", "delta": "0:00:00.136788", "end": "2015-01-15 17:55:19.740785", "item": "vagrant", "rc": 1, "start": "2015-01-15 17:55:19.603997"}
...ignoring

TASK: [../ansible-rbenv-role | install ruby {{ ruby.version }} for select users] ***
changed: [default] => (item=[{u'stdout': u'', u'changed': True, u'end': u'2015-01-15 17:55:19.453083', 'item': u'deploy', u'cmd': u'$SHELL -lc "rbenv versions | grep 2.1.5"', u'rc': 1, u'start': u'2015-01-15 17:55:19.316690', u'stderr': u'', u'delta': u'0:00:00.136393', 'invocation': {'module_name': u'shell', 'module_args': u'$SHELL -lc "rbenv versions | grep 2.1.5"'}}, u'deploy'])
changed: [default] => (item=[{u'stdout': u'', u'changed': True, u'end': u'2015-01-15 17:55:19.740785', 'item': 'vagrant', u'cmd': u'$SHELL -lc "rbenv versions | grep 2.1.5"', u'rc': 1, u'start': u'2015-01-15 17:55:19.603997', u'stderr': u'', u'delta': u'0:00:00.136788', 'invocation': {'module_name': u'shell', 'module_args': u'$SHELL -lc "rbenv versions | grep 2.1.5"'}}, 'vagrant'])

TASK: [../ansible-rbenv-role | install ruby {{ ruby.version }} for select users] ***
changed: [default] => (item=[{u'stdout': u'', u'changed': True, u'end': u'2015-01-15 17:55:19.453083', 'item': u'deploy', u'cmd': u'$SHELL -lc "rbenv versions | grep 2.1.5"', u'rc': 1, u'start': u'2015-01-15 17:55:19.316690', u'stderr': u'', u'delta': u'0:00:00.136393', 'invocation': {'module_name': u'shell', 'module_args': u'$SHELL -lc "rbenv versions | grep 2.1.5"'}}, u'deploy'])
changed: [default] => (item=[{u'stdout': u'', u'changed': True, u'end': u'2015-01-15 17:55:19.740785', 'item': 'vagrant', u'cmd': u'$SHELL -lc "rbenv versions | grep 2.1.5"', u'rc': 1, u'start': u'2015-01-15 17:55:19.603997', u'stderr': u'', u'delta': u'0:00:00.136788', 'invocation': {'module_name': u'shell', 'module_args': u'$SHELL -lc "rbenv versions | grep 2.1.5"'}}, 'vagrant'])
Based on my own incapacity of reading the README (#24) I thought we
could simplify the interface for the `rbenv_users` variable. Instead of
a hash with the user information including home, use ~ to figure it
out. I was trying to use $HOME, but came across
http://stackoverflow.com/questions/22873409/ansible-sudo-user-not-using-
the-correct-home-directory, long story short, ~ seems to do the trick
just fine.

`{{ item[1].home }}/.rbenv`, or `{{ rbenv_root }}` as I prefer to call
it, was created when each user cloned the repo, so there is no need to
chown it. Also user and group name might be different.

```yaml
  - role: ../ansible-rbenv-role
    rbenv:
      env: user
      version: v0.4.0
      ruby_version: 2.1.5
    rbenv_users:
      - deploy
      - vagrant
```

Here is the output log of a local run with two users:
```
TASK: [../ansible-rbenv-role | include env vars]
******************************
ok: [default]

TASK: [../ansible-rbenv-role | install build depends]
*************************
changed: [default] =>
(item=build-essential,git,libcurl4-openssl-dev,libreadline-dev,libssl-de
v,libxml2-dev,libxslt1-dev,zlib1g-dev)

TASK: [../ansible-rbenv-role | install build depends]
*************************
skipping: [default]

TASK: [../ansible-rbenv-role | homebrew name={{ item }} state=present]
********
skipping: [default] => (item=openssl)
skipping: [default] => (item=libyaml)

TASK: [../ansible-rbenv-role | homebrew_tap tap=homebrew/dupes
state=present] ***
skipping: [default]

TASK: [../ansible-rbenv-role | homebrew name=apple-gcc42 state=present]
*******
skipping: [default]

TASK: [../ansible-rbenv-role | checkout rbenv_repo for system]
****************
skipping: [default]

TASK: [../ansible-rbenv-role | create plugins directory for system]
***********
skipping: [default]

TASK: [../ansible-rbenv-role | install plugins for system]
********************
skipping: [default] => (item={'repo':
'git://github.com/sstephenson/rbenv-vars.git', 'version': 'v1.2.0',
'name': 'rbenv-vars'})
skipping: [default] => (item={'repo':
'git://github.com/sstephenson/ruby-build.git', 'version': 'v20141225',
'name': 'ruby-build'})
skipping: [default] => (item={'repo':
'git://github.com/sstephenson/rbenv-default-gems.git', 'version':
'v1.0.0', 'name': 'rbenv-default-gems'})
skipping: [default] => (item={'repo':
'git://github.com/fesplugas/rbenv-installer.git', 'version':
'22cc96aa45d06faca5958b1aa1688596198407a3', 'name': 'rbenv-installer'})
skipping: [default] => (item={'repo':
'git://github.com/rkh/rbenv-update.git', 'version':
'f0ff6e3264c45fdf2a8064205db6c8b3a707894e', 'name': 'rbenv-update'})
skipping: [default] => (item={'repo':
'git://github.com/rkh/rbenv-whatis.git', 'version': 'v1.0.0', 'name':
'rbenv-whatis'})
skipping: [default] => (item={'repo':
'git://github.com/rkh/rbenv-use.git', 'version': 'v1.0.0', 'name':
'rbenv-use'})

TASK: [../ansible-rbenv-role | checkout rbenv_repo for selected users]
********
changed: [default] => (item=deploy)
changed: [default] => (item=vagrant)

TASK: [../ansible-rbenv-role | create plugins directory for selected
users] ***
changed: [default] => (item=deploy)
changed: [default] => (item=vagrant)

TASK: [../ansible-rbenv-role | install plugins for selected users]
************
changed: [default] => (item=[u'deploy', {'repo':
'git://github.com/sstephenson/rbenv-vars.git', 'version': 'v1.2.0',
'name': 'rbenv-vars'}])
changed: [default] => (item=[u'deploy', {'repo':
'git://github.com/sstephenson/ruby-build.git', 'version': 'v20141225',
'name': 'ruby-build'}])
changed: [default] => (item=[u'deploy', {'repo':
'git://github.com/sstephenson/rbenv-default-gems.git', 'version':
'v1.0.0', 'name': 'rbenv-default-gems'}])
changed: [default] => (item=[u'deploy', {'repo':
'git://github.com/fesplugas/rbenv-installer.git', 'version':
'22cc96aa45d06faca5958b1aa1688596198407a3', 'name': 'rbenv-installer'}])
changed: [default] => (item=[u'deploy', {'repo':
'git://github.com/rkh/rbenv-update.git', 'version':
'f0ff6e3264c45fdf2a8064205db6c8b3a707894e', 'name': 'rbenv-update'}])
changed: [default] => (item=[u'deploy', {'repo':
'git://github.com/rkh/rbenv-whatis.git', 'version': 'v1.0.0', 'name':
'rbenv-whatis'}])
changed: [default] => (item=[u'deploy', {'repo':
'git://github.com/rkh/rbenv-use.git', 'version': 'v1.0.0', 'name':
'rbenv-use'}])
changed: [default] => (item=['vagrant', {'repo':
'git://github.com/sstephenson/rbenv-vars.git', 'version': 'v1.2.0',
'name': 'rbenv-vars'}])
changed: [default] => (item=['vagrant', {'repo':
'git://github.com/sstephenson/ruby-build.git', 'version': 'v20141225',
'name': 'ruby-build'}])
changed: [default] => (item=['vagrant', {'repo':
'git://github.com/sstephenson/rbenv-default-gems.git', 'version':
'v1.0.0', 'name': 'rbenv-default-gems'}])
changed: [default] => (item=['vagrant', {'repo':
'git://github.com/fesplugas/rbenv-installer.git', 'version':
'22cc96aa45d06faca5958b1aa1688596198407a3', 'name': 'rbenv-installer'}])
changed: [default] => (item=['vagrant', {'repo':
'git://github.com/rkh/rbenv-update.git', 'version':
'f0ff6e3264c45fdf2a8064205db6c8b3a707894e', 'name': 'rbenv-update'}])
changed: [default] => (item=['vagrant', {'repo':
'git://github.com/rkh/rbenv-whatis.git', 'version': 'v1.0.0', 'name':
'rbenv-whatis'}])
changed: [default] => (item=['vagrant', {'repo':
'git://github.com/rkh/rbenv-use.git', 'version': 'v1.0.0', 'name':
'rbenv-use'}])

TASK: [../ansible-rbenv-role | add rbenv initialization to profile
system-wide] ***
changed: [default]

TASK: [../ansible-rbenv-role | set default-gems for select users]
*************
changed: [default] => (item=deploy)
changed: [default] => (item=vagrant)

TASK: [../ansible-rbenv-role | set custom default-gems for select
users] ******
skipping: [default] => (item=deploy)
skipping: [default] => (item=vagrant)

TASK: [../ansible-rbenv-role | set gemrc for select users]
********************
changed: [default] => (item=deploy)
changed: [default] => (item=vagrant)

TASK: [../ansible-rbenv-role | set vars for select users]
*********************
changed: [default] => (item=deploy)
changed: [default] => (item=vagrant)

TASK: [../ansible-rbenv-role | check ruby {{ ruby.version }} installed
for system] ***
skipping: [default]

TASK: [../ansible-rbenv-role | install ruby {{ ruby.version }} for
system] ****
skipping: [default]

TASK: [../ansible-rbenv-role | install ruby {{ ruby.version }} for
system] ****
skipping: [default]

TASK: [../ansible-rbenv-role | check ruby {{ ruby.version }} installed
for select users] ***
failed: [default] => (item=deploy) => {"changed": true, "cmd": "$SHELL
-lc \"rbenv versions | grep 2.1.5\"", "delta": "0:00:00.136393", "end":
"2015-01-15 17:55:19.453083", "item": "deploy", "rc": 1, "start":
"2015-01-15 17:55:19.316690"}
...ignoring
failed: [default] => (item=vagrant) => {"changed": true, "cmd": "$SHELL
-lc \"rbenv versions | grep 2.1.5\"", "delta": "0:00:00.136788", "end":
"2015-01-15 17:55:19.740785", "item": "vagrant", "rc": 1, "start":
"2015-01-15 17:55:19.603997"}
...ignoring

TASK: [../ansible-rbenv-role | install ruby {{ ruby.version }} for
select users] ***
changed: [default] => (item=[{u'stdout': u'', u'changed': True, u'end':
u'2015-01-15 17:55:19.453083', 'item': u'deploy', u'cmd': u'$SHELL -lc
"rbenv versions | grep 2.1.5"', u'rc': 1, u'start': u'2015-01-15
17:55:19.316690', u'stderr': u'', u'delta': u'0:00:00.136393',
'invocation': {'module_name': u'shell', 'module_args': u'$SHELL -lc
"rbenv versions | grep 2.1.5"'}}, u'deploy'])
changed: [default] => (item=[{u'stdout': u'', u'changed': True, u'end':
u'2015-01-15 17:55:19.740785', 'item': 'vagrant', u'cmd': u'$SHELL -lc
"rbenv versions | grep 2.1.5"', u'rc': 1, u'start': u'2015-01-15
17:55:19.603997', u'stderr': u'', u'delta': u'0:00:00.136788',
'invocation': {'module_name': u'shell', 'module_args': u'$SHELL -lc
"rbenv versions | grep 2.1.5"'}}, 'vagrant'])

TASK: [../ansible-rbenv-role | install ruby {{ ruby.version }} for
select users] ***
changed: [default] => (item=[{u'stdout': u'', u'changed': True, u'end':
u'2015-01-15 17:55:19.453083', 'item': u'deploy', u'cmd': u'$SHELL -lc
"rbenv versions | grep 2.1.5"', u'rc': 1, u'start': u'2015-01-15
17:55:19.316690', u'stderr': u'', u'delta': u'0:00:00.136393',
'invocation': {'module_name': u'shell', 'module_args': u'$SHELL -lc
"rbenv versions | grep 2.1.5"'}}, u'deploy'])
changed: [default] => (item=[{u'stdout': u'', u'changed': True, u'end':
u'2015-01-15 17:55:19.740785', 'item': 'vagrant', u'cmd': u'$SHELL -lc
"rbenv versions | grep 2.1.5"', u'rc': 1, u'start': u'2015-01-15
17:55:19.603997', u'stderr': u'', u'delta': u'0:00:00.136788',
'invocation': {'module_name': u'shell', 'module_args': u'$SHELL -lc
"rbenv versions | grep 2.1.5"'}}, 'vagrant'])
```
zzet added a commit that referenced this pull request Jan 15, 2015
Simplify rbenv_users interface: Username only
@zzet zzet merged commit 0d1c2c7 into zzet:master Jan 15, 2015
1 check passed
1 check passed
continuous-integration/travis-ci The Travis CI build passed
Details
@zzet
Copy link
Owner

@zzet zzet commented Jan 15, 2015

@leonelgalan Thank you for contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.