mirror of
https://github.com/saltstack-formulas/mysql-formula.git
synced 2025-04-16 17:50:27 +00:00
Merge pull request #141 from Routhinator/add_official_repo_state
Add official repo state
This commit is contained in:
commit
88cbde3c83
2 changed files with 75 additions and 0 deletions
10
README.rst
10
README.rst
|
@ -96,3 +96,13 @@ Install the MySQL development libraries and header files.
|
|||
Note that this state is not installed by the mysql meta-state unless you set
|
||||
your pillar data accordingly.
|
||||
|
||||
``mysql.repo``
|
||||
--------------
|
||||
|
||||
Add the official MySQL 5.7 repository.
|
||||
|
||||
.. note::
|
||||
Note that this state currently only supports MySQL 5.7 for RHEL systems.
|
||||
Debian and Suse support to be added. Also need to add the option to allow
|
||||
selection of MySQL version (5.6 and 5.5 repos are added but disabled) and
|
||||
changed enabled repository accordingly.
|
||||
|
|
65
mysql/repo.sls
Normal file
65
mysql/repo.sls
Normal file
|
@ -0,0 +1,65 @@
|
|||
include:
|
||||
- mysql.config
|
||||
|
||||
{% from "mysql/defaults.yaml" import rawmap with context %}
|
||||
{%- set mysql = salt['grains.filter_by'](rawmap, grain='os', merge=salt['pillar.get']('mysql:lookup')) %}
|
||||
|
||||
# Completely ignore non-RHEL based systems
|
||||
# TODO: Add Debian and Suse systems.
|
||||
# TODO: Allow user to specify MySQL version and alter yum repo file accordingly.
|
||||
{% if grains['os_family'] == 'RedHat' %}
|
||||
{% if grains['osmajorrelease'][0] == '5' %}
|
||||
{% set rpm_source = "http://repo.mysql.com/mysql57-community-release-el5.rpm" %}
|
||||
{% elif grains['osmajorrelease'][0] == '6' %}
|
||||
{% set rpm_source = "http://repo.mysql.com/mysql57-community-release-el6.rpm" %}
|
||||
{% elif grains['osmajorrelease'][0] == '7' %}
|
||||
{% set rpm_source = "http://repo.mysql.com/mysql57-community-release-el7.rpm" %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% set mysql57_community_release = salt['pillar.get']('mysql:release', false) %}
|
||||
# A lookup table for MySQL Repo GPG keys & RPM URLs for various RedHat releases
|
||||
{% set pkg = {
|
||||
'key': 'http://repo.mysql.com/RPM-GPG-KEY-mysql',
|
||||
'key_hash': 'md5=e9efdf96207c90f4487462cd1f3ff764',
|
||||
'rpm': rpm_source
|
||||
} %}
|
||||
|
||||
|
||||
install_pubkey_mysql:
|
||||
file.managed:
|
||||
- name: /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
|
||||
- source: {{ salt['pillar.get']('mysql:pubkey', pkg.key) }}
|
||||
- source_hash: {{ salt['pillar.get']('mysql:pubkey_hash', pkg.key_hash) }}
|
||||
|
||||
mysql57_community_release:
|
||||
pkg.installed:
|
||||
- sources:
|
||||
- mysql57-community-release: {{ salt['pillar.get']('mysql:repo_rpm', pkg.rpm) }}
|
||||
- require:
|
||||
- file: install_pubkey_mysql
|
||||
- require_in:
|
||||
{% if "server_config" in mysql %}
|
||||
- pkg: {{ mysql.server }}
|
||||
{% endif %}
|
||||
{% if "clients_config" in mysql %}
|
||||
- pkg: {{ mysql.client }}
|
||||
{% endif %}
|
||||
|
||||
set_pubkey_mysql:
|
||||
file.replace:
|
||||
- append_if_not_found: True
|
||||
- name: /etc/yum.repos.d/mysql-community.repo
|
||||
- pattern: '^gpgkey=.*'
|
||||
- repl: 'gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql'
|
||||
- require:
|
||||
- pkg: mysql57_community_release
|
||||
|
||||
set_gpg_mysql:
|
||||
file.replace:
|
||||
- append_if_not_found: True
|
||||
- name: /etc/yum.repos.d/mysql-community.repo
|
||||
- pattern: 'gpgcheck=.*'
|
||||
- repl: 'gpgcheck=1'
|
||||
- require:
|
||||
- pkg: mysql57_community_release
|
Loading…
Add table
Reference in a new issue