Install Bundler gem using Ansible

前端 未结 6 484
忘了有多久
忘了有多久 2020-12-14 00:46

I am trying to install Bundler on my VPS using Ansible.

I already have rbenv set up and the global ruby is 2.1.0.

If I SSH as root into the server and run

6条回答
  •  遥遥无期
    2020-12-14 01:22

    I got it working like this:

    - name: Install jekyll and bundler                                                                                                                      
      become_user: bob                                                                                                                    
      gem:                                                                                                                                                  
        name: "{{ item }}"                                                                                                                                  
      environment:                                                                                                                                          
        GEM_HOME: /home/bob/gems                                                                                                          
        PATH: $PATH:/bin/:/usr/bin/:/home/bob/gems/bin                                                                                    
      with_items:                                                                                                                                           
        - jekyll                                                                                                                                            
        - bundler 
    

    Replace bob with your local user.

    And then use the same principle with the bundler module

    - name: Install Gems                                                                                                                                    
      become_user: bob                                                                                                                     
      bundler:                                                                                                                                              
        gemfile: /home/bob/Gemfile                                                                                          
        state: present                                                                                                                                      
      environment:                                                                                                                                          
        GEM_HOME: /home/bob/gems                                                                                                           
        PATH: $PATH:/bin/:/usr/bin/:/home/bob/gems/bin
    

提交回复
热议问题