-
-
Save andrewtimberlake/802bd8d285b3e18c5ebe to your computer and use it in GitHub Desktop.
Install ruby from source using Ansible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# group_vars/test.yml | |
# This file contains the variables needed for the [test] host group | |
--- | |
ruby_version: 2.3.0 | |
ruby_sha256sum: ba5ba60e5f1aa21b4ef8e9bf35b9ddb57286cb546aac4b5a28c71f459467e507 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# playbook.yml | |
# This file is the main build configuration | |
--- | |
- name: "Test Playbook" # The name of the playbook | |
hosts: test # The servers in this host group will be affected | |
remote_user: ubuntu # The user we are going to log in as | |
become_method: sudo # The method we will become another user via | |
roles: | |
- ruby |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# roles/ruby/tasks/main.yml | |
# This file contains all the tasks that will be run for the ruby play | |
--- | |
- name: install required packages | |
become: true | |
apt: name={{item}} state=present update_cache=yes | |
with_items: | |
- build-essential | |
- cmake | |
- zlib1g-dev | |
- libyaml-dev | |
- libncurses-dev | |
- libssl-dev | |
- libreadline-dev | |
- name: Download Ruby | |
get_url: | |
url: "https://cache.ruby-lang.org/pub/ruby/2.3/ruby-{{ruby_version}}.tar.gz" | |
dest: "/tmp/ruby-{{ruby_version}}.tar.gz" | |
sha256sum: "{{ruby_sha256sum}}" | |
- name: Extract archive | |
unarchive: | |
src: "/tmp/ruby-{{ruby_version}}.tar.gz" | |
dest: /tmp/ | |
creates: "/tmp/ruby-{{ruby_version}}/README.md" | |
copy: false | |
- name: Configure install | |
command: ./configure --disable-install-doc | |
args: | |
chdir: "/tmp/ruby-{{ruby_version}}" | |
creates: "/tmp/ruby-{{ruby_version}}/config.status" | |
- name: Build ruby | |
command: make | |
args: | |
chdir: "/tmp/ruby-{{ruby_version}}" | |
creates: "/tmp/ruby-{{ruby_version}}/ruby" | |
- name: Install ruby | |
become: true | |
command: make install | |
args: | |
chdir: "/tmp/ruby-{{ruby_version}}" | |
creates: /usr/local/bin/ruby | |
- name: Remove build directory | |
file: | |
path: "/tmp/ruby-{{ruby_version}}" | |
state: absent | |
- name: Remove archive | |
file: | |
path: "/tmp/ruby-{{ruby_version}}.tar.gz" | |
state: absent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[test] | |
ec2-127-0-0-1.eu-west-1.compute.amazonaws.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment