diff options
Diffstat (limited to 'ansible-continuous-delivery/roles/install-ruby/tasks')
3 files changed, 147 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 diff --git a/ansible-continuous-delivery/roles/install-ruby/tasks/install-ruby-rh8.yml b/ansible-continuous-delivery/roles/install-ruby/tasks/install-ruby-rh8.yml new file mode 100644 index 0000000..596db19 --- /dev/null +++ b/ansible-continuous-delivery/roles/install-ruby/tasks/install-ruby-rh8.yml @@ -0,0 +1,70 @@ +--- +- name: Add nodejs repo + ansible.builtin.copy: + dest: "/etc/dnf/modules.d/nodejs.module" + content: | + [nodejs] + name=nodejs + stream={{ nodejs_version }} + profiles= + state=enabled + mode: 0644 + owner: root + +- name: Add yarn repo + ansible.builtin.copy: + dest: "/etc/yum.repos.d/yarn.repo" + content: | + [yarn] + name=Yarn Repository + baseurl=https://dl.yarnpkg.com/rpm/ + enabled=1 + gpgcheck=1 + gpgkey=https://dl.yarnpkg.com/rpm/pubkey.gpg + mode: 0644 + owner: root + +- name: Import yarn GPG signature + ansible.builtin.rpm_key: + key: https://dl.yarnpkg.com/rpm/pubkey.gpg + environment: + https_proxy: "{{ https_proxy }}" + +- name: Install packages + ansible.builtin.dnf: + update_cache: true + state: present + name: + - "@ruby:2.6" + - bison + - bzip2 + - curl + - gcc-c++ + - git + - libcurl-devel + - libffi-devel + - libpq + - libpq-devel + - libtool + - libyaml + - make + - nodejs + - openssl-devel + - patch + - readline + - readline-devel + - redhat-rpm-config + - ruby-devel + - yarn + - zlib + - zlib-devel + +- name: Execute gem command + ansible.builtin.command: + gem install bundler + environment: + https_proxy: "{{ https_proxy }}" + changed_when: false + check_mode: false + become: true + become_user: zextras-ci diff --git a/ansible-continuous-delivery/roles/install-ruby/tasks/main.yml b/ansible-continuous-delivery/roles/install-ruby/tasks/main.yml new file mode 100644 index 0000000..60e17a9 --- /dev/null +++ b/ansible-continuous-delivery/roles/install-ruby/tasks/main.yml @@ -0,0 +1,19 @@ +--- +- name: Vérification de la présence des paramètres d'entrées dans les variables + ansible.builtin.fail: + msg: | + La variable {{ item }} est obligatoire pour utiliser le role. + Veuillez la renseigner dans le dossier host_vars. + when: + - item is not defined + loop: + - nodejs_version + - ruby_version + +- name: Install packages for RH8 + ansible.builtin.include_tasks: install-ruby-rh8.yml + when: (ansible_facts['os_family'] == "RedHat" and ansible_facts['distribution_major_version'] == 8) + +- name: Install packages for Debian/Ubuntu + ansible.builtin.include_tasks: install-ruby-apt.yml + when: ansible_pkg_mgr == "apt" |
