Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
mariadb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
webarch
mariadb
Commits
7b055a0c
Verified
Commit
7b055a0c
authored
1 year ago
by
Chris Croome
Browse files
Options
Downloads
Patches
Plain Diff
Refactor WIP
parent
45a0cf49
No related branches found
No related tags found
No related merge requests found
Pipeline
#27098
failed
1 year ago
Stage: lint
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
defaults/main.yml
+5
-4
5 additions, 4 deletions
defaults/main.yml
tasks/conf.yml
+1
-1
1 addition, 1 deletion
tasks/conf.yml
tasks/conf_edited.yml
+29
-0
29 additions, 0 deletions
tasks/conf_edited.yml
tasks/conf_section_edited.yml
+40
-0
40 additions, 0 deletions
tasks/conf_section_edited.yml
with
75 additions
and
5 deletions
defaults/main.yml
+
5
−
4
View file @
7b055a0c
...
...
@@ -16,10 +16,10 @@ mariadb_config:
state
:
edited
conf
:
mysqld
:
binlog_format
:
ROW
innodb_buffer_pool_instances
:
1
innodb_buffer_pool_size
:
1G
innodb_log_file_size
:
256M
binlog_format
:
"
ROW
"
innodb_buffer_pool_instances
:
"
1"
innodb_buffer_pool_size
:
"
256M"
innodb_log_file_size
:
"
64M"
join_buffer_size
:
"
8M"
key_buffer_size
:
"
16M"
max_allowed_packet
:
"
64M"
...
...
@@ -30,6 +30,7 @@ mariadb_config:
query_cache_limit
:
"
0"
query_cache_size
:
"
0"
query_cache_type
:
"
0"
slow_query_log_file
:
"
/var/log/mysql/mariadb-slow.log"
table_cache
:
"
64"
table_open_cache
:
"
4000"
thread_concurrency
:
"
10"
...
...
This diff is collapsed.
Click to expand it.
tasks/conf.yml
+
1
−
1
View file @
7b055a0c
...
...
@@ -45,7 +45,7 @@
ansible.builtin.assert
:
that
:
-
mariadb_cnf_section.value | ansible.builtin.flatten | select('regex', '-') == []
quiet
:
"
{%
if
ansible_check_mode
or
ansible_verbosity
>
=
2
%}
fals
e{%
else
%}
tru
e{%
endif
%}"
quiet
:
"
{%
if
ansible_verbosity
=
=
0
%}
tru
e{%
else
%}
fals
e{%
endif
%}"
fail_msg
:
Although dashes or underscores can be used for MariaDB configuration variables this role only suppports the use of underscores.
loop
:
"
{{
mariadb_cnf.conf
|
ansible.builtin.dict2items
}}"
loop_control
:
...
...
This diff is collapsed.
Click to expand it.
tasks/conf_edited.yml
+
29
−
0
View file @
7b055a0c
...
...
@@ -23,8 +23,15 @@
mode
:
"
{{
mariadb_cnf.mode
|
default('0644')
}}"
owner
:
"
{{
mariadb_cnf.owner
|
default('root')
}}"
group
:
"
{{
mariadb_cnf.owner
|
default('root')
}}"
changed_when
:
false
register
:
mariadb_cnf_file_backup
when
:
mariadb_cnf_file_path.stat.exists | bool
-
name
:
Debug MariaDB configuration file backup
ansible.builtin.debug
:
var
:
mariadb_cnf_file_backup
verbosity
:
"
{%
if
ansible_check_mode
|
bool
%}2{%
else
%}3{%
endif
%}"
-
name
:
Include the MariaDB configuration file section edited tasks
ansible.builtin.include_tasks
:
conf_section_edited.yml
loop
:
"
{{
mariadb_cnf.conf
|
dict2items
}}"
...
...
@@ -52,6 +59,28 @@
owner
:
"
{{
mariadb_cnf.owner
|
default('root')
}}"
group
:
"
{{
mariadb_cnf.owner
|
default('root')
}}"
-
name
:
Stat the MariaDB configuration file
ansible.builtin.stat
:
path
:
"
{{
mariadb_cnf.path
}}"
get_checksum
:
true
checksum_algorithm
:
sha1
register
:
mariadb_cnf_file_edited
-
name
:
Debug MariaDB configuration file
ansible.builtin.debug
:
var
:
mariadb_cnf_file_edited
verbosity
:
"
{%
if
ansible_check_mode
|
bool
%}2{%
else
%}3{%
endif
%}"
-
name
:
MariaDB configuration file backup absent when it is unchanged
ansible.builtin.file
:
path
:
"
{{
mariadb_cnf_file_path_backup
}}"
state
:
absent
changed_when
:
false
when
:
-
mariadb_cnf_file_path.stat.exists | bool
-
mariadb_cnf_file_backup.checksum is defined
-
mariadb_cnf_file_backup.checksum == mariadb_cnf_file_edited.stat.checksum
tags
:
-
mariadb
-
mariadb_conf
...
...
This diff is collapsed.
Click to expand it.
tasks/conf_section_edited.yml
+
40
−
0
View file @
7b055a0c
...
...
@@ -18,6 +18,7 @@
-
"
Section:
{{
mariadb_cnf_section.key
}}"
-
"
Existing:
{{
mariadb_cnf_variable_pair.key
}}:
{{
mariadb_cnf_file_existing_vars
|
community.general.json_query(mariadb_cnf_variable_jpq)
}}"
-
"
Proposed:
{{
mariadb_cnf_variable_pair.key
}}:
{{
mariadb_cnf_variable_pair.value
}}"
-
"
Regex:
^[#][
]{0,9}{{
mariadb_cnf_variable_pair.key
|
regex_replace('_',
'[_-]')
}}[
]{0,9}[=]"
verbosity
:
"
{%
if
ansible_check_mode
|
bool
%}0{%
else
%}1{%
endif
%}"
when
:
mariadb_cnf_variable_pair.value != mariadb_cnf_file_existing_vars | community.general.json_query(mariadb_cnf_variable_jpq)
vars
:
...
...
@@ -27,6 +28,45 @@
loop_var
:
mariadb_cnf_variable_pair
label
:
"
{{
mariadb_cnf_variable_pair.key
}}"
# This is to ensure that variables are written to the same place as existing commented values
-
name
:
Uncomment commented variables in the MariaDB configuration file that are to be edited
ansible.builtin.lineinfile
:
path
:
"
{{
mariadb_cnf.path
}}"
line
:
"
{{
mariadb_cnf_variable_pair.key
}}{%
if
mariadb_cnf_variable_pair.value
is
defined
%}=
{{
mariadb_cnf_variable_pair.value
}}{%
endif
%}"
regex
:
"
{{
mariadb_cnf_variable_regex
}}"
state
:
present
backrefs
:
true
mode
:
"
{{
mariadb_cnf.mode
|
default('0644')
}}"
owner
:
"
{{
mariadb_cnf.owner
|
default('root')
}}"
group
:
"
{{
mariadb_cnf.owner
|
default('root')
}}"
when
:
mariadb_cnf_variable_pair.value != mariadb_cnf_file_existing_vars | community.general.json_query(mariadb_cnf_variable_jpq)
vars
:
mariadb_cnf_variable_jpq
:
'
"{{
mariadb_cnf_section.key
}}"."{{
mariadb_cnf_variable_pair.key
}}"'
mariadb_cnf_variable_regex
:
"
^[#][
]{0,9}{{
mariadb_cnf_variable_pair.key
|
regex_replace('_',
'[_-]')
}}[
]{0,9}[=]"
loop
:
"
{{
mariadb_cnf_section.value
|
ansible.builtin.dict2items
}}"
loop_control
:
loop_var
:
mariadb_cnf_variable_pair
label
:
"
{{
mariadb_cnf_variable_pair.key
}}"
-
name
:
MariaDB configuration file edited
community.general.ini_file
:
path
:
"
{{
mariadb_cnf.path
}}"
section
:
"
{{
mariadb_cnf_section.key
}}"
option
:
"
{{
mariadb_cnf_variable_pair.key
}}"
value
:
"
{{
mariadb_cnf_variable_pair.value
}}"
allow_no_value
:
true
no_extra_spaces
:
false
mode
:
"
{{
mariadb_cnf.mode
|
default('0644')
}}"
owner
:
"
{{
mariadb_cnf.owner
|
default('root')
}}"
group
:
"
{{
mariadb_cnf.owner
|
default('root')
}}"
when
:
mariadb_cnf_variable_pair.value != mariadb_cnf_file_existing_vars | community.general.json_query(mariadb_cnf_variable_jpq)
vars
:
mariadb_cnf_variable_jpq
:
'
"{{
mariadb_cnf_section.key
}}"."{{
mariadb_cnf_variable_pair.key
}}"'
loop
:
"
{{
mariadb_cnf_section.value
|
ansible.builtin.dict2items
}}"
loop_control
:
loop_var
:
mariadb_cnf_variable_pair
label
:
"
{{
mariadb_cnf_variable_pair.key
}}
=
{{
mariadb_cnf_variable_pair.value
}}"
tags
:
-
mariadb
-
mariadb_conf
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment