File tree Expand file tree Collapse file tree 5 files changed +63
-2
lines changed
.templates/inventory/group_vars Expand file tree Collapse file tree 5 files changed +63
-2
lines changed Original file line number Diff line number Diff line change @@ -94,3 +94,20 @@ tasks:
94
94
export EDITOR=${TEXT_EDITOR};
95
95
ansible-vault edit "${inventory_path}"
96
96
cd inventory && git add host_vars/${ARG_HOST}.yaml
97
+
98
+ :node:edit:all-hosts-defaults-config :
99
+ description : Edit a file that contains common values for all hosts
100
+ steps : |
101
+ inventory_path=./inventory/group_vars/all.yaml
102
+ export EDITOR=${TEXT_EDITOR};
103
+
104
+ if [[ ! -f "${inventory_path}" ]]; then
105
+ %RKD% :node:copy-host-defaults
106
+ fi
107
+
108
+ if [[ "$(cat $inventory_path)" == *"ANSIBLE_VAULT"* ]]; then
109
+ ansible-vault edit "${inventory_path}"
110
+ exit 0
111
+ fi
112
+
113
+ ${EDITOR} "${inventory_path}"
Original file line number Diff line number Diff line change @@ -144,6 +144,21 @@ default_role_logs:
144
144
systemd_max_file_sec : 1month
145
145
146
146
147
+ # https://github.com/Oefenweb/ansible-fail2ban
148
+ default_role_fail2ban :
149
+ fail2ban_dbpurgeage : 86400
150
+ fail2ban_loglevel : " INFO"
151
+ fail2ban_logtarget : " SYSLOG"
152
+ fail2ban_syslog_target : " /var/log/fail2ban.log"
153
+ fail2ban_ignoreips : [127.0.0.1/8]
154
+ fail2ban_bantime : 600
155
+ fail2ban_maxretry : 6
156
+ fail2ban_services :
157
+ - name : sshd
158
+ port : " {{ ansible_ssh_port }}"
159
+ maxretry : 6
160
+ bantime : 600
161
+
147
162
default_role_system_settings :
148
163
timezone : Europe/Rome
149
164
locale : " en_GB.UTF-8"
Original file line number Diff line number Diff line change @@ -107,15 +107,32 @@ With this combination you can divide access to multiple admins handling administ
107
107
nano .env
108
108
```
109
109
110
- Editing inventory per host
111
- --------------------------
110
+ Editing configuration per host and disabling/enabling roles
111
+ -----------------------------------------------------------
112
112
113
113
This command will automatically encrypt existing and new file using AES-256 with Ansible Vault.
114
114
115
+ ** Please note: All values there are overriding ` group_vars/all.yaml ` default values for edited host**
116
+
117
+ ** To disable a role - remove or comment out it's section eg. ` role_fail2ban ` **
118
+
119
+ ** To enable a role without overriding any values (inheriting all defaults) just add empty section eg. ` role_fail2ban: {} ` **
120
+
115
121
``` bash
116
122
rkd :edit:host-config my-host.org
117
123
```
118
124
125
+ Setting default values for ALL hosts in inventory (hosts will inherit those values by default)
126
+ ----------------------------------------------------------------------------------------------
127
+
128
+ When a host does not override given value, then it is inherited from global defaults.
129
+
130
+ * Note: This file you can also encrypt and below command will support encrypted edits*
131
+
132
+ ``` bash
133
+ rkd :edit:all-hosts-defaults-config
134
+ ```
135
+
119
136
Deploying
120
137
---------
121
138
Original file line number Diff line number Diff line change 88
88
89
89
- include_role : name=infrastructure-ansible-logs
90
90
tags : logs
91
+
92
+ - name : Fail2ban role
93
+ when : role_fail2ban is defined
94
+ block :
95
+ - name : Include required vars
96
+ set_fact :
97
+ args : " {{ default_role_fail2ban | combine(role_fail2ban | default({}), recursive=True) }}"
98
+
99
+ - include_role : name=oefenweb.fail2ban
100
+ tags : fail2ban
Original file line number Diff line number Diff line change 6
6
- src : blackandred.server_basic_security
7
7
- src : git+https://github.com/riotkit-org/infrastructure-ansible-tweak-os
8
8
- src : blackandred.server_secure_storage
9
+ - src : oefenweb.fail2ban
10
+ version : v3.3.14
You can’t perform that action at this time.
0 commit comments