-
Notifications
You must be signed in to change notification settings - Fork 741
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* linting Signed-off-by: Sebastian Gumprich <[email protected]> * more linting Signed-off-by: Sebastian Gumprich <[email protected]> * change line length issues Signed-off-by: Sebastian Gumprich <[email protected]> * replace yes with true in tasks Signed-off-by: Sebastian Gumprich <[email protected]> * use manual line-wrapping because ansible-lint does not support it correctly. see ansible/ansible-lint#2522 * use manual line-wrapping because ansible-lint does not support it correctly. see ansible/ansible-lint#2522 Signed-off-by: Sebastian Gumprich <[email protected]> * use manual line-wrapping because ansible-lint does not support it correctly. see ansible/ansible-lint#2522 Signed-off-by: Sebastian Gumprich <[email protected]> * add exception for task Signed-off-by: Sebastian Gumprich <[email protected]> * remove trailing whitespace * add back deleted params Signed-off-by: Sebastian Gumprich <[email protected]> * add back deleted params Signed-off-by: Sebastian Gumprich <[email protected]> * add back tasks Signed-off-by: Sebastian Gumprich <[email protected]>
- Loading branch information
Showing
74 changed files
with
1,095 additions
and
1,029 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,13 +1,14 @@ | ||
--- | ||
namespace: devsec | ||
name: hardening | ||
version: 8.4.0 | ||
readme: README.md | ||
authors: | ||
- dev-sec <[email protected]> | ||
description: 'This collection provides battle tested hardening for Linux, SSH, nginx, MySQL' | ||
description: This collection provides battle tested hardening for Linux, SSH, nginx, MySQL | ||
license: | ||
- Apache-2.0 | ||
license_file: '' | ||
license_file: "" | ||
tags: | ||
- devsec | ||
- hardening | ||
|
@@ -23,13 +24,13 @@ tags: | |
- os_hardening | ||
- ssh_hardening | ||
dependencies: | ||
ansible.posix: '>=1.0.0' | ||
community.crypto: '>=1.0.0' | ||
community.general: '>=1.0.0' | ||
community.mysql: '>=1.3.0' | ||
repository: 'https://github.com/dev-sec/ansible-collection-hardening/' | ||
homepage: 'https://dev-sec.io/' | ||
issues: 'https://github.com/dev-sec/ansible-collection-hardening/issues' | ||
ansible.posix: ">=1.0.0" | ||
community.crypto: ">=1.0.0" | ||
community.general: ">=1.0.0" | ||
community.mysql: ">=1.3.0" | ||
repository: https://github.com/dev-sec/ansible-collection-hardening/ | ||
homepage: https://dev-sec.io/ | ||
issues: https://github.com/dev-sec/ansible-collection-hardening/issues | ||
build_ignore: | ||
- codecov.yml | ||
- .github | ||
|
This file contains 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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
requires_ansible: '>=2.9.10' | ||
requires_ansible: ">=2.9.10" |
This file contains 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 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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
--- | ||
|
||
- name: Restart mysql | ||
service: | ||
name: '{{ mysql_daemon }}' | ||
ansible.builtin.service: | ||
name: "{{ mysql_daemon }}" | ||
state: restarted | ||
when: mysql_hardening_restart_mysql | bool |
This file contains 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 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 |
---|---|---|
@@ -1,64 +1,64 @@ | ||
--- | ||
- name: Protect my.cnf | ||
file: | ||
path: '{{ mysql_hardening_mysql_conf_file }}' | ||
mode: '0640' | ||
owner: '{{ mysql_cnf_owner }}' | ||
group: '{{ mysql_cnf_group }}' | ||
ansible.builtin.file: | ||
path: "{{ mysql_hardening_mysql_conf_file }}" | ||
mode: "0640" | ||
owner: "{{ mysql_cnf_owner }}" | ||
group: "{{ mysql_cnf_group }}" | ||
follow: true | ||
state: file | ||
|
||
- name: Ensure permissions on mysql-datadir are correct | ||
file: | ||
path: '{{ item }}' | ||
ansible.builtin.file: | ||
path: "{{ item }}" | ||
state: directory | ||
owner: '{{ mysql_hardening_user }}' | ||
group: '{{ mysql_hardening_user }}' | ||
mode: '0750' | ||
owner: "{{ mysql_hardening_user }}" | ||
group: "{{ mysql_hardening_user }}" | ||
mode: "0750" | ||
when: item is defined and item != "" | ||
loop: | ||
- '{{ mysql_settings.settings.datadir }}' | ||
- "{{ mysql_settings.settings.datadir }}" | ||
- '{{ mysql_datadir | default("") }}' | ||
|
||
- name: Ensure permissions on mysql-logfile are correct | ||
file: | ||
path: '{{ item }}' | ||
ansible.builtin.file: | ||
path: "{{ item }}" | ||
state: file | ||
owner: '{{ mysql_hardening_user }}' | ||
group: '{{ mysql_hardening_group }}' | ||
mode: '0640' | ||
owner: "{{ mysql_hardening_user }}" | ||
group: "{{ mysql_hardening_group }}" | ||
mode: "0640" | ||
when: item is defined and item != "" | ||
loop: | ||
- '{{ mysql_settings.settings.log_error }}' | ||
- "{{ mysql_settings.settings.log_error }}" | ||
- '{{ mysql_hardening_log_file | default("") }}' | ||
|
||
- name: Check mysql configuration-directory exists and has right permissions | ||
file: | ||
path: '{{ mysql_hardening_mysql_confd_dir }}' | ||
ansible.builtin.file: | ||
path: "{{ mysql_hardening_mysql_confd_dir }}" | ||
state: directory | ||
owner: '{{ mysql_hardening_user }}' | ||
group: '{{ mysql_hardening_group }}' | ||
mode: '0750' | ||
owner: "{{ mysql_hardening_user }}" | ||
group: "{{ mysql_hardening_group }}" | ||
mode: "0750" | ||
|
||
- name: Check include-dir directive is present in my.cnf | ||
lineinfile: | ||
dest: '{{ mysql_hardening_mysql_conf_file }}' | ||
line: '!includedir {{ mysql_hardening_mysql_confd_dir }}' | ||
insertafter: 'EOF' | ||
ansible.builtin.lineinfile: | ||
dest: "{{ mysql_hardening_mysql_conf_file }}" | ||
line: "!includedir {{ mysql_hardening_mysql_confd_dir }}" | ||
insertafter: EOF | ||
state: present | ||
backup: true | ||
notify: Restart mysql | ||
|
||
- name: Apply hardening configuration | ||
template: | ||
src: 'hardening.cnf.j2' | ||
dest: '{{ mysql_hardening_mysql_hardening_conf_file }}' | ||
owner: '{{ mysql_cnf_owner }}' | ||
group: '{{ mysql_cnf_group }}' | ||
mode: '0640' | ||
ansible.builtin.template: | ||
src: hardening.cnf.j2 | ||
dest: "{{ mysql_hardening_mysql_hardening_conf_file }}" | ||
owner: "{{ mysql_cnf_owner }}" | ||
group: "{{ mysql_cnf_group }}" | ||
mode: "0640" | ||
notify: Restart mysql | ||
|
||
- name: Enable mysql | ||
service: | ||
name: '{{ mysql_daemon }}' | ||
enabled: '{{ mysql_daemon_enabled }}' | ||
ansible.builtin.service: | ||
name: "{{ mysql_daemon }}" | ||
enabled: "{{ mysql_daemon_enabled }}" |
This file contains 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
Oops, something went wrong.