This repository was archived by the owner on Nov 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
alt version initial commit #15
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
43b5e1e
alt version initial commit
fitz123 8986cd9
remove .sql file
fitz123 2a8f03d
replace all mysql-client related tasks by ansible mysql modules tasks
fitz123 67a3b14
disable role by default
fitz123 57937c0
change default admin group mysql->root
fitz123 8882477
fixed package name for RHEL: python-mysqldb->MySQL-python
fitz123 dfc4c81
add 'mysql_user_home' variable and turn on role by default
fitz123 780c4af
install .my.cnf into 'mysql_user_home' location instead of hardcoded …
fitz123 9289dc8
make mysql_root_password as mandatory variable
fitz123 01bd7bc
make mysql_root_password mandatory variable and change owner/group pe…
fitz123 6542799
add warning about using default mysql_root_password
fitz123 f4e84e5
add comments into defaults
fitz123 8f1d970
run mysql_secure_installation always
fitz123 4e4b931
fix task name
fitz123 56fe739
README updated
fitz123 ef77bf7
delete spaces in variables ({{ item }} -> {{item}})
fitz123 ec90b8d
Update README with explaining of conditional enabling/disabling role
fitz123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DELETE FROM mysql.user WHERE User=''; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. everything here is copy-paste from old main.yml excluding last part with sql importing |
||
|
||
- name: protect my.cnf | ||
file: path='{{mysql_hardening_mysql_conf}}' mode=0600 owner=root group=root | ||
|
||
- name: ensure permissions on mysql-datadir are correct | ||
file: path='{{mysql_datadir}}' state=directory owner='{{mysql_hardening_user}}' group='{{mysql_hardening_user}}' | ||
|
||
- name: check mysql configuration-directory exists and has right permissions | ||
file: path='/etc/mysql/conf.d' state=directory owner='{{mysql_hardening_user}}' group='{{mysql_hardening_group}}' mode=0470 | ||
|
||
- name: check include-dir directive is present in my.cnf | ||
lineinfile: dest='{{mysql_hardening_mysql_conf}}' line='!includedir /etc/mysql/conf.d/' insertafter='EOF' state=present backup=yes | ||
notify: restart mysql | ||
|
||
- name: apply hardening configuration | ||
template: src='hardening.cnf.j2' dest='{{mysql_hardening_hardening_conf}}' owner='{{mysql_hardening_user}}' group='{{mysql_hardening_group}}' mode=0460 | ||
notify: restart mysql |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. everything here is a replacement for sql import |
||
|
||
# supported for ansible ver => 2.0 | ||
#- name: Install python-mysqldb for Ansible | ||
# package: pkg=python-mysqldb state=present | ||
|
||
|
||
- name: Install MySQL-python for Ansible | ||
apt: name=python-mysqldb state=present | ||
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' | ||
|
||
- name: Install python-mysqldb for Ansible | ||
yum: name=MySQL-python state=present | ||
when: ansible_os_family == 'RedHat' or ansible_os_family == 'Oracle Linux' | ||
|
||
- debug: msg="WARNING - you have to change default mysql_root_password" | ||
when: mysql_root_password == '-----====>SetR00tPa$$wordH3r3!!!<====-----' | ||
|
||
- name: root password is present | ||
mysql_user: name=root host={{item}} password={{mysql_root_password | mandatory}} state=present | ||
with_items: | ||
- '::1' | ||
- '127.0.0.1' | ||
- 'localhost' | ||
|
||
- name: install .my.cnf with credentials | ||
template: src=my.cnf.j2 dest={{mysql_user_home}}/.my.cnf | ||
mode=0400 | ||
tags: my_cnf | ||
|
||
- name: test database is absent | ||
mysql_db: name=test state=absent | ||
when: mysql_remove_test_database | ||
|
||
# Can use only if ansible ver => 2.1 | ||
#- name: anonymous users are absent | ||
# mysql_user: name='' state=absent host_all=yes | ||
# when: mysql_remove_anonymous_users | ||
|
||
- name: copy mysql_remove_anonymous_users | ||
copy: src='{{item}}.sql' dest='/tmp/{{item}}.sql' | ||
with_items: | ||
- mysql_remove_anonymous_users | ||
when: mysql_remove_anonymous_users | ||
changed_when: false | ||
|
||
- name: apply mysql_remove_anonymous_users | ||
mysql_db: name='mysql' state=import target='/tmp/{{item}}.sql' | ||
with_items: | ||
- mysql_remove_anonymous_users | ||
when: mysql_remove_anonymous_users | ||
changed_when: false | ||
|
||
- name: copy mysql_remove_remote_root | ||
copy: src='{{item}}.sql' dest='/tmp/{{item}}.sql' | ||
with_items: | ||
- mysql_remove_remote_root | ||
when: mysql_remove_remote_root | ||
changed_when: false | ||
|
||
- name: apply mysql_remove_remote_root | ||
mysql_db: name='mysql' state=import target='/tmp/{{item}}.sql' | ||
with_items: | ||
- mysql_remove_remote_root | ||
when: mysql_remove_remote_root | ||
changed_when: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[client] | ||
user=root | ||
password='{{ mysql_root_password | mandatory }}' | ||
#ssl |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm usually make ability to disable role but not exclude it from playbook. It's very useful, if you have a lot of different builds use one playbook
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, we should do this for os and ssh hardening, too!