Ansible not installing latest version of Mysql 5.7 - mysql

My Ansible script is installing Mysql version 5.4, but I need it to install 5.7.
This is the code:
- name: mysql | Install MySQL Packages
sudo: yes
apt: pkg={{ item }} state=latest
with_items:
- mysql-server
- mysql-client
- python-mysqldb
I have tried this, but it doesn't work:
- name: mysql | Install MySQL Packages
sudo: yes
apt: pkg={{ item }} state=latest
with_items:
- mysql-server-5.7
- mysql-client-5.7
- python-mysqldb
Anyone know how to get Ansible to install Mysql 5.7?

I would expect 5.4 is the latest version available per apt. Unless you're saying you can install MySQL 5.7 with apt manually on the command line, this is not an Ansible issue.
You can try to activate the update_cache option.
- name: mysql | Install MySQL Packages
sudo: yes
apt:
pkg: "{{ item }}"
state: latest
update_cache: yes
with_items:
- mysql-server
- mysql-client
- python-mysqldb
Also you could try to add the MySQL apt repository with the apt_repository module before installing MySQL. Something like this:
- apt_repository:
repo: 'deb http://repo.mysql.com/apt/debian/ precise mysql-5.7'
state: present

Related

How do you install openssl1.0 in a github action CI workflow on ubuntu-latest/18.04?

I tried adding the following to the github steps in the yaml file from https://github.com/actions/virtual-environments/issues/1307#issuecomment-664989873
steps:
- name: Install openssl&libssl-dev
run: |
sudo apt-get install -y --allow-downgrades openssl=1.0.2g-1ubuntu4.16 libssl-dev=1.0.2g-1ubuntu4.16
- name: Display openssl&libssl-dev versions
run: dpkg -l openssl libssl-dev | grep '^ii' | cut -c5-
But received error Version '1.0.2g-1ubuntu4.16' for 'openssl' was not found
How do I figure out what "old versions" of openssl I can install in at least ubuntu 18.04 for github actions?

how to install mysql version 8.0.21 using ansible

I am trying to install MySQL version 8.0.21 using ansible. I have downloaded the required tar file from the MySQL community and tried to install using dpkg command but found issues while passing passwords.
- name: Set MySQL root password before installing
debconf: name='mysql-server' question='mysql-server/root_password' value='{{MySQL_root_pass | quote}}' vtype='password'
become: yes
- name: Confirm MySQL root password before installing
debconf: name='mysql-server' question='mysql-server/root_password_again' value='{{MySQL_root_pass | quote}}' vtype='password'
become: yes
- name: Install my_package
apt: deb="required_package.deb"
become: true
become_method: sudo
This is my YAML.The mysql version is installed with an empty password
What about the role from geerlingguy
ansible-galaxy install geerlingguy.mysql
After installing you yml like this:
- hosts: YOUR_SERVER_IP_HERE
become: yes
vars_files:
- vars/main.yml
roles:
- { role: geerlingguy.mysql }
pre_tasks:
- name: Install the MySQL repo.
yum:
name: http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
state: present
when: ansible_os_family == "RedHat"
- name: Override variables for MySQL (RedHat).
set_fact:
mysql_daemon: mysqld
mysql_packages: ['mysql-server']
mysql_log_error: /var/lib/mysql/error.log
mysql_syslog_tag: mysqld
mysql_pid_file: /var/run/mysqld/mysqld.pid
mysql_socket: /var/lib/mysql/mysql.sock
when: ansible_os_family == "RedHat"
Make sure to updat the vars/main.yml file including the version you wish!

Install mysql-5.7 with ansible on ubuntu 14.04 trusty

I'm trying to install Mysql-5.7 on ubuntu 14.04 which by default has no has no 5.7 package in its repositories.
So I try to add it manually with this little role:
---
- name: download the mysql deb package
get_url: url=http://dev.mysql.com/get/{{ deb_filename }} dest=/tmp/{{ deb_filename }} mode=0644
tags: apt
- name: install the package
sudo: true
apt: deb=/tmp/{{ deb_filename }}
tags: apt
- name: update apt cache
sudo: true
apt: update_cache=yes
tags: apt
Where deb_filename is the latest one “mysql-apt-config_0.8.7-1_all.deb”.
When I run a playbook with this role everything seems to run smoothly. No errors.
But then when it comes to a real installation of a package it says that:
msg: No package matching 'mysql-client-5.7' is available
And when I login to the server and run “apt-cache search mysql-client” I see no mysql-5.7.
How can I add this package using ansible to my server?
Thanks everyone!

how to deal with unverified apt install in ansible

when installing an apt package from our own repo, I get the the following on the CLI:
Install these packages without verification? [y/N]
The question is, how does one install these packages successfully using ansible?
Even with the force option, ansible fails to install the package.
The command I'm using is:
- apt: name=coupons-graphite dpkg_options='force' state=present
According to the documentation for the apt module you should be using force=yes in this case:
- apt: name=coupons-graphite
state=present
force=yes

How to install mysql on ubuntu with SaltStack

I have to write a SLS file to install mysql-server, mysql-client, mysql-common on ubuntu. How do I do it? The following SLS is giving error saying that these packages are unbale to install or update.
state1:
pkg.installed:
- pkgs:
- mysql-server
- mysql-common
- mysql-client
I experienced an issue with mysql-server specifically. On Ubuntu, it's a "meta-package" which just installs the latest version, e.g. mysql-server-5.5. In my case, there was an error with my preconfiguration, and apt marked "mysql-server" as installed, but "mysql-server-5.5" failed. Later calls to apt failed because of the missing "mysql-server-5.5". I removed mysql-server manually, fixed my issue with the preconfiguration, and it worked fine. Here's my code, for your reference:
mysql_setup:
debconf.set:
- name: mysql-server
- data:
'mysql-server/root_password': {'type': 'string', 'value': '{{ pillar['SQL_ROOT_PASSWORD'] }}'}
'mysql-server/root_password_again': {'type': 'string', 'value': '{{ pillar['SQL_ROOT_PASSWORD'] }}'}
mysql-server:
pkg:
- installed
- require:
- debconf: mysql_setup
That isn't how the pkg.installed directive works. You want this:
mysql-server:
pkg.installed
mysql-common
pkg.installed
mysql-client
pkg.installed