Reading from a MySQL Database using the MySQL Gem

Hi all,
I have the necessity to connect to an external mysql database. Inside the book “Mastering Cloudforms automation” (page 366) is described how to do it, but when I execute the script arises the error that mysql gem is not installed.

require ‘rubygems’
require ‘mysql’

Anybody had experienced something like this and know the steps to follow? I’m a little scared to install the ruby gem mysql in cloudforms prod for not messing up anything.

Thanks in advance,

The mysql gem is deprecated and no longer compatible with the ruby version on ManageIQ. It was replaced by mysql2 which works more or less the same

We have mysql2 installed and haven’t experienced any problems with it.
To install mysql2 you need a few additional packages to install the gem

# ==============================
# mysql Gem
# =============================
- name: "[Gem mysql] install rpm dependencies"
    - mariadb-devel
    - ruby-devel
    - gcc
    state: latest
- name: "[Gem mysql] install mysql gem"
    name: "mysql2"
    state: present
    https_proxy: "{{ http_proxy }}"

1 Like