-
Notifications
You must be signed in to change notification settings - Fork 29
Conversation
mysql_datadir: '/var/lib/mysql' | ||
mysql_hardening_hardening_conf: '/etc/mysql/conf.d/hardening.cnf' | ||
mysql_root_password: "{{ lookup('env','mysql_root_password') }}" |
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 not sure about it, but don't know more secure way to pass values like that
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.
We could use a separate variables-file that only contains the password and encrypt this file with vault. Or something along these lines.
Checks are failed because of "python-mysqldb" package installation and probably because of requirement of env variable |
@@ -0,0 +1,18 @@ | |||
--- |
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.
everything here is copy-paste from old main.yml excluding last part with sql importing
Thanks for these improvements. I'll test them locally this weekend and see if anything fails. |
I've tested it on one on my mariadb instances and at first view - it looks fine. Gonna test on galera cluster soon and fix if something will fail. So basically "mysql_secure_installation.yml" I've been used quite a long time already and never had issues with it, but "mysql_hardening_options" dict includes a lot of variables I've never used and not sure how it can affect servers, so gonna test them as well, but slowly |
And it'd be great if you can find a way to fix travis checks) |
The problem is that the package-module is only supported from ansible 2.0 on. So we're going to have to stick to yum and apt tasks for now. See here: https://github.com/dev-sec/ansible-os-hardening/blob/master/tasks/pam.yml#L9-L15 on how to do it. |
@@ -1,4 +1,4 @@ | |||
mysql_hardening_enabled: yes | |||
mysql_hardening_enabled: no |
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 think disabling the role by default is counter-intuitive.
If I would use this role, I'd expect that it would work out-of-the-box (like os and ssh hardening), not that I should still have to activate it. Because that's already what I'm doing when I'm including this role into one of my playbooks.
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.
Up to you, but usually roles are deactivated by default to not accidentally fail builds. For os and ssh that's different, probably because you can successfully execute it on almost build, but mysql have to be executed on mysql-enabled instances only. My use case: I'm using 1 playbook for almost everything, and having group-specific variables that control which roles are enabled (except roles like os/ssh-hardening which can be safelly enabled for all (at least my) instances, so they're enabled by default, though it's an exclusion). We can do the opposite, if you still want. though I think it's better not to leave it disabled and force user to manually activate it
I don't understand the distinction between configure.yml and mysql_secure_installation.yml. Why are these both separated? And why does mysql_secure_installation.yml only runs, when |
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' | ||
|
||
- name: Install python-mysqldb for Ansible | ||
yum: name=python-mysqldb state=present |
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.
for rhel that's MySQL-python
.
I tested the role successfully on a fresh centos 6.5 system and it works great! |
I'll update the travis file, too, because right now there isn't much testing going on at all. |
Could you also test on ubuntu, as far as I know for apt module to work "python-apt" package is required. I have it installed in all templates since I start using ansible, so not super easy to test) |
I separated them mostly logically/functionally, configure.yml responses for configuration hardening, and mysql_secure_installation.yml almost copies mysql-secure-installation script's functionality (https://dev.mysql.com/doc/refman/5.7/en/mysql-secure-installation.html)
It does (at least I guess it's) opposite, it doesn't run if you didn't pass root password as a parameter, because mysql_db module have to have credentials for "import" to work, ether passed as parameters or in .my.cnf. |
@@ -1,10 +1,13 @@ | |||
mysql_hardening_enabled: no |
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.
We should set this to "yes", because my expectation is that a role just works when I include it into my playbook. Also I've never seen another role you have to "enable" with an additional variable.
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.
done
Yes and we should force this, because if no password is set, than you have a huge gaping security hole, no matter if the installation is secured otherwise. What I'd like to see:
|
@rndmh3ro, I can change behaviour to ether:
|
…rmissions for users .my.cnf
any other comments? |
Everything's fine now! |
So I tested the role:
There is a minor issue with RedHat that I will fix after merging this. |
No description provided.