Skip to content

Commit

Permalink
Merge pull request saltstack-formulas#225 from myii/chore/standardise…
Browse files Browse the repository at this point in the history
…-structure

feat(yamllint): include for this repo and apply rules throughout
  • Loading branch information
aboe76 authored Aug 17, 2019
2 parents 272a1ae + 9f739fa commit 755d916
Show file tree
Hide file tree
Showing 10 changed files with 296 additions and 166 deletions.
13 changes: 9 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
---
stages:
- test
- commitlint
- lint
- name: release
if: branch = master AND type != pull_request

Expand Down Expand Up @@ -49,16 +49,21 @@ script:

jobs:
include:
# Define the commitlint stage
- stage: commitlint
# Define the `lint` stage (runs `yamllint` and `commitlint`)
- stage: lint
language: node_js
node_js: lts/*
before_install: skip
script:
# Install and run `yamllint`
- pip install --user yamllint
# yamllint disable-line rule:line-length
- yamllint -s . .yamllint pillar.example test/salt/pillar/mysql.sls
# Install and run `commitlint`
- npm install @commitlint/config-conventional -D
- npm install @commitlint/travis-cli -D
- commitlint-travis
# Define the release stage that runs semantic-release
# Define the release stage that runs `semantic-release`
- stage: release
language: node_js
node_js: lts/*
Expand Down
18 changes: 18 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
# Extend the `default` configuration provided by `yamllint`
extends: default

# Files to ignore completely
# 1. All YAML files under directory `node_modules/`, introduced during the Travis run
# 2. Any YAML files using Jinja (result in `yamllint` syntax errors)
ignore: |
node_modules/
mysql/supported_sections.yaml
rules:
line-length:
# Increase from default of `80`
# Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`)
max: 88
57 changes: 32 additions & 25 deletions mysql/defaults.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# vim: sts=2 ts=2 sw=2 et ai
#
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
mysql:
serverpkg: mysql-server
clientpkg: mysql-client
service: mysql
{%- if grains.pythonversion[0] == 2 %}
pythonpkg: python-mysqldb
{% else %}
pythonpkg: python3-mysqldb
{% endif %}
devpkg: mysql-devel
debconf_utils: debconf-utils

Expand Down Expand Up @@ -40,66 +36,77 @@ mysql:
retries: 2
products:
community_server:
enabled: True
enabled: true
# yamllint disable-line rule:line-length
url: https://downloads.mysql.com/archives/get/file/mysql-8.0.11-macos10.13-x86_64.dmg
sum: 'md5=602a84390ecf3d82025b1d99fc594124'
isapp: False
isapp: false
path: /usr/local/mysql
app: mysql
workbench:
enabled: True
enabled: true
# yamllint disable-line rule:line-length
url: https://downloads.mysql.com/archives/get/file/mysql-workbench-community-8.0.11-rc-macos-x86_64.dmg
sum: 'md5=37c5ae5bd75a4e1804ae6e0127d68611'
isapp: True
isapp: true
path: /Applications/MySQLWorkbench/Contents/Versions/latest
app: MySQLWorkbench
cluster:
enabled: False
enabled: false
# yamllint disable-line rule:line-length
url: https://downloads.mysql.com/archives/get/file/mysql-cluster-gpl-7.6.6-macos10.13-x86_64.dmg
sum: 'md5=0df975908e7d8e4e8c1003d95edf4721'
isapp: False
isapp: false
path: /usr/local/mysqlcluster
app: MySQLCluster
router:
enabled: False
enabled: false
# yamllint disable-line rule:line-length
url: https://downloads.mysql.com/archives/get/file/mysql-router-8.0.11-macos10.13-x86-64bit.dmg
sum: 'md5=8dd536f2f223933ecbfb8b19e54ee2f6'
isapp: False
isapp: false
app: MySQLRouter
utilities:
enabled: False
enabled: false
# yamllint disable-line rule:line-length
url: https://downloads.mysql.com/archives/get/file/mysql-utilities-1.6.5-macos10.12.dmg
sum: 'md5=4c8e75bb217b8293dcdeb915b649c2c8'
isapp: True ## ??
isapp: true ## ??
app: MySQLUtilties
shell:
enabled: False
enabled: false
# yamllint disable-line rule:line-length
url: https://downloads.mysql.com/archives/get/file/mysql-shell-8.0.11-macos10.13-x86-64bit.dmg
sum: 'md5=43db4f0fc39f88c1d7be4a4f52cec363'
isapp: True ## ??
isapp: true ## ??
app: MySQLShell
proxy:
enabled: False
enabled: false
# yamllint disable-line rule:line-length
url: https://downloads.mysql.com/archives/get/file/mysql-proxy-0.8.5-osx10.7-x86-32bit.tar.gz
sum: 'md5=107df22412aa8c483d2021e1af24ee22'
connector:
enabled: False
enabled: false
# yamllint disable-line rule:line-length
url: https://downloads.mysql.com/archives/get/file/mysql-connector-nodejs-8.0.11.tar.gz
sum: 'md5=dece7fe5607918ba68499ef07c31508d'
forvisualstudio:
enabled: False
enabled: false
# yamllint disable-line rule:line-length
url: https://downloads.mysql.com/archives/get/file/mysql-for-visualstudio-2.0.4-src.zip
sum: 'md5=fcf39316505ee2921e31a431eae77a9c'
forexcel:
enabled: False
enabled: false
# yamllint disable-line rule:line-length
url: https://downloads.mysql.com/archives/get/file/mysql-for-excel-1.3.6-src.zip
sum: 'md5=2cc8b65eb72a1b07a6e4e2665e2a29e3'
notifier:
enabled: False
enabled: false
# yamllint disable-line rule:line-length
url: https://downloads.mysql.com/archives/get/file/mysql-notifier-1.1.6-src.zip
sum: 'md5=349f1994681763fd6626a8ddf6be5363'

#The following dict names are reserved for pillar data (see pillar.example)
# The following dict names are reserved for pillar data (see pillar.example)
global: {}
clients: {}
library: {}
Expand Down
70 changes: 57 additions & 13 deletions mysql/map.jinja
Original file line number Diff line number Diff line change
@@ -1,17 +1,61 @@
{% import_yaml "mysql/defaults.yaml" as defaults %}
{% import_yaml "mysql/osfamilymap.yaml" as osfamilymap %}
{% import_yaml "mysql/osmap.yaml" as osmap %}
# -*- coding: utf-8 -*-
# vim: ft=jinja

{% set mysql = salt['grains.filter_by'](
defaults,
merge=salt['grains.filter_by'](
osfamilymap,
grain='os_family',
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{#- Start imports as #}
{%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %}
{%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %}
{%- import_yaml tplroot ~ "/osmap.yaml" as osmap %}
{%- import_yaml tplroot ~ "/osfingermap.yaml" as osfingermap %}

{#- Retrieve the config dict only once #}
{%- set _config = salt['config.get'](tplroot, default={}) %}

{%- set py_ver_settings = {
2: {'pythonpkg': 'python-mysqldb'},
3: {'pythonpkg': 'python3-mysqldb'},
} %}

{%- set defaults = salt['grains.filter_by'](
py_ver_settings,
default=grains.pythonversion[0],
merge=salt['grains.filter_by'](
default_settings,
default=tplroot,
merge=salt['grains.filter_by'](
osfamilymap,
grain='os_family',
merge=salt['grains.filter_by'](
osmap,
grain='os',
merge=salt['pillar.get']('mysql', {}),
),
),
base='mysql',
) %}
merge=salt['grains.filter_by'](
osfingermap,
grain='osfinger',
merge=salt['grains.filter_by'](
_config,
default='lookup'
)
)
)
)
)
)
%}

{%- set config = salt['grains.filter_by'](
{'defaults': defaults},
default='defaults',
merge=_config
)
%}

{%- set mysql = config %}

{#- Post-processing for specific non-YAML customisations #}
{%- if grains.os == 'MacOS' %}
{%- set macos_user = salt['pillar.get']('mysql:user', salt['cmd.run']("stat -f '%Su' /dev/console")) %}
{%- set macos_group = salt['pillar.get']('mysql:group', salt['cmd.run']("stat -f '%Sg' /dev/console")) %}
{%- do mysql.macos.update({'user': macos_user}) %}
{%- do mysql.macos.update({'group': macos_group}) %}
{%- endif %}
56 changes: 16 additions & 40 deletions mysql/osfamilymap.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
# vim: sts=2 ts=2 sw=2 et ai
#

# -*- coding: utf-8 -*-
# vim: ft=yaml
---
Debian:
{% if 'osmajorrelease' in grains and salt['grains.get']('osmajorrelease')|int >= 9 %}
serverpkg: mariadb-server
service: mariadb
clientpkg: mariadb-client
devpkg: libmariadbclient-dev
{% else %}
devpkg: libmysqlclient-dev
{% endif %}

config:
sections:
Expand All @@ -20,7 +13,7 @@ Debian:
pid_file: /var/run/mysqld/mysqld.pid
basedir: /usr
tmpdir: /tmp
lc_messages_dir: /usr/share/mysql
lc_messages_dir: /usr/share/mysql
skip_external_locking: noarg_present
bind_address: 127.0.0.1
key_buffer_size: 16M
Expand All @@ -31,9 +24,9 @@ Debian:
query_cache_size: 16M
expire_logs_days: 10
max_binlog_size: 100M
#innodb_flush_log_at_trx_commit: 1
#innodb_lock_wait_timeout: 50
#innodb_file_per_table: noarg_present
# innodb_flush_log_at_trx_commit: 1
# innodb_lock_wait_timeout: 50
# innodb_file_per_table: noarg_present
mysqldump:
quick: noarg_present
quote_names: noarg_present
Expand All @@ -42,31 +35,18 @@ Debian:
key_buffer_size: 16M
append: |
!includedir /etc/mysql/conf.d/
# {% if 'osmajorrelease' in grains and salt['grains.get']('osmajorrelease')|int >= 9 -%}
# !includedir /etc/mysql/mariadb.conf.d/
# {%- endif %}
RedHat:
#https://mariadb.com/blog/rhel7-transition-mysql-mariadb-first-look
{%- if 'osmajorrelease' in grains and salt['grains.get']('osmajorrelease')|int in [7] %}
{% set fork = 'mariadb' %}
serverpkg: mariadb-server
service: mariadb
devpkg: mariadb-devel
{%- else %}
{% set fork = 'mysql' %}
service: mysqld
{%- endif %}

clientpkg: {{ fork }}
clientpkg: mysql
pythonpkg: MySQL-python
config:
file: /etc/my.cnf
sections:
client:
mysqld_safe:
log_error: /var/log/{{ fork }}/mysqld.log
pid_file: /var/run/{{ fork }}/mysqld.pid
log_error: /var/log/mysql/mysqld.log
pid_file: /var/run/mysql/mysqld.pid
mysqld:
socket: /var/lib/mysql/mysql.sock
bind_address: 127.0.0.1
Expand All @@ -75,12 +55,7 @@ RedHat:
Suse:
serverpkg: mariadb
clientpkg: mariadb-client
{%- if 'osmajorrelease' in grains and salt['grains.get']('osmajorrelease')|int == 42 %}
# "old" package name up to Leap 42.x
pythonpkg: python-PyMySQL
{% else %}
pythonpkg: python2-pymysql
{% endif %}

config:
file: /etc/my.cnf
Expand All @@ -91,10 +66,10 @@ Suse:
port:
user:
socket:
datadir:
datadir:
tmpdir:
innodb_file_format: Barracuda
innodb_file_per_table: ON
innodb_file_per_table: 'ON'
server-id: 1
sql_mode: NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
mysqld_multi:
Expand Down Expand Up @@ -178,7 +153,7 @@ Gentoo:
default_character_set: utf8
myisamchk:
character_sets_dir: /usr/share/mysql/charsets
key_buffer: 20M ##????? key_buffer_size ?
key_buffer: 20M ## ????? key_buffer_size ?
sort_buffer_size: 20M
read_buffer: 2M
write_buffer: 2M
Expand All @@ -188,7 +163,8 @@ Gentoo:
err_log: /var/log/mysql/mysql.err
mysqld:
character_set_serverpkg: utf8
# note: the gentoo init.d script specifically needs pid-file (dash not underscore)
# note: the gentoo init.d script specifically needs pid-file
# (dash not underscore)
pid-file: /var/run/mysqld/mysqld.pid
log_error: /var/log/mysql/mysqld.err
basedir: /usr
Expand Down Expand Up @@ -217,7 +193,7 @@ Gentoo:
innodb_lock_wait_timeout: 50
innodb_file_per_table: noarg_present
isamchk:
key_buffer: 20M ##????? key_buffer_size ?
key_buffer: 20M ## ????? key_buffer_size ?
sort_buffer_size: 20M
read_buffer: 2M
write_buffer: 2M
Expand Down
Loading

0 comments on commit 755d916

Please sign in to comment.