|
| 1 | +# ansible-role-cis-amazon-linux-2 |
| 2 | +## Continued from https://github.com/anthcourtney/ansible-role-cis-amazon-linux but for Amazon Linux 2 |
| 3 | + |
| 4 | +Development |
| 5 | +------------- |
| 6 | +We are going to use "master" branch only for fully tested changes. |
| 7 | + |
| 8 | +**Going forward please send your pull requests to "build" branch.** |
| 9 | + |
| 10 | +We need more community support to make changes and most importantly to test and review changes. If you would like to participate, please send a note to [Anth](https://github.com/anthcourtney) or [Chandan](https://github.com/chandanchowdhury). |
| 11 | + |
| 12 | +The major work to be done are |
| 13 | +* CIS Benchmark v2.2.0 |
| 14 | +* Ansible 2.5 and above |
| 15 | +* Amazon Linux 2 LTS |
| 16 | + |
| 17 | +Introduction |
| 18 | +------------ |
| 19 | + |
| 20 | +This ansible role applies v2.0.0 of the CIS Amazon Linux Benchmark. <https://www.cisecurity.org/benchmark/amazon_linux/> |
| 21 | + |
| 22 | +This role was developed and tested against Amazon Linux 2. It has been tested against Amazon Linux 2 with equal success. |
| 23 | + |
| 24 | +Why Would I Use This Role? |
| 25 | +-------------------------- |
| 26 | + |
| 27 | +If you are attempting to obtain compliance against an industry-accepted security standard, like PCI DSS, APRA or ISO 27001, then you need to demonstrate that you have applied documented hardening standards against all systems within scope of assessment. |
| 28 | + |
| 29 | +If you are running Amazon Linux, then this role attempts to provide one piece of the solution to the compliance puzzle. |
| 30 | + |
| 31 | +Here Be Dragons! |
| 32 | +---------------- |
| 33 | + |
| 34 | +If you are considering applying this role to any servers, you should have a basic familiarity with the CIS Benchmark (or other similar benchmarks) and an appreciation for the impact that it may have on a system. |
| 35 | + |
| 36 | +Please take the time to familarise yourself with the standard and with the configurable default values, and exclude any items before applying to a system. |
| 37 | + |
| 38 | +An examples of items that should be immediately considered for exclusion (or at least, for modification of the related default values) include: |
| 39 | + |
| 40 | +* ```3.3.2``` and ```3.3.3```, which by default effectively limit access to the host (including via ssh) to localhost only. |
| 41 | + |
| 42 | + |
| 43 | +Example Playbook |
| 44 | +---------------- |
| 45 | + |
| 46 | +An example playbook which uses this role is as follows: |
| 47 | + |
| 48 | +``` |
| 49 | +--- |
| 50 | +
|
| 51 | +- hosts: localhost |
| 52 | + connection: local |
| 53 | + gather_facts: true |
| 54 | + become: yes |
| 55 | +
|
| 56 | + roles: |
| 57 | + - ansible-role-cis-amazon-linux-2.cis-amazon-linux |
| 58 | +``` |
| 59 | + |
| 60 | +A more advanced example, which includes modifications to the default values used, as well as the exclusion of some items in the benchmark which are considered unnecessary for a fictional environment, is as follows: |
| 61 | + |
| 62 | +``` |
| 63 | +--- |
| 64 | +
|
| 65 | +- hosts: localhost |
| 66 | + connection: local |
| 67 | + gather_facts: true |
| 68 | + become: yes |
| 69 | +
|
| 70 | + vars: |
| 71 | + ntp_servers: |
| 72 | + - 0.amazon.pool.ntp.org |
| 73 | + - 1.amazon.pool.ntp.org |
| 74 | + - 2.amazon.pool.ntp.org |
| 75 | + - 3.amazon.pool.ntp.org |
| 76 | + cis_level_1_exclusions: |
| 77 | + # Allows packer scripts to build by enabling /tmp |
| 78 | + - 1.1.2 |
| 79 | + - 1.1.3 |
| 80 | + - 1.1.4 |
| 81 | + - 1.1.5 |
| 82 | + # Autofs is no longer installed and we need to ignore it or else will fail |
| 83 | + - 1.1.19 |
| 84 | + # Using Chronyd instead of NTP |
| 85 | + - 2.1.1.2 |
| 86 | + # Using Samba |
| 87 | + - 2.1.12 |
| 88 | + # LDAP |
| 89 | + - 2.2.5 |
| 90 | + # Firewall rules and locks us out at a point |
| 91 | + - 3.1.1 |
| 92 | + - 3.3.2 |
| 93 | + - 3.3.3 |
| 94 | + - 3.5.1.1 |
| 95 | + - 3.5.1.4 |
| 96 | + - 3.5.2.1 |
| 97 | + # Disable remote logging |
| 98 | + - 4.2.1.4 |
| 99 | + # Disabled SU group restriction |
| 100 | + - 5.5 |
| 101 | + cis_level_2_exclusions: |
| 102 | + - 6.1.1 |
| 103 | + cis_pass_max_days: 45 |
| 104 | + cis_umask_default: 002 |
| 105 | +
|
| 106 | + roles: |
| 107 | + - ansible-role-cis-amazon-linux-2.cis-amazon-linux |
| 108 | +
|
| 109 | +``` |
| 110 | + |
| 111 | +Note that the use of ```become: yes``` is required as 99% of tasks require privileged access to execute. |
| 112 | + |
| 113 | +Role Variables |
| 114 | +-------------- |
| 115 | + |
| 116 | +See ```defaults/main.yml``` for variables which can be overriden according to preference. |
| 117 | + |
| 118 | +Options |
| 119 | +------- |
| 120 | + |
| 121 | +Tags (and combinations thereof) can be used to run a particular level of the CIS standard, a section, or an individual recommendation. For example: |
| 122 | + |
| 123 | +* Run only Level 1 tasks |
| 124 | + |
| 125 | +``` |
| 126 | +ansible-playbook playbook.yml -t level-1 |
| 127 | +``` |
| 128 | + |
| 129 | +* Run only Section 3 tasks |
| 130 | + |
| 131 | +``` |
| 132 | +ansible-playbook playbook.yml -t section-3 |
| 133 | +``` |
| 134 | + |
| 135 | +* Run tasks 1.3.1 and 2.2.10 only |
| 136 | + |
| 137 | +``` |
| 138 | +ansible-playbook playbook.yml -t 1.3.1,2.2.10 |
| 139 | +``` |
| 140 | + |
| 141 | +* Run scored tasks only |
| 142 | + |
| 143 | +``` |
| 144 | +ansible-playbook playbook.yml -t scored |
| 145 | +``` |
| 146 | + |
| 147 | +Limitations |
| 148 | +----------- |
| 149 | + |
| 150 | +At present, only the Level 1 items of the benchmark are implemented. Level 2 items will be added as time permits. |
| 151 | + |
| 152 | +The following checks have not been implemented: |
| 153 | + |
| 154 | +* 3.6.2. Firewall rulesets are environment specific. |
| 155 | +* 3.6.3. Firewall rulesets are environment specific. |
| 156 | +* 3.6.4. Firewall rulesets are environment specific. |
| 157 | +* 3.6.5. Firewall rulesets are environment specific. |
| 158 | +* 4.2.1.3. Inline editing of rsyslog configuration file is considered too imprecise and is best solved by a supplied configuration file which addresses this and other related requirements. |
| 159 | +* 4.2.1.4. Inline editing of rsyslog configuration file is considered too imprecise and is best solved by a supplied configuration file which addresses this and other related requirements. |
| 160 | +* 4.2.1.5. Inline editing of rsyslog configuration file is considered too imprecise and is best solved by a supplied configuration file which addresses this and other related requirements. |
| 161 | +* 4.3. The configuration of logrotate is site-specific. |
| 162 | + |
| 163 | +Compatibility |
| 164 | +------------- |
| 165 | + |
| 166 | +This role is compatible with the following versions of ansible: |
| 167 | + |
| 168 | +* 2.3 |
| 169 | +* 2.4 |
| 170 | +* 2.5 |
| 171 | +* 2.6 |
| 172 | +* 2.7 |
| 173 | + |
| 174 | +This role has not been tested against any other versions of ansible. |
| 175 | + |
| 176 | +Testing |
| 177 | +------- |
| 178 | + |
| 179 | +The following testing processes are applied by the developer of this role: |
| 180 | + |
| 181 | +* The syntax of the role is checked. See ```make syntax```. |
| 182 | +* ```ansible-review``` is run against the role and any warnings which are deemed appropriate are remediated. See ```make review```. |
| 183 | +* The role is applied against a docker container using both ansible v2.1.3 and ansible v2.2. see ```make test```. |
| 184 | + |
| 185 | +The following tests have been flagged but are not yet implemented: |
| 186 | + |
| 187 | +* Test application of the role against the Vagrant ```mvbcoding/awslinux``` image, using the ansible provisioner. |
| 188 | + |
| 189 | +Author Information |
| 190 | +------------------ |
| 191 | + |
| 192 | +This role was developed from [Anth Courtney](https://au.linkedin.com/in/anthcourtney) original github publication. |
| 193 | + |
| 194 | +All feedback, issues and PRs are encouraged and appreciated. |
0 commit comments