Skip to content

Commit

Permalink
Merge pull request #232 from daks/style-sls
Browse files Browse the repository at this point in the history
style: remove previous line from jinja directives
  • Loading branch information
myii authored Dec 3, 2019
2 parents 32ac499 + ec0e2a7 commit bd25712
Show file tree
Hide file tree
Showing 14 changed files with 225 additions and 225 deletions.
2 changes: 1 addition & 1 deletion mysql/apparmor.sls
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% from tpldir ~ "/map.jinja" import mysql with context %}
{%- from tpldir ~ "/map.jinja" import mysql with context %}
{%- if "apparmor" in mysql.config %}
Expand Down
2 changes: 1 addition & 1 deletion mysql/client.sls
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include:
- .config

{% from tpldir ~ "/map.jinja" import mysql with context %}
{%- from tpldir ~ "/map.jinja" import mysql with context %}
mysql:
pkg.installed:
Expand Down
54 changes: 27 additions & 27 deletions mysql/config.sls
Original file line number Diff line number Diff line change
@@ -1,100 +1,100 @@
{% from tpldir ~ "/map.jinja" import mysql with context %}
{% set os_family = salt['grains.get']('os_family', None) %}
{%- from tpldir ~ "/map.jinja" import mysql with context %}
{%- set os_family = salt['grains.get']('os_family', None) %}
{% if "config_directory" in mysql %}
{%- if "config_directory" in mysql %}
mysql_config_directory:
file.directory:
- name: {{ mysql.config_directory }}
{% if os_family in ['Debian', 'Gentoo', 'RedHat'] %}
{%- if os_family in ['Debian', 'Gentoo', 'RedHat'] %}
- user: root
- group: root
- mode: 755
{% endif %}
{%- endif %}
- makedirs: True
{% if "server_config" in mysql %}
{%- if "server_config" in mysql %}
mysql_server_config:
file.managed:
- name: {{ mysql.config_directory + mysql.server_config.file }}
- template: jinja
- source: salt://{{ tpldir }}/files/server.cnf
{% if os_family in ['Debian', 'Gentoo', 'RedHat'] %}
{%- if os_family in ['Debian', 'Gentoo', 'RedHat'] %}
- context:
tpldir: {{ tpldir }}
- user: root
- group: root
- mode: 644
{% endif %}
{%- endif %}
- require:
- file: mysql_config_directory
{% endif %}
{%- endif %}
{% if "galera_config" in mysql %}
{%- if "galera_config" in mysql %}
mysql_galera_config:
file.managed:
- name: {{ mysql.config_directory + mysql.galera_config.file }}
- template: jinja
- source: salt://{{ tpldir }}/files/galera.cnf
{% if os_family in ['Debian', 'Gentoo', 'RedHat'] %}
{%- if os_family in ['Debian', 'Gentoo', 'RedHat'] %}
- context:
tpldir: {{ tpldir }}
- user: root
- group: root
- mode: 644
{% endif %}
{%- endif %}
- require:
- file: mysql_config_directory
{% endif %}
{%- endif %}
{% if "library_config" in mysql %}
{%- if "library_config" in mysql %}
mysql_library_config:
file.managed:
- name: {{ mysql.config_directory + mysql.library_config.file }}
- template: jinja
- source: salt://{{ tpldir }}/files/client.cnf
{% if os_family in ['Debian', 'Gentoo', 'RedHat'] %}
{%- if os_family in ['Debian', 'Gentoo', 'RedHat'] %}
- context:
tpldir: {{ tpldir }}
- user: root
- group: root
- mode: 644
{% endif %}
{%- endif %}
- require:
- file: mysql_config_directory
{% endif %}
{%- endif %}
{% if "clients_config" in mysql %}
{%- if "clients_config" in mysql %}
mysql_clients_config:
file.managed:
- name: {{ mysql.config_directory + mysql.clients_config.file }}
- template: jinja
- source: salt://{{ tpldir }}/files/mysql-clients.cnf
{% if os_family in ['Debian', 'Gentoo', 'RedHat'] %}
{%- if os_family in ['Debian', 'Gentoo', 'RedHat'] %}
- context:
tpldir: {{ tpldir }}
- user: root
- group: root
- mode: 644
{% endif %}
{%- endif %}
- require:
- file: mysql_config_directory
{% endif %}
{%- endif %}
{% endif %}
{%- endif %}
mysql_config:
file.managed:
- name: {{ mysql.config.file }}
- template: jinja
{% if "config_directory" in mysql %}
{%- if "config_directory" in mysql %}
- source: salt://{{ tpldir }}/files/my-include.cnf
{% else %}
{%- else %}
- source: salt://{{ tpldir }}/files/my.cnf
{% endif %}
{%- endif %}
- context:
tpldir: {{ tpldir }}
{% if os_family in ['Debian', 'Gentoo', 'RedHat'] %}
{%- if os_family in ['Debian', 'Gentoo', 'RedHat'] %}
- user: root
- group: root
- mode: 644
{% endif %}
{%- endif %}
60 changes: 30 additions & 30 deletions mysql/database.sls
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
{% from tpldir ~ "/map.jinja" import mysql with context %}
{%- from tpldir ~ "/map.jinja" import mysql with context %}
{% set mysql_root_user = salt['pillar.get']('mysql:server:root_user', 'root') %}
{% set mysql_root_pass = salt['pillar.get']('mysql:server:root_password', salt['grains.get']('server_id')) %}
{% set mysql_host = salt['pillar.get']('mysql:server:host', 'localhost') %}
{% set db_states = [] %}
{%- set mysql_root_user = salt['pillar.get']('mysql:server:root_user', 'root') %}
{%- set mysql_root_pass = salt['pillar.get']('mysql:server:root_password', salt['grains.get']('server_id')) %}
{%- set mysql_host = salt['pillar.get']('mysql:server:host', 'localhost') %}
{%- set db_states = [] %}
{% set mysql_salt_user = salt['pillar.get']('mysql:salt_user:salt_user_name', mysql_root_user) %}
{% set mysql_salt_pass = salt['pillar.get']('mysql:salt_user:salt_user_password', mysql_root_pass) %}
{%- set mysql_salt_user = salt['pillar.get']('mysql:salt_user:salt_user_name', mysql_root_user) %}
{%- set mysql_salt_pass = salt['pillar.get']('mysql:salt_user:salt_user_password', mysql_root_pass) %}
include:
- .python
{% for database_obj in salt['pillar.get']('mysql:database', []) %}
{% set state_id = 'mysql_db_' ~ loop.index0 %}
{% if not database_obj %}{# in case database_obj == [] #}
{% continue %}
{% elif database_obj is mapping %}
{% set database = database_obj.get('name') %}
{% set present = database_obj.get('present', True) %}
{% else %}
{% set database = database_obj %}
{% set present = True %}
{% endif %}
{%- for database_obj in salt['pillar.get']('mysql:database', []) %}
{%- set state_id = 'mysql_db_' ~ loop.index0 %}
{%- if not database_obj %}{# in case database_obj == [] #}
{%- continue %}
{%- elif database_obj is mapping %}
{%- set database = database_obj.get('name') %}
{%- set present = database_obj.get('present', True) %}
{%- else %}
{%- set database = database_obj %}
{%- set present = True %}
{%- endif %}
{{ state_id }}:
{%- if present %}
mysql_database.present:
{% if database_obj is mapping %}
{%- if database_obj is mapping %}
- character_set: {{ database_obj.get('character_set', '') }}
- collate: {{ database_obj.get('collate', '') }}
{% endif %}
{% else %}
{%- endif %}
{%- else %}
mysql_database.absent:
{% endif %}
{%- endif %}
- name: {{ database }}
- connection_host: '{{ mysql_host }}'
- connection_user: '{{ mysql_salt_user }}'
{% if mysql_salt_pass %}
{%- if mysql_salt_pass %}
- connection_pass: '{{ mysql_salt_pass }}'
{% endif %}
{%- endif %}
- connection_charset: utf8
{% if salt['pillar.get'](['mysql', 'schema', database, 'load']|join(':'), False) %}
{%- if salt['pillar.get'](['mysql', 'schema', database, 'load']|join(':'), False) %}
{{ state_id }}_schema:
file.managed:
- name: /etc/mysql/{{ database }}.schema
Expand All @@ -50,17 +50,17 @@ include:
{%- if template_type %}
- template: {{ template_type }}
- context: {{ template_context|yaml }}
{% endif %}
{%- endif %}
- user: {{ salt['pillar.get']('mysql:server:user', 'mysql') }}
- makedirs: True
{{ state_id }}_load:
cmd.wait:
- name: mysql -u {{ mysql_salt_user }} -h{{ mysql_host }} {% if mysql_salt_pass %}-p{% endif %}{{ mysql_salt_pass }} {{ database }} < /etc/mysql/{{ database }}.schema
- name: mysql -u {{ mysql_salt_user }} -h{{ mysql_host }} {%- if mysql_salt_pass %}-p{%- endif %}{{ mysql_salt_pass }} {{ database }} < /etc/mysql/{{ database }}.schema
- watch:
- file: {{ state_id }}_schema
- mysql_database: {{ state_id }}
{% endif %}
{%- endif %}
{% do db_states.append(state_id) %}
{% endfor %}
{%- do db_states.append(state_id) %}
{%- endfor %}
2 changes: 1 addition & 1 deletion mysql/dev.sls
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% from tpldir ~ "/map.jinja" import mysql with context %}
{%- from tpldir ~ "/map.jinja" import mysql with context %}
mysql_dev:
pkg:
Expand Down
2 changes: 1 addition & 1 deletion mysql/disabled.sls
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% from tpldir ~ "/map.jinja" import mysql with context %}
{%- from tpldir ~ "/map.jinja" import mysql with context %}
mysql:
service.dead:
Expand Down
24 changes: 12 additions & 12 deletions mysql/init.sls
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
{% from tpldir ~ '/database.sls' import db_states with context %}
{% from tpldir ~ '/user.sls' import user_states with context %}
{%- from tpldir ~ '/database.sls' import db_states with context %}
{%- from tpldir ~ '/user.sls' import user_states with context %}
{% macro requisites(type, states) %}
{%- macro requisites(type, states) %}
{%- for state in states %}
- {{ type }}: {{ state }}
{%- endfor -%}
{% endmacro %}
{%- endmacro %}
{% set mysql_dev = salt['pillar.get']('mysql:dev:install', False) %}
{% set mysql_salt_user = salt['pillar.get']('mysql:salt_user:salt_user_name', False) %}
{%- set mysql_dev = salt['pillar.get']('mysql:dev:install', False) %}
{%- set mysql_salt_user = salt['pillar.get']('mysql:salt_user:salt_user_name', False) %}
include:
- .server
{% if mysql_salt_user %}
{%- if mysql_salt_user %}
- .salt-user
{% endif %}
{%- endif %}
- .database
- .user
{% if mysql_dev %}
{%- if mysql_dev %}
- .dev
{% endif %}
{%- endif %}
{% if (db_states|length() + user_states|length()) > 0 %}
{%- if (db_states|length() + user_states|length()) > 0 %}
extend:
mysqld-service-running:
service:
- require_in:
{{ requisites('mysql_database', db_states) }}
{{ requisites('mysql_user', user_states) }}
{% endif %}
{%- endif %}
6 changes: 3 additions & 3 deletions mysql/macos/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ mysql-macos-download-{{ product }}-archive:
cmd.run:
- name: curl {{ dl.opts }} -o {{ dl.tmpdir }}/{{ archivefile }} {{ data.url }}
- unless: test -f {{ dl.tmpdir }}/{{ archivefile }}
{% if grains['saltversioninfo'] >= [2017, 7, 0] %}
{%- if grains['saltversioninfo'] >= [2017, 7, 0] %}
- retry:
attempts: {{ dl.retries }}
interval: {{ dl.interval }}
until: True
splay: 10
{% endif %}
{%- endif %}
- require:
- mysql-macos-extract-dirs

Expand Down Expand Up @@ -93,4 +93,4 @@ mysql-macos-{{ product }}-desktop-shortcut-add:
- file: mysql-macos-{{ product }}-desktop-shortcut-add

{%- endif %}
{% endfor %}
{%- endfor %}
2 changes: 1 addition & 1 deletion mysql/python.sls
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% from tpldir ~ "/map.jinja" import mysql with context %}
{%- from tpldir ~ "/map.jinja" import mysql with context %}
mysql_python:
pkg.installed:
Expand Down
14 changes: 7 additions & 7 deletions mysql/remove_test_database.sls
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% set mysql_root_user = salt['pillar.get']('mysql:server:root_user', 'root') %}
{% set mysql_root_pass = salt['pillar.get']('mysql:server:root_password', salt['grains.get']('server_id')) %}
{% set mysql_host = salt['pillar.get']('mysql:server:host', 'localhost') %}
{% set mysql_salt_user = salt['pillar.get']('mysql:salt_user:salt_user_name', mysql_root_user) %}
{% set mysql_salt_pass = salt['pillar.get']('mysql:salt_user:salt_user_password', mysql_root_pass) %}
{%- set mysql_root_user = salt['pillar.get']('mysql:server:root_user', 'root') %}
{%- set mysql_root_pass = salt['pillar.get']('mysql:server:root_password', salt['grains.get']('server_id')) %}
{%- set mysql_host = salt['pillar.get']('mysql:server:host', 'localhost') %}
{%- set mysql_salt_user = salt['pillar.get']('mysql:salt_user:salt_user_name', mysql_root_user) %}
{%- set mysql_salt_pass = salt['pillar.get']('mysql:salt_user:salt_user_password', mysql_root_pass) %}

include:
- .python
Expand All @@ -13,7 +13,7 @@ mysql remove test database:
- host: '{{ mysql_host }}'
- connection_user: '{{ mysql_salt_user }}'
- connection_host: '{{ mysql_host }}'
{% if mysql_salt_pass %}
{%- if mysql_salt_pass %}
- connection_pass: '{{ mysql_salt_pass }}'
{% endif %}
{%- endif %}
- connection_charset: utf8
Loading

0 comments on commit bd25712

Please sign in to comment.