1+ # roles/ruby/tasks/main.yml
2+ # This file contains all the tasks that will be run for the ruby play
3+ ---
4+ - name : install required packages
5+ become : true
6+ apt : name={{item}} state=present update_cache=yes
7+ with_items :
8+ - build-essential
9+ - cmake
10+ - zlib1g-dev
11+ - libyaml-dev
12+ - libncurses-dev
13+ - libssl-dev
14+ - libreadline-dev
15+
16+ - name : Get installed version
17+ command : ruby --version
18+ ignore_errors : True
19+ changed_when : false
20+ failed_when : false
21+ register : ruby_installed_version
22+
23+ - name : Force install if the version numbers do not match
24+ set_fact :
25+ ruby_reinstall_from_source : true
26+ when : ' (ruby_installed_version|success and (ruby_installed_version.stdout | regex_replace("^.*?([0-9\.]+).*$", "\\1") | version_compare(ruby_version, operator="!=")))'
27+
28+ - when : ruby_installed_version|failed or ruby_reinstall_from_source
29+ block :
30+ - name : Download Ruby
31+ get_url :
32+ url : " https://cache.ruby-lang.org/pub/ruby/2.3/ruby-{{ruby_version}}.tar.gz"
33+ dest : " /tmp/ruby-{{ruby_version}}.tar.gz"
34+ sha256sum : " {{ruby_sha256sum}}"
35+
36+ - name : Extract archive
37+ unarchive :
38+ src : " /tmp/ruby-{{ruby_version}}.tar.gz"
39+ dest : /tmp/
40+ creates : " /tmp/ruby-{{ruby_version}}/README.md"
41+ copy : false
42+
43+ - name : Configure install
44+ command : ./configure --disable-install-doc
45+ args :
46+ chdir : " /tmp/ruby-{{ruby_version}}"
47+ creates : " /tmp/ruby-{{ruby_version}}/config.status"
48+
49+ - name : Build ruby
50+ command : make
51+ args :
52+ chdir : " /tmp/ruby-{{ruby_version}}"
53+ creates : " /tmp/ruby-{{ruby_version}}/ruby"
54+
55+ - name : Install ruby
56+ become : true
57+ command : make install
58+ args :
59+ chdir : " /tmp/ruby-{{ruby_version}}"
60+ creates : /usr/local/bin/ruby
61+
62+ - name : Remove build directory
63+ file :
64+ path : " /tmp/ruby-{{ruby_version}}"
65+ state : absent
66+
67+ - name : Remove archive
68+ file :
69+ path : " /tmp/ruby-{{ruby_version}}.tar.gz"
70+ state : absent
0 commit comments