• This repository has been archived on 17/Nov/2020
  • Stars
    star
    140
  • Rank 254,299 (Top 6 %)
  • Language
    Ruby
  • Created almost 9 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This Ansible role provides security configuration for MySQL.

mysql-hardening (Ansible role)

Attention: This role has been migrated to our hardening-collection:

Requirements

  • Ansible
  • Set up mysql_root_password variable

Installation

Install the role with ansible-galaxy:

ansible-galaxy install dev-sec.mysql-hardening

Example Playbook

- hosts: localhost
  roles:
    - dev-sec.mysql-hardening

This hardening role installs the hardening but expects an existing installation of MySQL, MariaDB or Percona. Please ensure that the following variables are set accordingly:

  • mysql_hardening_enabled: yes role is enabled by default and can be disabled without removing it from a playbook. You can use conditional variable, for example: mysql_hardening_enabled: "{{ true if mysql_enabled else false }}"
  • mysql_hardening_user: 'mysql' The user that mysql runs as.
  • mysql_datadir: '/var/lib/mysql' The MySQL data directory
  • mysql_hardening_mysql_hardening_conf_file: '/etc/mysql/conf.d/hardening.cnf' The path to the configuration file where the hardening will be performed

Role Variables

  • mysql_hardening_chroot
    • Default: ""
    • Description: chroot
  • mysql_hardening_options.safe-user-create
  • mysql_hardening_options.secure-auth
  • mysql_hardening_options.skip-symbolic-links
  • mysql_hardening_skip_grant_tables:
  • mysql_hardening_skip_show_database
  • mysql_hardening_options.local-infile
  • mysql_hardening_options.allow-suspicious-udfs
  • mysql_hardening_chroot.automatic-sp-privileges
  • mysql_hardening_options.secure-file-priv
  • mysql_allow_remote_root
    • Default: false
    • Description: delete remote root users
  • mysql_remove_anonymous_users
    • Default: true
    • Description: remove users without authentication
  • mysql_remove_test_database
    • Default: true
    • Description: remove test database

Further information is available at Deutsche Telekom (German) and Symantec

Local Testing

The preferred way of locally testing the role is to use Docker. You will have to install Docker on your system. See Get started for a Docker package suitable to for your system.

You can also use vagrant and Virtualbox or VMWare to run tests locally. You will have to install Virtualbox and Vagrant on your system. See Vagrant Downloads for a vagrant package suitable for your system. For all our tests we use test-kitchen. If you are not familiar with test-kitchen please have a look at their guide.

Next install test-kitchen:

# Install dependencies
gem install bundler
bundle install

Testing with Docker

# list all available machines
bundle exec kitchen list

# fast test on one machine
bundle exec kitchen test mysql-centos7-ansible-latest

# test on all machines
bundle exec kitchen test

# for development
bundle exec kitchen create mysql-centos7-ansible-latest
bundle exec kitchen converge mysql-centos7-ansible-latest

Testing with Virtualbox

# fast test on one machine
KITCHEN_YAML=".kitchen.vagrant.yml" bundle exec kitchen test default-ubuntu-1404

# test on all machines
KITCHEN_YAML=".kitchen.vagrant.yml" bundle exec kitchen test

# for development
KITCHEN_YAML=".kitchen.vagrant.yml" bundle exec kitchen create default-ubuntu-1404
KITCHEN_YAML=".kitchen.vagrant.yml" bundle exec kitchen converge default-ubuntu-1404

For more information see test-kitchen

License and Author

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

ansible-collection-hardening

This Ansible collection provides battle tested hardening for Linux, SSH, nginx, MySQL
Jinja
3,615
star
2

ansible-ssh-hardening

This Ansible role provides numerous security-related ssh configurations, providing all-round base protection.
HTML
772
star
3

linux-baseline

DevSec Linux Baseline - InSpec Profile
Ruby
753
star
4

cis-docker-benchmark

CIS Docker Benchmark - InSpec Profile
Ruby
469
star
5

chef-os-hardening

This chef cookbook provides numerous security-related configurations, providing all-round base protection.
Ruby
430
star
6

hardening

DevSec Examples
Ruby
313
star
7

cis-kubernetes-benchmark

CIS Kubernetes Benchmark - InSpec Profile
Ruby
289
star
8

ssh-baseline

DevSec SSH Baseline - InSpec Profile
Ruby
274
star
9

puppet-os-hardening

This puppet module provides numerous security-related configurations, providing all-round base protection.
Puppet
272
star
10

windows-baseline

DevSec Windows Baseline - InSpec Profile
Ruby
214
star
11

ansible-nginx-hardening

This Ansible role provides secure nginx configurations.
Ruby
187
star
12

chef-ssh-hardening

This chef cookbook provides secure ssh-client and ssh-server configurations.
Ruby
156
star
13

ansible-windows-hardening

This Ansible role provides windows hardening configurations for the DevSec Windows baseline profile.
Ruby
145
star
14

cis-dil-benchmark

CIS Distribution Independent Linux Benchmark - InSpec Profile
Ruby
142
star
15

nginx-baseline

DevSec Nginx Baseline - InSpec Profile
Ruby
103
star
16

chef-windows-hardening

This chef cookbook provides windows hardening configurations for the DevSec Windows baseline profile.
Ruby
95
star
17

linux-patch-baseline

DevSec Linux Patch Baseline - InSpec Profile
Ruby
83
star
18

ssl-baseline

DevSec SSL/TLS Baseline - InSpec Profile
Ruby
66
star
19

puppet-ssh-hardening

This puppet module provides secure ssh-client and ssh-server configurations.
Ruby
59
star
20

mysql-baseline

DevSec MySQL Baseline - InSpec Profile
Ruby
58
star
21

chef-nginx-hardening

This chef cookbook provides secure nginx configurations.
Ruby
50
star
22

postgres-baseline

DevSec PostgreSQL Baseline - InSpec Profile
Ruby
48
star
23

windows-patch-baseline

DevSec Windows Patch Baseline - InSpec Profile
Ruby
47
star
24

apache-baseline

DevSec Apache Baseline - InSpec Profile
Ruby
38
star
25

ansible-apache-hardening

HTML
36
star
26

example-puppet-hardening

β›” DEPRECATED
Dockerfile
34
star
27

chef-postgres-hardening

This chef cookbook provides security configuration for PostgreSQL.
Ruby
27
star
28

chef-mysql-hardening

This chef cookbook provides security configuration for mysql.
Ruby
26
star
29

php-baseline

DevSec PHP baseline - InSpec Profile
Ruby
25
star
30

chef-apache-hardening

Ruby
25
star
31

puppet-nginx-hardening

Nginx Web Server Hardening with Puppet
Puppet
23
star
32

docker-ansible

Docker containers that include ansible latest stable 2.x version.
Dockerfile
21
star
33

openstack-baseline

Use InSpec to run through the configurations from the OpenStack Security Guide.
Ruby
18
star
34

puppet-mysql-hardening

MySql Server Hardening with Puppet
Puppet
18
star
35

dev-sec.github.io

project website
SCSS
18
star
36

chef-jenkins-hardening

β›” DEPRECATED: A secure jenkins installation
Ruby
17
star
37

puppet-apache-hardening

Apache Web Server Hardening with Puppet
HTML
15
star
38

docs

β›” DEPRECATED, migrated to dev-sec/dev-sec.github.io
12
star
39

puppet-postgres-hardening

Postgres Web Server Hardening with Puppet
Puppet
10
star
40

patcher

β›” DEPRECATED: CLI to extract patches from InSpec report
Ruby
7
star
41

blog

β›” DEPRECATED, migrated to dev-sec/dev-sec.github.io
HTML
6
star
42

puppet-hardening-stdlib

Shared functions for puppet hardening.
Ruby
4
star
43

chef-percona-hardening

β›” DEPRECATED: Security Configuration for Percona
Ruby
4
star
44

chef-linux-patch

β›” DEPRECATED: Update Linux packages according to InSpec linux-patch-baseline output
Ruby
4
star
45

cnspec-collection-baselines

DevSec Security Baselines provide battle tested hardening checks for Linux, SSH, nginx, MySQL in cnspec
4
star
46

git-contributors

Get contributors of your git repos.
Ruby
3
star
47

pam-tester

Python
3
star
48

.github

1
star