-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrbenv-setup.yml
More file actions
115 lines (102 loc) · 2.59 KB
/
rbenv-setup.yml
File metadata and controls
115 lines (102 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
---
- name: Install RbEnv and Ruby build dependencies
hosts: all
become: yes
vars:
rbenv_packages:
- git
- curl
- build-essential
- libssl-dev
- zlib1g-dev
- libpq-dev
- rbenv
- libffi-dev
- libyaml-dev
- autoconf
- bison
tasks:
- name: Update apt cache
apt:
update_cache: yes
- name: Install required packages for rbenv and Ruby
apt:
name: "{{ rbenv_packages }}"
state: present
install_recommends: yes
- name: Ensure rbenv is initialized in .bashrc
lineinfile:
path: ~/.bashrc
line: 'eval "$(rbenv init -)"'
state: present
insertafter: EOF
become: no
- name: Install rbenv using git
git:
repo: 'https://github.com/rbenv/rbenv.git'
dest: ~/.rbenv
update: no
become: no
- name: Add rbenv to PATH
lineinfile:
path: ~/.bashrc
line: 'export PATH="$HOME/.rbenv/bin:$PATH"'
state: present
insertafter: EOF
become: no
- name: Install ruby-build as rbenv plugin
git:
repo: 'https://github.com/rbenv/ruby-build.git'
dest: ~/.rbenv/plugins/ruby-build
update: no
become: no
- name: Ensure rbenv is initialized in .bashrc
lineinfile:
path: ~/.bashrc
line: 'eval "$(rbenv init -)"'
state: present
insertafter: EOF
become: no
- name: Reload shell to use rbenv
shell: |
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
args:
executable: /bin/bash
become: no
- name: Install Ruby 3.1.2
shell: |
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
rbenv install -s 3.1.2
args:
creates: ~/.rbenv/versions/3.1.2
executable: /bin/bash
become: no
- name: Set Ruby 3.1.2 as local version
shell: |
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
rbenv local 3.1.2
args:
chdir: "{{ ansible_env.PWD }}"
executable: /bin/bash
become: no
- name: Install bundler gem
shell: |
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
gem install bundler
rbenv rehash
args:
executable: /bin/bash
become: no
- name: Run bundle install
shell: |
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
bundle install
args:
chdir: "{{ ansible_env.PWD }}"
executable: /bin/bash
become: no