Giter Site home page Giter Site logo

ansible-rvm's People

Contributors

aguynamedryan avatar klodio avatar kporras07 avatar newmen avatar trinitronx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ansible-rvm's Issues

Handling RVM updates

Hey,

Is there a way to handle/perform RVM updates? Not ruby updates (that's simple enough), but actual rvm updates.

Problems installing System-Wide RVM install when running ansible-playbook as non-root user with sudo

I believe I have found a couple bugs in the way that running the system-level install as root via sudo works with this role.

The bugs I observed were:

  • When playbook was run as non-root user with any of: sudo: True, sudo: true, sudo: yes, or --sudo command line option, RVM installer script would fail due to file permissions issues:

    TASK: [altermn.rvm | updating RVM] ********************************************
    <mauth00.tst.lan.returnpath.net> REMOTE_MODULE command source /etc/profile.d/rvm.sh && rvm get stable executable=/bin/bash #USE_SHELL
    failed: [mauth00.tst.lan.returnpath.net] => {"changed": true, "cmd": "source /etc/profile.d/rvm.sh && rvm get stable", "delta": "0:00:01.871639", "end": "2015-08-24 15:53:56.982704", "rc": 23, "start": "2015-08-24 15:53:55.111065", "warnings": []}
    stderr: curl: (23) Failed writing body (0 != 860)
    curl: (23) Failed writing body (0 != 15926)
    Could not update RVM, get some help at #rvm IRC channel at freenode servers.
    stdout: Downloading https://get.rvm.io
    Downloading https://github.com/rvm/rvm/archive/1.26.11.tar.gz
    
    Could not download 'https://github.com/rvm/rvm/archive/1.26.11.tar.gz'.
      curl returned status '23'.
    
    Downloading https://bitbucket.org/mpapis/rvm/get/1.26.11.tar.gz
    
    Could not download 'https://bitbucket.org/mpapis/rvm/get/1.26.11.tar.gz'.
      curl returned status '23'.
    
    FATAL: all hosts have already failed -- aborting
    
  • When playbook was run against a node with RVM already installed, and with: auto_update_rvm: true and --user=root (to avoid first bug), install would fail due to gpg key not being installed into root's gpg keychain

    [[email protected] ~]# source /etc/profile.d/rvm.sh && rvm get stable
    Downloading https://get.rvm.io
    Downloading https://github.com/rvm/rvm/archive/1.26.11.tar.gz
    Downloading https://github.com/rvm/rvm/releases/download/1.26.11/1.26.11.tar.gz.asc
    gpg: Signature made Mon 30 Mar 2015 03:52:13 PM MDT using RSA key ID BF04FF17
    gpg: Can't check signature: No public key
    Warning, RVM 1.26.0 introduces signed releases and automated check of signatures when GPG software found.
    Assuming you trust Michal Papis import the mpapis public key (downloading the signatures).
    
    GPG signature verification failed for '/usr/local/rvm/archives/rvm-1.26.11.tgz' - 'https://github.com/rvm/rvm/releases/download/1.26.11/1.26.11.tar.gz.asc'!
    try downloading the signatures:
    
        gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
    
    or if it fails:
    
        command curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
    
    the key can be compared with:
    
        https://rvm.io/mpapis.asc
        https://keybase.io/mpapis
    
    Could not update RVM, get some help at #rvm IRC channel at freenode servers.
    

It appears that even when run with any of these options: - { role: altermn.rvm, sudo: yes }, sudo: True, sudo: true, sudo: yes, or --sudo command line option, the user that actually runs the tasks which have sudo: "{{ sudo }}" are not actually being run as root unless the user running the playbook is already root (--user=root).

Debugging

I added some debug tasks to the role to verify this, and tested against Ansible v1.8.4 and v1.9.2 and saw the same behavior:

---
- name: Configure Ruby
  hosts: ruby_hosts
  sudo: true
  roles:
    - { role: altermn.rvm, sudo: True, tags: rvm }

roles/altermn.rvm/tasks/receive_key.yml:

- name: whoami
  shell: whoami
  sudo: "{{ sudo }}"
  register: ansible_user_is_running_as
  always_run: true
  ignore_errors: true
  tags:
    - debug

- name: Who is Ansible running as?
  debug:
    var: ansible_user_is_running_as
  always_run: true
  ignore_errors: true
  tags:
    - debug

- name: sudoDOdooo!
  debug:
    msg: "{{ sudo }}"
  always_run: true
  ignore_errors: true
  tags:
    - debug

As you can see, the user returned by the whoami command which is supposedly run as sudo with sudo: True actually returns ansible:

[[email protected]]$ ./bin/docker-run 'ansible-playbook -i inventory/racktables.py playbooks/ruby_host/rvm.yml -e rp_environment=test --user=ansible --diff -vv --check --tags=rvm,debug '

PLAY [Configure Ruby] ********************************************************

GATHERING FACTS ***************************************************************
<rubynode00.example.com> REMOTE_MODULE setup CHECKMODE=True

ok: [rubynode00.example.com]

TASK: [altermn.rvm | ensure necessary yum packages are installed] *************
<rubynode00.example.com> REMOTE_MODULE yum name=curl,gnupg2 state=present CHECKMODE=True

ok: [rubynode00.example.com] => (item=curl,gnupg2) => {"changed": false, "item": "curl,gnupg2", "msg": "", "rc": 0, "results": ["curl-7.19.7-36.el6_4.x86_64 providing curl is already installed", "gnupg2-2.0.14-4.el6.x86_64 providing gnupg2 is already installed"]}

TASK: [altermn.rvm | ensure necessary apt packages are installed] *************
skipping: [rubynode00.example.com]

TASK: [altermn.rvm | checking that RVM is installed] **************************
<rubynode00.example.com> REMOTE_MODULE stat path=/etc/profile.d/rvm.sh CHECKMODE=True

ok: [rubynode00.example.com] => {"changed": false, "stat": {"atime": 1440421983.2096033, "checksum": "f219eb582a5520c5c79fd5b1cb727d7307c2349b", "ctime": 1414434821.7944453, "dev": 64769, "exists": true, "gid": 0, "gr_name": "root", "inode": 9133, "isblk": false, "ischr": false, "isdir": false, "isfifo": false, "isgid": false, "islnk": false, "isreg": true, "issock": false, "isuid": false, "md5": "afde9903e1fc2f5c989d54a97d4611ce", "mode": "0755", "mtime": 1414434821.7924473, "nlink": 1, "path": "/etc/profile.d/rvm.sh", "pw_name": "root", "rgrp": true, "roth": true, "rusr": true, "size": 1720, "uid": 0, "wgrp": false, "woth": false, "wusr": true, "xgrp": true, "xoth": true, "xusr": true}}

TASK: [altermn.rvm | Check for mpapis gpg key] ********************************
skipping: [rubynode00.example.com]

TASK: [altermn.rvm | whoami] **************************************************
skipping: [rubynode00.example.com]

TASK: [altermn.rvm | Who is Ansible running as?] ******************************
skipping: [rubynode00.example.com]

TASK: [altermn.rvm | sudoDOdooo!] *********************************************
skipping: [rubynode00.example.com]

TASK: [altermn.rvm | receiving key] *******************************************
skipping: [rubynode00.example.com]

TASK: [altermn.rvm | downloading RVM installer] *******************************
skipping: [rubynode00.example.com]

TASK: [altermn.rvm | set executable RVM installer] ****************************
skipping: [rubynode00.example.com]

TASK: [altermn.rvm | installing RVM] ******************************************
skipping: [rubynode00.example.com]

TASK: [altermn.rvm | removing RVM installer] **********************************
skipping: [rubynode00.example.com]

TASK: [altermn.rvm | setting RVM autolibs on] *********************************
skipping: [rubynode00.example.com]

TASK: [altermn.rvm | Check for mpapis gpg key] ********************************
<rubynode00.example.com> REMOTE_MODULE command gpg --list-keys mpapis #USE_SHELL

changed: [rubynode00.example.com] => {"changed": true, "cmd": "gpg --list-keys mpapis", "delta": "0:00:00.005546", "end": "2015-08-24 15:47:21.012892", "rc": 0, "start": "2015-08-24 15:47:21.007346", "stderr": "", "stdout": "pub   4096R/D39DC0E3 2014-10-28\nuid                  Michal Papis (RVM signing) <[email protected]>\nsub   4096R/BF04FF17 2014-10-28 [expires: 2016-01-05]", "warnings": []}

TASK: [altermn.rvm | whoami] **************************************************
<rubynode00.example.com> REMOTE_MODULE command whoami #USE_SHELL

changed: [rubynode00.example.com] => {"changed": true, "cmd": "whoami", "delta": "0:00:00.002383", "end": "2015-08-24 15:47:21.464745", "rc": 0, "start": "2015-08-24 15:47:21.462362", "stderr": "", "stdout": "ansible", "warnings": []}

TASK: [altermn.rvm | Who is Ansible running as?] ******************************

ok: [rubynode00.example.com] => {
    "var": {
        "ansible_user_is_running_as": {
            "changed": true,
            "cmd": "whoami",
            "delta": "0:00:00.002383",
            "end": "2015-08-24 15:47:21.464745",
            "invocation": {
                "module_args": "whoami",
                "module_name": "shell"
            },
            "rc": 0,
            "start": "2015-08-24 15:47:21.462362",
            "stderr": "",
            "stdout": "ansible",
            "stdout_lines": [
                "ansible"
            ],
            "warnings": []
        }
    }
}

TASK: [altermn.rvm | sudoDOdooo!] *********************************************

ok: [rubynode00.example.com] => {
    "msg": "True"
}

TASK: [altermn.rvm | receiving key] *******************************************
skipping: [rubynode00.example.com]

TASK: [altermn.rvm | updating RVM] ********************************************
skipping: [rubynode00.example.com]

ok: [rubynode00.example.com] => {"msg": "check mode not supported for shell", "skipped": true}

TASK: [altermn.rvm | setting default Ruby version] ****************************
skipping: [rubynode00.example.com]

ok: [rubynode00.example.com] => {"msg": "check mode not supported for shell", "skipped": true}

TASK: [altermn.rvm | installing Ruby] *****************************************
skipping: [rubynode00.example.com]

TASK: [altermn.rvm | setting default Ruby version] ****************************
skipping: [rubynode00.example.com]

PLAY RECAP ********************************************************************
rubynode00.example.com : ok=7    changed=2    unreachable=0    failed=0

I have found that by calling the role with ansible_sudo: True, and removing all the sudo: "{{ sudo }}" task lines fixes the problem.
It appears that this is due to a problem in Ansible where it does not evaluate the contents of sudo: "{{ foo }}", but simply passes it along to utils.boolean.

The fix or workaround mentioned here to preserve the conditional ability to run with sudo is to duplicate tasks, and have one with sudo: true, one with sudo: false, then use when: conditions to run the appropriate one.

Can not install 1.9.3 on Debian

Hello,
my playbook contains

- role: rvm_io.ruby
      become: yes
      rvm1_rubies: ['ruby-1.9.3']
      rvm1_install_flags: '--auto-dotfiles'
      rvm1_install_path: /usr/local/rvm
      rvm1_user: root

I get an error:

< TASK [rvm_io.ruby : Install rvm] >
 ----------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

fatal: [188.166.135.48]: FAILED! => {"changed": true, "cmd": ["/tmp/rvm-installer.sh", "stable", "--path", "/usr/local/rvm", "--auto-dotfiles"], "delta": "0:00:00.042643", "end": "2016-12-21 11:41:33.787967", "failed": true, "rc": 200, "start": "2016-12-21 11:41:33.745324", "stderr": "", "stdout": "Turning on auto dotfiles mode.\nDownloading https://github.com/rvm/rvm/archive/.tar.gz\n\nCould not download 'https://github.com/rvm/rvm/archive/.tar.gz'.\n  curl returned status '200'.\n\nDownloading https://bitbucket.org/mpapis/rvm/get/.tar.gz\n\nCould not download 'https://bitbucket.org/mpapis/rvm/get/.tar.gz'.\n  curl returned status '200'.", "stdout_lines": ["Turning on auto dotfiles mode.", "Downloading https://github.com/rvm/rvm/archive/.tar.gz", "", "Could not download 'https://github.com/rvm/rvm/archive/.tar.gz'.", "  curl returned status '200'.", "", "Downloading https://bitbucket.org/mpapis/rvm/get/.tar.gz", "", "Could not download 'https://bitbucket.org/mpapis/rvm/get/.tar.gz'.", "  curl returned status '200'."], "warnings": []}
	to retry, use: --limit @/home/rombr/Workspace/interactive-menu/ansible/web.retry
 ____________
< PLAY RECAP >
 ------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

188.166.135.48             : ok=26   changed=1    unreachable=0    failed=1   

Thanks!

GPG Issue

Hi, my machine was missing GPG, which is a dependency to install rvm.

Adding gnu this to the role solved my issue.

  - name: ensure necessary packages are installed
    yum:
      name: "{{ item }}"
      state: present
    with_items:
      - curl
      - gnupg2

ERROR! 'version' is not a valid attribute for a RoleMetadata

When using this role Ansible outputs this message:


ERROR! 'version' is not a valid attribute for a RoleMetadata

The error appears to have been in '/etc/ansible/roles/altermn.rvm/meta/main.yml': line 2, column 1, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


galaxy_info:

^ here

After removing the version line in the metadata file the role works ok.

I have looked up other roles and none of them have the version line.

Ansible version (development):
ansible-playbook 2.2.0 (devel aece03312f) last updated 2016/07/27 13:10:48 (GMT +200)
lib/ansible/modules/core: (detached HEAD 24db4de245) last updated 2016/07/26 15:42:03 (GMT +200)
lib/ansible/modules/extras: (detached HEAD db979dde74) last updated 2016/07/26 15:42:04 (GMT +200)
config file = /home/david/devel/ansible/playbooks/ansible.cfg
configured module search path = Default w/o overrides

RVM install failed

ASK: [altermn.rvm | installing RVM] ******************************************
failed: [app1.example.com] => {"changed": true, "cmd": ["/root/rvm-installer.sh", "--path", "/usr/local/rvm", "stable"], "delta": "0:00:04.354553", "end": "2014-11-09 22:04:28.783126", "rc": 2, "start": "2014-11-09 22:04:24.428573"}
stderr: gpg: Signature made Wed 29 Oct 2014 12:52:06 PM GMT using RSA key ID BF04FF17
gpg: Can't check signature: public key not found
stdout: Downloading https://github.com/wayneeseguin/rvm/archive/1.26.0.tar.gz
Downloading https://github.com/wayneeseguin/rvm/releases/download/1.26.0/1.26.0.tar.gz.asc
Warning, RVM 1.26.0 introduces signed releases and automated check of signatures when GPG software found.
Assuming you trust Michal Papis import the mpapis public key (downloading the signatures).

GPG signature verification failed for '/usr/local/rvm/archives/rvm-1.26.0.tgz' - 'https://github.com/wayneeseguin/rvm/releases/download/1.26.0/1.26.0.tar.gz.asc'!
try downloading the signatures:

    gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3

or if it fails:

    command curl -sSL https://rvm.io/mpapis.asc | gpg --import -

the key can be compared with:

    https://rvm.io/mpapis.asc
    https://keybase.io/mpapis

FATAL: all hosts have already failed -- aborting

I manually ran that just to check the next step out, and i got:

TASK: [altermn.rvm | updating RVM] ********************************************
failed: [app1.example.com] => {"changed": true, "cmd": ["/usr/local/rvm/bin/rvm", "get", "stable"], "delta": "0:00:06.138139", "end": "2014-11-09 22:06:43.571701", "rc": 2, "start": "2014-11-09 22:06:37.433562"}
stderr: gpg: Signature made Sat 08 Nov 2014 06:37:43 PM GMT using RSA key ID BF04FF17
gpg: Good signature from "Michal Papis (RVM signing) <[email protected]>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 409B 6B17 96C2 7546 2A17  0311 3804 BB82 D39D C0E3
     Subkey fingerprint: 62C9 E5F4 DA30 0D94 AC36  166B E206 C29F BF04 FF17
In case of problems: http://rvm.io/help and https://twitter.com/rvm_io
  * No new notes to display.

/usr/local/rvm/bin/rvm: line 67: unexpected EOF while looking for matching `"'
/usr/local/rvm/bin/rvm: line 70: syntax error: unexpected end of file
stdout: Downloading https://get.rvm.io
Downloading https://raw.githubusercontent.com/wayneeseguin/rvm/master/binscripts/rvm-installer.asc
Verifying /usr/local/rvm/archives/rvm-installer.asc
GPG verified '/usr/local/rvm/archives/rvm-installer'
Downloading https://github.com/wayneeseguin/rvm/archive/master.tar.gz

Upgrading the RVM installation in /usr/local/rvm/
Upgrade of RVM in /usr/local/rvm/ is complete.

# Administrator,
#
#   Thank you for using RVM!
#   We sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne, Michal & team.


Upgrade Notes:

RVM reloaded!

Install RVM on another user

Hi

I need to ssh Via ansible_ssh_user and install ruby with rvm on another user is it possible? Please help me

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.