summaryrefslogtreecommitdiff
path: root/ansible-continuous-delivery/roles/install-ruby/tasks/install-ruby-apt.yml
diff options
context:
space:
mode:
authorAntoine Ouvrard <antoine.ouvrard@zextras.fr>2023-03-09 17:27:02 +0100
committerAntoine Ouvrard <antoine.ouvrard@zextras.fr>2023-03-09 17:27:02 +0100
commit749b7a84a0a7f74a3327ecad8110b2806a9d77e6 (patch)
treededbf8026a9ed2a6087ef99274fe7ddcea716215 /ansible-continuous-delivery/roles/install-ruby/tasks/install-ruby-apt.yml
parent0495c4425e67eafe8e23aac49052564a6207ae27 (diff)
readd directory
Diffstat (limited to 'ansible-continuous-delivery/roles/install-ruby/tasks/install-ruby-apt.yml')
-rw-r--r--ansible-continuous-delivery/roles/install-ruby/tasks/install-ruby-apt.yml58
1 files changed, 58 insertions, 0 deletions
diff --git a/ansible-continuous-delivery/roles/install-ruby/tasks/install-ruby-apt.yml b/ansible-continuous-delivery/roles/install-ruby/tasks/install-ruby-apt.yml
new file mode 100644
index 0000000..bbe83dd
--- /dev/null
+++ b/ansible-continuous-delivery/roles/install-ruby/tasks/install-ruby-apt.yml
@@ -0,0 +1,58 @@
+---
+- name: Install prerequis
+ ansible.builtin.apt:
+ name:
+ - build-essential
+ - libz-dev
+ - libreadline-dev
+ - nodejs
+ - nginx
+ state: present
+
+- name: Become zextras-ci user
+ become: true
+ become_user: zextras-ci
+ block:
+ - name: Find out if ruby is initialized
+ ansible.builtin.stat:
+ path: /home/zextras-ci/.rbenv/versions/{{ ruby_version }}
+ register: ruby_version_install
+
+ - name: Get rbenv from github
+ ansible.builtin.git:
+ repo: https://github.com/sstephenson/rbenv.git
+ dest: /home/zextras-ci/.rbenv
+ single_branch: true
+ version: master
+ when: not ruby_version_install.stat.exists
+
+ - name: Get ruby build plugin for rbenv from github
+ ansible.builtin.git:
+ repo: https://github.com/sstephenson/ruby-build.git
+ dest: /home/zextras-ci/.rbenv/plugins/ruby-build
+ single_branch: true
+ version: master
+ when: not ruby_version_install.stat.exists
+
+ - name: Install ruby with rbenv
+ ansible.builtin.command: /home/zextras-ci/.rbenv/bin/rbenv install {{ ruby_version }}
+ when: not ruby_version_install.stat.exists
+
+ - name: Init rbenv in bashrc
+ ansible.builtin.lineinfile:
+ path: /home/zextras-ci/.bashrc
+ line: 'eval "$(/home/zextras-ci/.rbenv/bin/rbenv init - bash)"'
+
+ - name: Get setup version of ruby
+ ansible.builtin.command: /home/zextras-ci/.rbenv/bin/rbenv global
+ register: ruby_version_set
+ changed_when: false
+ check_mode: false
+
+ - name: Set version ruby with rbenv
+ ansible.builtin.command: /home/zextras-ci/.rbenv/bin/rbenv global {{ ruby_version }}
+ when: not ruby_version_set.stdout == ruby_version
+
+ - name: Install bundler
+ ansible.builtin.command: /home/zextras-ci/.rbenv/versions/{{ ruby_version }}/bin/gem install bundler
+ when: not ruby_version_set.stdout == ruby_version