Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5d6d402612 | |||
| 9c9861f74e | |||
| 05f415d727 | |||
| 8109fcd18b | |||
| f5b4a493fd | |||
| 15fc072b76 | |||
| 2f1623b853 | |||
| b7c75f18f2 | |||
| 8f76a7fa4f | |||
| f2fe66668d | |||
| cfd846f787 | |||
| 37ba58e8c2 | |||
| 3732b74306 | |||
| be58aa437c | |||
| ad406e1b86 | |||
| 7ac6c74574 | |||
| 63ed305852 | |||
| 5199567bda | |||
| 46089e1d7a | |||
| 0999da5ac5 | |||
| ce565ecd44 | |||
| c6ce82732c | |||
| f03a3c03b8 |
@@ -22,12 +22,12 @@ jobs:
|
|||||||
# - uses: actions/gitea-upload-artifact@v3
|
# - uses: actions/gitea-upload-artifact@v3
|
||||||
# with:
|
# with:
|
||||||
# path: /workspace/itik/bgwaf/seb4itik/byow/seb4itik-byow-0.1.2.tar.gz
|
# path: /workspace/itik/bgwaf/seb4itik/byow/seb4itik-byow-0.1.2.tar.gz
|
||||||
- name: Push artifacts
|
# - name: Push artifacts
|
||||||
run: |
|
# run: |
|
||||||
GITEA_REPO_OWNER=$(echo $GITEA_REPOSITORY | cut -d"/" -f1) && \
|
# GITEA_REPO_OWNER=$(echo $GITEA_REPOSITORY | cut -d"/" -f1) && \
|
||||||
GITEA_REPO_NAME=$(echo $GITEA_REPOSITORY | cut -d"/" -f2) && \
|
# GITEA_REPO_NAME=$(echo $GITEA_REPOSITORY | cut -d"/" -f2) && \
|
||||||
curl \
|
# curl \
|
||||||
-X PUT \
|
# -X PUT \
|
||||||
-H "Authorization: token ${{ secrets.CI_GITEA_PACKAGES_TOKEN }}" \
|
# -H "Authorization: token ${{ secrets.CI_GITEA_PACKAGES_TOKEN }}" \
|
||||||
--upload-file seb4itik-byow-${VER}.tar.gz \
|
# --upload-file seb4itik-byow-${VER}.tar.gz \
|
||||||
$GITEA_SERVER_URL/api/packages/${GITEA_REPO_OWNER}/generic/${GITEA_REPO_NAME}/${GITEA_SHA}/seb4itik-byow-${VER}.tar.gz
|
# $GITEA_SERVER_URL/api/packages/${GITEA_REPO_OWNER}/generic/${GITEA_REPO_NAME}/${GITEA_SHA}/seb4itik-byow-${VER}.tar.gz
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,4 +1,4 @@
|
|||||||
/notes/
|
notes/
|
||||||
.ansible/
|
.ansible/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
infra-*/
|
infra-*/
|
||||||
|
|||||||
1
example/ansible/.gitignore
vendored
1
example/ansible/.gitignore
vendored
@@ -1,4 +1,3 @@
|
|||||||
/ca/
|
/ca/
|
||||||
/.vault_pass
|
/.vault_pass
|
||||||
/ansible_local.env
|
/ansible_local.env
|
||||||
/known_hosts
|
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ vault_password_file = ./.vault_pass
|
|||||||
|
|
||||||
[ssh_connection]
|
[ssh_connection]
|
||||||
pipelining = True
|
pipelining = True
|
||||||
ssh_args = -o ControlMaster=auto -o ControlPersist=300s -o StrictHostKeyChecking=no -o UserKnownHostsFile=./known_hosts
|
ssh_args = -o ControlMaster=auto -o ControlPersist=300s -o StrictHostKeyChecking=no
|
||||||
|
|||||||
@@ -2,6 +2,25 @@ linux:
|
|||||||
vars:
|
vars:
|
||||||
ansible_user: "root"
|
ansible_user: "root"
|
||||||
|
|
||||||
|
debian13:
|
||||||
|
hosts:
|
||||||
|
bdd1:
|
||||||
|
nfs1:
|
||||||
|
waf1:
|
||||||
|
# waf2:
|
||||||
|
# waf3:
|
||||||
|
www1:
|
||||||
|
www2:
|
||||||
|
www3:
|
||||||
|
# www4:
|
||||||
|
# www5:
|
||||||
|
vars:
|
||||||
|
ansible_python_interpreter: "/usr/bin/python3.13"
|
||||||
|
|
||||||
|
ubuntu2204lts:
|
||||||
|
vars:
|
||||||
|
ansible_python_interpreter: "/usr/bin/python3.10"
|
||||||
|
|
||||||
ubuntu2404lts:
|
ubuntu2404lts:
|
||||||
vars:
|
vars:
|
||||||
ansible_python_interpreter: "/usr/bin/python3.12"
|
ansible_python_interpreter: "/usr/bin/python3.12"
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
- "IP:{{ ansible_default_ipv4.address }}"
|
- "IP:{{ ansible_default_ipv4.address }}"
|
||||||
caddy_config_only: true
|
caddy_config_only: true
|
||||||
caddy_consul: true
|
caddy_consul: true
|
||||||
caddy_consul: true
|
|
||||||
caddy_consul_delegate_to: "waf1"
|
caddy_consul_delegate_to: "waf1"
|
||||||
caddy_consul_admin_token: "{{ secrets.consul.bootstrap_secret }}"
|
caddy_consul_admin_token: "{{ secrets.consul.bootstrap_secret }}"
|
||||||
caddy_consul_aes_key: "{{ secrets.caddy.storage_consul_aes_key }}"
|
caddy_consul_aes_key: "{{ secrets.caddy.storage_consul_aes_key }}"
|
||||||
|
|||||||
@@ -4,8 +4,10 @@
|
|||||||
- "vars/common.yml"
|
- "vars/common.yml"
|
||||||
- "vars/secrets.yml"
|
- "vars/secrets.yml"
|
||||||
vars:
|
vars:
|
||||||
caddy_debug: true
|
|
||||||
caddy_config_only: true
|
caddy_config_only: true
|
||||||
|
caddy_log_debug: true
|
||||||
|
caddy_crowdsec: true
|
||||||
|
caddy_crowdsec_api_key: "{{ secrets.crowdsec.lapi_key }}"
|
||||||
caddy_consul: true
|
caddy_consul: true
|
||||||
caddy_consul_delegate_to: "waf1"
|
caddy_consul_delegate_to: "waf1"
|
||||||
caddy_consul_admin_token: "{{ secrets.consul.bootstrap_secret }}"
|
caddy_consul_admin_token: "{{ secrets.consul.bootstrap_secret }}"
|
||||||
|
|||||||
@@ -45,7 +45,9 @@
|
|||||||
- "vars/common.yml"
|
- "vars/common.yml"
|
||||||
- "vars/secrets.yml"
|
- "vars/secrets.yml"
|
||||||
vars:
|
vars:
|
||||||
common_proxy_server: "{{ hostvars['proxy1'].ansible_default_ipv4.address }}:3128"
|
# common_proxy_server: "{{ hostvars['proxy1'].ansible_default_ipv4.address }}:3128"
|
||||||
|
common_search_domains:
|
||||||
|
- "multipass"
|
||||||
common_default_packages:
|
common_default_packages:
|
||||||
- "net-tools"
|
- "net-tools"
|
||||||
- "htop"
|
- "htop"
|
||||||
@@ -130,6 +132,8 @@
|
|||||||
unbound_stub_zones:
|
unbound_stub_zones:
|
||||||
- name: "{{ common.consul.datacenter }}.{{ common.consul.domain }}"
|
- name: "{{ common.consul.datacenter }}.{{ common.consul.domain }}"
|
||||||
stub_to: "127.0.0.1@8600"
|
stub_to: "127.0.0.1@8600"
|
||||||
|
caddy_crowdsec: true
|
||||||
|
caddy_crowdsec_api_key: "{{ secrets.crowdsec.lapi_key }}"
|
||||||
caddy_consul: true
|
caddy_consul: true
|
||||||
caddy_consul_delegate_to: "waf1"
|
caddy_consul_delegate_to: "waf1"
|
||||||
caddy_consul_admin_token: "{{ secrets.consul.bootstrap_secret }}"
|
caddy_consul_admin_token: "{{ secrets.consul.bootstrap_secret }}"
|
||||||
@@ -142,6 +146,7 @@
|
|||||||
roles:
|
roles:
|
||||||
- "local_ca_certs"
|
- "local_ca_certs"
|
||||||
- "consul"
|
- "consul"
|
||||||
|
- "crowdsec"
|
||||||
- "caddy"
|
- "caddy"
|
||||||
# - "keepalived"
|
# - "keepalived"
|
||||||
- "unbound"
|
- "unbound"
|
||||||
@@ -180,11 +185,11 @@
|
|||||||
owner: 1001
|
owner: 1001
|
||||||
group: 33
|
group: 33
|
||||||
clients:
|
clients:
|
||||||
- address: "www1"
|
- address: "www1.multipass"
|
||||||
options: "rw,no_root_squash"
|
options: "rw,no_root_squash"
|
||||||
- address: "www2"
|
- address: "www2.multipass"
|
||||||
options: "rw,no_root_squash"
|
options: "rw,no_root_squash"
|
||||||
- address: "www3"
|
- address: "www3.multipass"
|
||||||
options: "rw,no_root_squash"
|
options: "rw,no_root_squash"
|
||||||
roles:
|
roles:
|
||||||
- "nfs_server"
|
- "nfs_server"
|
||||||
@@ -200,7 +205,7 @@
|
|||||||
vars:
|
vars:
|
||||||
nfs_client_mounts:
|
nfs_client_mounts:
|
||||||
- mount_point: "/var/www/wordpress"
|
- mount_point: "/var/www/wordpress"
|
||||||
server: "nfs1:/srv/wordpress"
|
server: "nfs1.multipass:/srv/wordpress"
|
||||||
owner: 1001
|
owner: 1001
|
||||||
group: 33
|
group: 33
|
||||||
wordpress_create_master: "www1"
|
wordpress_create_master: "www1"
|
||||||
@@ -212,7 +217,7 @@
|
|||||||
wordpress_admin_email: "seb@itik.fr"
|
wordpress_admin_email: "seb@itik.fr"
|
||||||
wordpress_themes: ["twentytwentyfive"]
|
wordpress_themes: ["twentytwentyfive"]
|
||||||
wordpress_active_theme: "twentytwentyfive"
|
wordpress_active_theme: "twentytwentyfive"
|
||||||
wordpress_db_host: "bdd1"
|
wordpress_db_host: "bdd1.multipass"
|
||||||
wordpress_db_pass: "{{ secrets.wordpress.mysql_password }}"
|
wordpress_db_pass: "{{ secrets.wordpress.mysql_password }}"
|
||||||
roles:
|
roles:
|
||||||
- "nfs_client"
|
- "nfs_client"
|
||||||
|
|||||||
@@ -1,29 +1,33 @@
|
|||||||
$ANSIBLE_VAULT;1.1;AES256
|
$ANSIBLE_VAULT;1.1;AES256
|
||||||
64353736626438653965303633376231356361353433626432333862363638353937386635396430
|
66313136343333353333666339316366663134303039333133376461333765383138663238376162
|
||||||
6339336333323062333732626539333761396234316535360a376361326263393431626638373165
|
3739613236313832623963346565393630636562356239640a613634643365653264373338393737
|
||||||
34663632643038643630386331663035383738333364393636376137643037623939313136373665
|
64626435636131666132646566393735653364353764366139616533393135366662353564636666
|
||||||
3238356630313039310a636661613764373133323033356339373334613331366337343935313334
|
3139636566613065340a383931353561376339373730376633656537663435653764663139316665
|
||||||
30326631386562666336363735316234616339396633356633343339313562386530303863613331
|
30666261313338656230323861633033323733346463326166323262613866323264663736633235
|
||||||
30646638313535316433393361613461613932393933613932656362653666383638333739383831
|
66313334343963316261613137363439633938383134656164323963636665376534653963346534
|
||||||
64363266336438373635376663616432346464303365316564326536623133356264326462393537
|
36383435323239666366653362373635306465316338303332656438333332623030333433643165
|
||||||
38646261303962373465663266643139393366616133346662666331326539353635616662326138
|
39333432616666353539653766656363373365373335643238373336653433646536313666393163
|
||||||
64393163396339336231303765366130323530336433666361353161376536326465333438326337
|
61653664626131343131376363316337373666396564646465333764353465393666636136646162
|
||||||
64633731626636666430656335303431623663333464383138393231633435323338303862666634
|
34336364303139343864303766393963313135343531366131633731633234623133353631636234
|
||||||
33373664383663393637623735656338346566626431333964366637636431653461656363396463
|
32626230393539343561393135386163363536376637376533356536356266613266613434396338
|
||||||
65343033326433343863393865663236623133306663636237383532306137316534313436323137
|
34343364356364356262346161653962313336656433346132623437626332366336643034326532
|
||||||
66346630383133383430383263656137653462656665313664626366613135323463613737346261
|
38346339333332303265353334386661353935623837633865373361313830613138613138323835
|
||||||
32643833616135363066633632313863373563366362366534353762616162626239306135356164
|
34656535383664373039333734396564623662363330643332646535386533376265343863626632
|
||||||
31323631323939343763643964656330363133383437306236646466326266333964613162623666
|
36636537393162373064323361376361306664363065633961363033313031313763613134353436
|
||||||
61623139616466653438663065373635653162653461613131383531373632633235336332333935
|
63366434363137346263653966323239613164363634613235656364663037386537386335666431
|
||||||
30666430396634373563646439353563646536353966653635323932306261383863653137333766
|
65363162623031633166613735393735333133626466313061396333306236393039383062326264
|
||||||
39616564373330366230333562626435343934333331623761373336393937376562343433386334
|
38343464636330326162653036326663383631613836656461303462333035636335326135303766
|
||||||
31386663613031613835353662373138663835373235613462316232373533626439343631353632
|
37323463666338323766393063633662343835393330326332616331373633663366393563303438
|
||||||
36366133313862336336663134353935306661613935363331663136323930616361396431653439
|
37666162633461313333623934633138663930623135663638386634626430346264633735333532
|
||||||
37356666363331303637326663623561346236356266323731383632323835336362633362646237
|
64623461613538343436306436626133383733393737393463306539383763663866346164306339
|
||||||
31376230633165306135306537656434666630343865343333663762646361323462303031303935
|
64303335303539306632306164613761343035306632303063393233633262333264333431333363
|
||||||
36356132313934323235343436303032623461343630623464353663303138653566313938653635
|
30373861636565363438346338376531346162303564653435373237636237366632323564646539
|
||||||
36613037376430313966356237323362353862626139663339323834326637313636326534343031
|
37383361356362653132653961376134663930363763326437306338623064623862336435373664
|
||||||
37373664653361373064666362343165613063303336663330643064643331383432653333353330
|
63393262323039616539626137396432613932633730316235396435396531366466616264393161
|
||||||
38646535363835653039636531616632313130313963656435303739326530633434316237303562
|
62323339393039323235383663663265643065626137636562656335343233313734366166336264
|
||||||
66646631393563356136303537303563346537366633316437373231313265633133653431323031
|
35633765316262633636323866633266653037326165646230326564323033613963316331346331
|
||||||
33393937356430363739
|
32346265386164376361303532343730343139393837343162666238633366643361353332376137
|
||||||
|
33633764323133316334323234353932363165636438656563353630373238376465643463656535
|
||||||
|
30383337303861326433303137383539313536333465663063306137646264316438636665323263
|
||||||
|
34383933666565333962363863313536653232363930306665336432373738353238666362353639
|
||||||
|
37316136373639373233
|
||||||
|
|||||||
@@ -1,21 +1,27 @@
|
|||||||
vms = {
|
vms = {
|
||||||
proxy1 = {
|
# proxy1 = {
|
||||||
disk = "20g"
|
# disk = "20g"
|
||||||
},
|
# },
|
||||||
waf1 = {
|
waf1 = {
|
||||||
cpus = 4
|
cpus = 4
|
||||||
},
|
},
|
||||||
waf2 = {
|
waf2 = {
|
||||||
cpus = 4
|
cpus = 4
|
||||||
|
image = "22.04"
|
||||||
},
|
},
|
||||||
waf3 = {
|
waf3 = {
|
||||||
cpus = 4
|
cpus = 4
|
||||||
|
image = "24.04"
|
||||||
},
|
},
|
||||||
bdd1 = {},
|
bdd1 = {},
|
||||||
nfs1 = {},
|
nfs1 = {},
|
||||||
www1 = {},
|
www1 = {},
|
||||||
www2 = {},
|
www2 = {},
|
||||||
www3 = {},
|
www3 = {},
|
||||||
www4 = {},
|
www4 = {
|
||||||
www5 = {},
|
image = "22.04"
|
||||||
|
},
|
||||||
|
www5 = {
|
||||||
|
image = "24.04"
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,6 @@ variable "vms" {
|
|||||||
cpus = optional(number, 2),
|
cpus = optional(number, 2),
|
||||||
memory = optional(string, "3g"),
|
memory = optional(string, "3g"),
|
||||||
disk = optional(string, "12g"),
|
disk = optional(string, "12g"),
|
||||||
image = optional(string, "24.04"),
|
image = optional(string, "https://cloud.debian.org/images/cloud/trixie/latest/debian-13-generic-amd64.qcow2"),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace: "seb4itik"
|
namespace: "seb4itik"
|
||||||
name: "byow"
|
name: "byow"
|
||||||
version: "0.3.1"
|
version: "0.3.5"
|
||||||
readme: "README.md"
|
readme: "README.md"
|
||||||
authors:
|
authors:
|
||||||
- "S. Namèche <sebastien@itik.fr>"
|
- "S. Namèche <sebastien@itik.fr>"
|
||||||
|
|||||||
@@ -6,45 +6,26 @@ caddy_http_port: 80
|
|||||||
caddy_https_port: 443
|
caddy_https_port: 443
|
||||||
caddy_default_bind: null
|
caddy_default_bind: null
|
||||||
|
|
||||||
# If true, will not install software, just deploy Caddy and OWASP CRS
|
# Sotware versions
|
||||||
|
caddy_go_version: "1.26.1"
|
||||||
|
caddy_xcaddy_version: "0.4.5"
|
||||||
|
caddy_version: "2.11.2"
|
||||||
|
|
||||||
|
# If true, will not install software, just deploy Caddyfile and OWASP CRS
|
||||||
# configuration files.
|
# configuration files.
|
||||||
caddy_config_only: false
|
caddy_config_only: false
|
||||||
|
|
||||||
# Debug will go to /var/log/<caddy_my_name>/debug.log.
|
# Log settings
|
||||||
caddy_debug: false
|
# If log_to_file is false, will log to journald.
|
||||||
|
# If log_to_file is true, logs will go:
|
||||||
# Required for Let's Encrypt auto certificates.
|
# - for each site, in: /var/log/<caddy_my_name>/site_<sit.id>.log
|
||||||
caddy_email: null
|
# - for WAF logs (Coraza), in /var/log/<caddy_my_name>/waf.log
|
||||||
|
caddy_log_to_file: true
|
||||||
# If a custom CA root have to be used.
|
caddy_log_format: "console" # "console" or "json"
|
||||||
caddy_ca_root: null
|
caddy_log_debug: false # Debug will go to /var/log/<caddy_my_name>/debug.log
|
||||||
|
|
||||||
# For using a Consul cluster.
|
|
||||||
caddy_consul: false
|
|
||||||
caddy_consul_server: "{{ ansible_fqdn }}:8501"
|
|
||||||
caddy_consul_delegate_to: null # Required, Consul host for running Consul commands
|
|
||||||
caddy_consul_admin_token: null # Required
|
|
||||||
caddy_consul_aes_key: null # Required, 32 characters
|
|
||||||
caddy_consul_client_cert: null # Required
|
|
||||||
caddy_consul_client_key: null # Required
|
|
||||||
|
|
||||||
# Accound id and license key are required if a site use Geoip filtering.
|
|
||||||
# See: https://dev.maxmind.com/geoip/updating-databases/
|
|
||||||
caddy_geoip_account_id: null
|
|
||||||
caddy_geoip_license_key: null
|
|
||||||
caddy_geoip_edition_ids: "GeoLite2-ASN,GeoLite2-Country,GeoLite2-City"
|
|
||||||
caddy_geoip_update_frequency: 86400 # In seconds
|
|
||||||
|
|
||||||
# Sotware versions
|
|
||||||
caddy_version: "2.10.2"
|
|
||||||
caddy_go_version: "1.25.6"
|
|
||||||
caddy_xcaddy_version: "0.4.5"
|
|
||||||
caddy_coraza_caddy_version: "v2@v2.1.0" # Coraza v3.3.3
|
|
||||||
# Different sites can use different versions of OWASP CRS
|
|
||||||
caddy_owasp_crs_versions: ["4.23.0"]
|
|
||||||
|
|
||||||
# Paths
|
# Paths
|
||||||
caddy_binary: "/usr/local/bin/{{ caddy_my_name }}"
|
caddy_binary: "/usr/local/sbin/caddy_{{ caddy_my_name }}" # Should begin by "caddy" for CrowdSec
|
||||||
caddy_system_user: "{{ caddy_my_name }}"
|
caddy_system_user: "{{ caddy_my_name }}"
|
||||||
caddy_system_group: "{{ caddy_my_name }}"
|
caddy_system_group: "{{ caddy_my_name }}"
|
||||||
caddy_home_dir: "/opt/{{ caddy_my_name }}"
|
caddy_home_dir: "/opt/{{ caddy_my_name }}"
|
||||||
@@ -53,9 +34,52 @@ caddy_crs_plugins_dir: "{{ caddy_config_dir }}/crs-plugins"
|
|||||||
caddy_sites_dir: "{{ caddy_config_dir }}/sites"
|
caddy_sites_dir: "{{ caddy_config_dir }}/sites"
|
||||||
caddy_log_dir: "/var/log/{{ caddy_my_name }}"
|
caddy_log_dir: "/var/log/{{ caddy_my_name }}"
|
||||||
|
|
||||||
# OWASP CRS plugins that will can be actived per site.
|
# Required for Let's Encrypt auto certificates.
|
||||||
|
caddy_email: null
|
||||||
|
|
||||||
|
# For using a Consul cluster.
|
||||||
|
caddy_consul: false
|
||||||
|
caddy_consul_server: "{{ ansible_fqdn }}:8501"
|
||||||
|
caddy_consul_delegate_to: null # Required, Consul host for running Consul commands
|
||||||
|
caddy_consul_admin_token: null # Required
|
||||||
|
caddy_consul_aes_key: null # Required, 32 characters
|
||||||
|
caddy_consul_client_cert: null # Required, CN must be "server.<consul datacenter>.<consul domain>"
|
||||||
|
# At least, SANs must include:
|
||||||
|
# - "DNS:server.<consul datacenter>.<consul domain>"
|
||||||
|
# - "DNS:<host FQDN>"
|
||||||
|
caddy_consul_client_key: null # Required
|
||||||
|
|
||||||
|
# Accound id and license key are required if a site use Geoip filtering.
|
||||||
|
# See: https://dev.maxmind.com/geoip/updating-databases/
|
||||||
|
caddy_geoip: false
|
||||||
|
caddy_geoip_account_id: null # Required
|
||||||
|
caddy_geoip_license_key: null # Required
|
||||||
|
caddy_geoip_edition_ids: "GeoLite2-ASN,GeoLite2-Country,GeoLite2-City"
|
||||||
|
caddy_geoip_update_frequency: 86400 # In seconds
|
||||||
|
|
||||||
|
# CrowdSec
|
||||||
|
caddy_crowdsec: false
|
||||||
|
caddy_crowdsec_api_key: null # Required
|
||||||
|
caddy_crowdsec_api_url: "http://127.0.0.1:8080"
|
||||||
|
caddy_crowdsec_ticker_interval: 15 # In seconds
|
||||||
|
caddy_crowdsec_appsec_url: null # "http://localhost:7422"
|
||||||
|
caddy_crowdsec_streaming: true
|
||||||
|
caddy_crowdsec_hard_fails: true
|
||||||
|
|
||||||
|
# Rate Limit
|
||||||
|
caddy_ratelimit: true
|
||||||
|
|
||||||
|
# Bot barrier
|
||||||
|
caddy_bot_barrier: false
|
||||||
|
|
||||||
|
# Coraza
|
||||||
|
caddy_coraza: true
|
||||||
|
caddy_coraza_caddy_version: "v2@v2.2.0" # Coraza v3.3.3
|
||||||
|
# Different sites can use different versions of OWASP CRS
|
||||||
|
caddy_coraza_crs_versions: ["4.24.1"]
|
||||||
|
# OWASP CRS plugins that can be actived per site.
|
||||||
# Cf.: https://github.com/coreruleset/plugin-registry
|
# Cf.: https://github.com/coreruleset/plugin-registry
|
||||||
caddy_crs_plugins:
|
caddy_coraza_crs_plugins:
|
||||||
- name: "drupal-rule-exclusions"
|
- name: "drupal-rule-exclusions"
|
||||||
version: "1.0.0"
|
version: "1.0.0"
|
||||||
- name: "wordpress-rule-exclusions"
|
- name: "wordpress-rule-exclusions"
|
||||||
@@ -77,12 +101,14 @@ caddy_crs_plugins:
|
|||||||
|
|
||||||
# Sites
|
# Sites
|
||||||
caddy_sites: []
|
caddy_sites: []
|
||||||
# - id: "" # Mandatory: short id for the site (for site specific directories and files)
|
# - id: "" # Mandatory: short id for the site (for site specific directories and files)
|
||||||
# name: "" # Mandatory: canonical domain name
|
# name: "" # Mandatory: canonical domain name
|
||||||
# paths: # Mandatory: targets for the reverse proxy
|
# paths: # Mandatory: targets for the reverse proxy
|
||||||
# - path: "" # Optionnal: path of the request, default "*"
|
# - path: "*" # Optionnal: path of the request, default "*"
|
||||||
# addrs: # Mandatory: upstreams
|
# strip_prefix: false # Optionnal: default "false"
|
||||||
# - "" # Mandatory: URL of the upstream, minimum 1 required
|
# addrs: # Mandatory: upstreams
|
||||||
|
# - "" # Mandatory: URL of the upstream, minimum 1 required
|
||||||
|
# ... # Site configuration directives (see caddy_global_sites_defaults in vars/main.yml)
|
||||||
|
|
||||||
|
|
||||||
# For overriding default global parameters. Will be merged with
|
# For overriding default global parameters. Will be merged with
|
||||||
|
|||||||
@@ -6,3 +6,8 @@
|
|||||||
ansible.builtin.service:
|
ansible.builtin.service:
|
||||||
name: "{{ caddy_my_name }}"
|
name: "{{ caddy_my_name }}"
|
||||||
state: "restarted"
|
state: "restarted"
|
||||||
|
|
||||||
|
- name: Restart Crowdsec Securiy Engine
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: "crowdsec"
|
||||||
|
state: "restarted"
|
||||||
|
|||||||
@@ -2,63 +2,69 @@
|
|||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
caddy_sites_defaults: "{{ caddy_global_sites_defaults | combine(caddy_my_sites_defaults) }}"
|
caddy_sites_defaults: "{{ caddy_global_sites_defaults | combine(caddy_my_sites_defaults) }}"
|
||||||
|
|
||||||
- name: Create sites config directories
|
- name: Configure Caddy Coraza CRS
|
||||||
loop: "{{ caddy_sites }}"
|
when: "caddy_coraza"
|
||||||
ansible.builtin.file:
|
block:
|
||||||
path: "{{ caddy_sites_dir }}/{{ item.id }}"
|
|
||||||
state: "directory"
|
|
||||||
group: "{{ caddy_system_group }}"
|
|
||||||
mode: "0750"
|
|
||||||
|
|
||||||
- name: Generate sites coraza.conf config file
|
- name: Create sites config directories
|
||||||
loop: "{{ caddy_sites }}"
|
loop: "{{ caddy_sites }}"
|
||||||
loop_control:
|
ansible.builtin.file:
|
||||||
loop_var: "site"
|
path: "{{ caddy_sites_dir }}/{{ item.id }}"
|
||||||
ansible.builtin.template:
|
state: "directory"
|
||||||
src: "templates/coraza.conf"
|
group: "{{ caddy_system_group }}"
|
||||||
dest: "{{ caddy_sites_dir }}/{{ site.id }}/coraza.conf"
|
mode: "0750"
|
||||||
group: "{{ caddy_system_group }}"
|
|
||||||
mode: "0640"
|
|
||||||
notify:
|
|
||||||
- "Restart Caddy"
|
|
||||||
|
|
||||||
- name: Generate sites crs-setup config file
|
- name: Generate sites coraza.conf config file
|
||||||
loop: "{{ caddy_sites }}"
|
loop: "{{ caddy_sites }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: "site"
|
loop_var: "site"
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: "templates/crs-setup.conf"
|
src: "templates/coraza.conf"
|
||||||
dest: "{{ caddy_sites_dir }}/{{ site.id }}/crs-setup.conf"
|
dest: "{{ caddy_sites_dir }}/{{ site.id }}/coraza.conf"
|
||||||
group: "{{ caddy_system_group }}"
|
group: "{{ caddy_system_group }}"
|
||||||
mode: "0640"
|
mode: "0640"
|
||||||
notify:
|
notify:
|
||||||
- "Restart Caddy"
|
- "Restart Caddy"
|
||||||
|
|
||||||
- name: Generate sites exclusions before request file
|
- name: Generate sites crs-setup config file
|
||||||
loop: "{{ caddy_sites }}"
|
loop: "{{ caddy_sites }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: "site"
|
loop_var: "site"
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: "templates/exclusions-request-before.conf"
|
src: "templates/crs-setup.conf"
|
||||||
dest: "{{ caddy_sites_dir }}/{{ site.id }}/exclusions-request-before.conf"
|
dest: "{{ caddy_sites_dir }}/{{ site.id }}/crs-setup.conf"
|
||||||
group: "{{ caddy_system_group }}"
|
group: "{{ caddy_system_group }}"
|
||||||
mode: "0640"
|
mode: "0640"
|
||||||
notify:
|
notify:
|
||||||
- "Restart Caddy"
|
- "Restart Caddy"
|
||||||
|
|
||||||
- name: Generate sites exclusions after response file
|
- name: Generate sites exclusions before request file
|
||||||
loop: "{{ caddy_sites }}"
|
loop: "{{ caddy_sites }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: "site"
|
loop_var: "site"
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: "templates/exclusions-response-after.conf"
|
src: "templates/exclusions-request-before.conf"
|
||||||
dest: "{{ caddy_sites_dir }}/{{ site.id }}/exclusions-response-after.conf"
|
dest: "{{ caddy_sites_dir }}/{{ site.id }}/exclusions-request-before.conf"
|
||||||
group: "{{ caddy_system_group }}"
|
group: "{{ caddy_system_group }}"
|
||||||
mode: "0640"
|
mode: "0640"
|
||||||
notify:
|
notify:
|
||||||
- "Restart Caddy"
|
- "Restart Caddy"
|
||||||
|
|
||||||
|
- name: Generate sites exclusions after response file
|
||||||
|
loop: "{{ caddy_sites }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: "site"
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: "templates/exclusions-response-after.conf"
|
||||||
|
dest: "{{ caddy_sites_dir }}/{{ site.id }}/exclusions-response-after.conf"
|
||||||
|
group: "{{ caddy_system_group }}"
|
||||||
|
mode: "0640"
|
||||||
|
notify:
|
||||||
|
- "Restart Caddy"
|
||||||
|
|
||||||
|
# FIXME: Should per site
|
||||||
- name: Copy bot barrier template
|
- name: Copy bot barrier template
|
||||||
|
when: "caddy_bot_barrier"
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: "files/bot_barrier_template.html"
|
src: "files/bot_barrier_template.html"
|
||||||
dest: "{{ caddy_config_dir }}/bot_barrier_template.html"
|
dest: "{{ caddy_config_dir }}/bot_barrier_template.html"
|
||||||
|
|||||||
19
seb4itik/byow/roles/caddy/tasks/caddy_crowdsec.yml
Normal file
19
seb4itik/byow/roles/caddy/tasks/caddy_crowdsec.yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
- name: Get collections list
|
||||||
|
ansible.builtin.shell:
|
||||||
|
executable: "/usr/bin/bash"
|
||||||
|
cmd: |
|
||||||
|
set -o pipefail
|
||||||
|
cscli collection list --output=json |jq -r '.collections[] |.name'
|
||||||
|
register: "crowdsec_out_list_collections"
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Install collections
|
||||||
|
loop:
|
||||||
|
- "crowdsecurity/caddy"
|
||||||
|
- "barnoux/caddy-coraza"
|
||||||
|
when: "item not in crowdsec_out_list_collections.stdout_lines"
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: "cscli collections install {{ item }}"
|
||||||
|
changed_when: true
|
||||||
|
notify:
|
||||||
|
- "Restart Crowdsec Securiy Engine"
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
- "git"
|
- "git"
|
||||||
- "libnss3-tools"
|
- "libnss3-tools"
|
||||||
- "ssl-cert"
|
- "ssl-cert"
|
||||||
|
- "jq"
|
||||||
|
|
||||||
- name: Create Go directory
|
- name: Create Go directory
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
@@ -37,16 +38,31 @@
|
|||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
caddy_build_command: >
|
caddy_build_command: >
|
||||||
/usr/local/xcaddy-{{ caddy_xcaddy_version }}/xcaddy build v{{ caddy_version }}
|
/usr/local/xcaddy-{{ caddy_xcaddy_version }}/xcaddy build v{{ caddy_version }}
|
||||||
--with github.com/pteich/caddy-tlsconsul
|
{% if caddy_coraza %}
|
||||||
--with github.com/corazawaf/coraza-caddy/{{ caddy_coraza_caddy_version }}
|
--with github.com/corazawaf/coraza-caddy/{{ caddy_coraza_caddy_version }}
|
||||||
|
{% endif %}
|
||||||
|
{% if caddy_ratelimit %}
|
||||||
--with github.com/mholt/caddy-ratelimit
|
--with github.com/mholt/caddy-ratelimit
|
||||||
|
{% endif %}
|
||||||
|
{% if caddy_consul %}
|
||||||
|
--with github.com/pteich/caddy-tlsconsul
|
||||||
|
{% endif %}
|
||||||
|
{% if caddy_bot_barrier %}
|
||||||
--with github.com/steffenbusch/caddy-bot-barrier
|
--with github.com/steffenbusch/caddy-bot-barrier
|
||||||
|
{% endif %}
|
||||||
|
{% if caddy_geoip %}
|
||||||
--with github.com/zhangjiayin/caddy-geoip2
|
--with github.com/zhangjiayin/caddy-geoip2
|
||||||
|
{% endif %}
|
||||||
|
{% if caddy_crowdsec %}
|
||||||
|
--with github.com/hslatman/caddy-crowdsec-bouncer/http
|
||||||
|
--with github.com/hslatman/caddy-crowdsec-bouncer/layer4
|
||||||
|
--with github.com/hslatman/caddy-crowdsec-bouncer/appsec
|
||||||
|
{% endif %}
|
||||||
--output {{ caddy_binary }}
|
--output {{ caddy_binary }}
|
||||||
|
|
||||||
- name: Remember and test Caddy version
|
- name: Remember and test Caddy version
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
dest: "/usr/local/bin/.caddy.{{ caddy_my_name }}.build"
|
dest: "{{ caddy_binary }}.build"
|
||||||
content: >
|
content: >
|
||||||
XCADDY_WHICH_GO=/usr/local/go-{{ caddy_go_version }}/bin/go
|
XCADDY_WHICH_GO=/usr/local/go-{{ caddy_go_version }}/bin/go
|
||||||
{{ caddy_build_command }}
|
{{ caddy_build_command }}
|
||||||
@@ -60,7 +76,6 @@
|
|||||||
XCADDY_WHICH_GO: "/usr/local/go-{{ caddy_go_version }}/bin/go"
|
XCADDY_WHICH_GO: "/usr/local/go-{{ caddy_go_version }}/bin/go"
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
cmd: "{{ caddy_build_command }}"
|
cmd: "{{ caddy_build_command }}"
|
||||||
creates: "{{ caddy_binary }}"
|
|
||||||
notify:
|
notify:
|
||||||
- "Restart Caddy"
|
- "Restart Caddy"
|
||||||
|
|
||||||
@@ -96,7 +111,8 @@
|
|||||||
owner: "{{ caddy_system_user }}"
|
owner: "{{ caddy_system_user }}"
|
||||||
|
|
||||||
- name: Install OWASP CRS
|
- name: Install OWASP CRS
|
||||||
loop: "{{ caddy_owasp_crs_versions }}"
|
when: "caddy_coraza"
|
||||||
|
loop: "{{ caddy_coraza_crs_versions }}"
|
||||||
ansible.builtin.unarchive:
|
ansible.builtin.unarchive:
|
||||||
src: "https://github.com/coreruleset/coreruleset/archive/refs/tags/v{{ item }}.tar.gz"
|
src: "https://github.com/coreruleset/coreruleset/archive/refs/tags/v{{ item }}.tar.gz"
|
||||||
dest: "{{ caddy_config_dir }}"
|
dest: "{{ caddy_config_dir }}"
|
||||||
@@ -104,8 +120,9 @@
|
|||||||
group: "{{ caddy_system_group }}"
|
group: "{{ caddy_system_group }}"
|
||||||
remote_src: true
|
remote_src: true
|
||||||
|
|
||||||
- name: Install plugins
|
- name: Install CRS plugins
|
||||||
loop: "{{ caddy_crs_plugins }}"
|
when: "caddy_coraza"
|
||||||
|
loop: "{{ caddy_coraza_crs_plugins }}"
|
||||||
ansible.builtin.unarchive:
|
ansible.builtin.unarchive:
|
||||||
src: "https://github.com/{{ item.provider | default('coreruleset') }}/{{ item.name }}-plugin/archive/refs/tags/v{{ item.version }}.tar.gz"
|
src: "https://github.com/{{ item.provider | default('coreruleset') }}/{{ item.name }}-plugin/archive/refs/tags/v{{ item.version }}.tar.gz"
|
||||||
dest: "{{ caddy_crs_plugins_dir }}"
|
dest: "{{ caddy_crs_plugins_dir }}"
|
||||||
@@ -119,9 +136,9 @@
|
|||||||
group: "{{ caddy_system_group }}"
|
group: "{{ caddy_system_group }}"
|
||||||
remote_src: true
|
remote_src: true
|
||||||
|
|
||||||
- name: Create plugins after config
|
- name: Create CRS plugins after config
|
||||||
loop: "{{ caddy_crs_plugins }}"
|
loop: "{{ caddy_coraza_crs_plugins }}"
|
||||||
when: "not(item.has_after_config | default(false))"
|
when: "caddy_coraza and not(item.has_after_config | default(false))"
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
content: ""
|
content: ""
|
||||||
dest: "{{ caddy_crs_plugins_dir }}/{{ item.name }}-after.conf"
|
dest: "{{ caddy_crs_plugins_dir }}/{{ item.name }}-after.conf"
|
||||||
|
|||||||
@@ -6,5 +6,9 @@
|
|||||||
when: "caddy_consul"
|
when: "caddy_consul"
|
||||||
ansible.builtin.include_tasks: "caddy_consul.yml"
|
ansible.builtin.include_tasks: "caddy_consul.yml"
|
||||||
|
|
||||||
|
- name: Configure CrowdSec for Caddy
|
||||||
|
when: "caddy_crowdsec"
|
||||||
|
ansible.builtin.include_tasks: "caddy_crowdsec.yml"
|
||||||
|
|
||||||
- name: Configure Caddy
|
- name: Configure Caddy
|
||||||
ansible.builtin.include_tasks: "caddy_config.yml"
|
ansible.builtin.include_tasks: "caddy_config.yml"
|
||||||
|
|||||||
@@ -1,31 +1,40 @@
|
|||||||
{
|
{
|
||||||
http_port {{ caddy_http_port }}
|
http_port {{ caddy_http_port }}
|
||||||
https_port {{ caddy_https_port }}
|
https_port {{ caddy_https_port }}
|
||||||
|
admin off
|
||||||
|
persist_config off
|
||||||
{% if caddy_default_bind != None %}
|
{% if caddy_default_bind != None %}
|
||||||
default_bind {{ caddy_default_bind }}
|
default_bind {{ caddy_default_bind }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if caddy_crowdsec %}
|
||||||
|
order crowdsec first
|
||||||
|
{% endif %}
|
||||||
|
{% if caddy_geoip %}
|
||||||
order geoip2_vars first
|
order geoip2_vars first
|
||||||
|
{% endif %}
|
||||||
|
{% if caddy_coraza %}
|
||||||
order coraza_waf first
|
order coraza_waf first
|
||||||
admin off
|
{% endif %}
|
||||||
persist_config off
|
|
||||||
|
|
||||||
{% if caddy_consul %}
|
{% if caddy_consul %}
|
||||||
|
# See: https://github.com/pteich/caddy-tlsconsul
|
||||||
storage consul {
|
storage consul {
|
||||||
address "{{ caddy_consul_server }}"
|
address "{{ caddy_consul_server }}"
|
||||||
token "{{ caddy_out_consul_token.token.SecretID }}"
|
token "{{ caddy_out_consul_token.token.SecretID | mandatory }}"
|
||||||
timeout 10
|
timeout 10
|
||||||
prefix "caddy-{{ caddy_my_name }}-tls"
|
prefix "caddy-{{ caddy_my_name }}-tls"
|
||||||
value_prefix "{{ caddy_my_name }}"
|
value_prefix "{{ caddy_my_name }}"
|
||||||
aes_key "{{ caddy_consul_aes_key }}"
|
aes_key "{{ caddy_consul_aes_key | mandatory }}"
|
||||||
tls_enabled "true"
|
tls_enabled "true"
|
||||||
tls_insecure "false"
|
tls_insecure "false"
|
||||||
}
|
}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if caddy_geoip_account_id != None and caddy_geoip_license_key != None %}
|
{% if caddy_geoip %}
|
||||||
|
# See: https://github.com/zhangjiayin/caddy-geoip2
|
||||||
geoip2 {
|
geoip2 {
|
||||||
accountId "{{ caddy_geoip_account_id }}"
|
accountId "{{ caddy_geoip_account_id | mandatory }}"
|
||||||
licenseKey "{{ caddy_geoip_license_key }}"
|
licenseKey "{{ caddy_geoip_license_key | mandatory }}"
|
||||||
databaseDirectory "{{ caddy_home_dir }}/geoip2"
|
databaseDirectory "{{ caddy_home_dir }}/geoip2"
|
||||||
lockFile "{{ caddy_home_dir }}/geoip2/.geoip2.lock"
|
lockFile "{{ caddy_home_dir }}/geoip2/.geoip2.lock"
|
||||||
editionID "{{ caddy_geoip_edition_ids }}"
|
editionID "{{ caddy_geoip_edition_ids }}"
|
||||||
@@ -38,32 +47,49 @@
|
|||||||
email "{{ caddy_email }}"
|
email "{{ caddy_email }}"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if caddy_ca_root | default(None) != None %}
|
{% if caddy_crowdsec %}
|
||||||
tls {
|
# See: https://github.com/hslatman/caddy-crowdsec-bouncer
|
||||||
ca_root "{{ caddy_ca_root }}"
|
crowdsec {
|
||||||
}
|
api_key {{ caddy_crowdsec_api_key | mandatory }}
|
||||||
{% endif %}
|
api_url {{ caddy_crowdsec_api_url }}
|
||||||
|
ticker_interval {{ caddy_crowdsec_ticker_interval }}s
|
||||||
{% if caddy_debug %}
|
{% if caddy_crowdsec_appsec_url != None %}
|
||||||
log {
|
appsec_url {{ caddy_crowdsec_appsec_url }}
|
||||||
format json
|
{% endif %}
|
||||||
level DEBUG
|
{% if not caddy_crowdsec_streaming %}
|
||||||
output file {{ caddy_log_dir }}/debug.log
|
disable_streaming
|
||||||
|
{% endif %}
|
||||||
|
{% if caddy_crowdsec_hard_fails %}
|
||||||
|
enable_hard_fails
|
||||||
|
{% endif %}
|
||||||
}
|
}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if caddy_coraza %}
|
||||||
log waf {
|
log waf {
|
||||||
format {{ caddy_sites_defaults.log_format }}
|
|
||||||
include "http.handlers.waf"
|
include "http.handlers.waf"
|
||||||
|
format {{ caddy_log_format }}
|
||||||
format append {
|
format append {
|
||||||
waf_id {{ caddy_my_name }}
|
waf_id {{ caddy_my_name }}
|
||||||
}
|
}
|
||||||
{% if caddy_sites_defaults.log_to_file %}
|
{% if caddy_log_to_file %}
|
||||||
output file {{ caddy_log_dir }}/waf.log
|
output file {{ caddy_log_dir }}/waf.log
|
||||||
{% else %}
|
{% else %}
|
||||||
output stdout
|
output stdout
|
||||||
{% endif %}
|
{% endif %}
|
||||||
}
|
}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if caddy_log_debug %}
|
||||||
|
log {
|
||||||
|
level DEBUG
|
||||||
|
format {{ caddy_log_format }}
|
||||||
|
format append {
|
||||||
|
waf_id {{ caddy_my_name }}
|
||||||
|
}
|
||||||
|
output file {{ caddy_log_dir }}/debug.log
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
}
|
}
|
||||||
|
|
||||||
# 0=origin, 1=methods, 2=headers, 3=allow credentials, 4=max age, 5=vary, 6=expose headers
|
# 0=origin, 1=methods, 2=headers, 3=allow credentials, 4=max age, 5=vary, 6=expose headers
|
||||||
@@ -105,7 +131,7 @@
|
|||||||
|
|
||||||
{% for site in caddy_sites %}
|
{% for site in caddy_sites %}
|
||||||
|
|
||||||
{% if (site.site_redirect_from_aliases | default(caddy_sites_defaults.site_redirect_from_aliases)) and (site.site_aliases | default([]) | length) > 0 %}
|
{% if (site.site_aliases_redirect | default(caddy_sites_defaults.site_aliases_redirect)) and (site.site_aliases | default([]) | length) > 0 %}
|
||||||
{{ site.site_aliases | join(', ') }} {
|
{{ site.site_aliases | join(', ') }} {
|
||||||
redir https://{{ site.name }}{uri}
|
redir https://{{ site.name }}{uri}
|
||||||
}
|
}
|
||||||
@@ -117,8 +143,12 @@
|
|||||||
{{ site.name }} {
|
{{ site.name }} {
|
||||||
encode gzip zstd
|
encode gzip zstd
|
||||||
|
|
||||||
|
{% if caddy_crowdsec and site.crowdsec | default(caddy_sites_defaults.crowdsec) %}
|
||||||
|
crowdsec
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% for path in site.paths %}
|
{% for path in site.paths %}
|
||||||
handle {{ path.path | default('*') }} {
|
handle{% if path.strip_prefix | default(false) %}_path{% endif %} {{ path.path | default('*') }} {
|
||||||
reverse_proxy {
|
reverse_proxy {
|
||||||
to {{ path.addrs | join(' ') }}
|
to {{ path.addrs | join(' ') }}
|
||||||
header_up X-Real-IP {remote}
|
header_up X-Real-IP {remote}
|
||||||
@@ -148,8 +178,8 @@
|
|||||||
}
|
}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% if site.custom_cert | default (false) %}
|
{% if site.custom_cert | default(caddy_sites_defaults.custom_cert) %}
|
||||||
tls {{ site.custom_cert_file }} {{ site.custom_cert_key_file }}
|
tls {{ site.custom_cert_file | default(caddy_sites_defaults.custom_cert_file) }} {{ site.custom_cert_key_file | default(caddy_sites_defaults.custom_cert_key_file) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if site.filter_blacklist | default(caddy_sites_defaults.filter_blacklist) | length > 0 %}
|
{% if site.filter_blacklist | default(caddy_sites_defaults.filter_blacklist) | length > 0 %}
|
||||||
@@ -161,7 +191,7 @@
|
|||||||
respond @blocked "Access Denied" 403
|
respond @blocked "Access Denied" 403
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if site.geoip | default(caddy_sites_defaults.geoip) %}
|
{% if caddy_geoip and site.geoip | default(caddy_sites_defaults.geoip) %}
|
||||||
geoip2_vars strict
|
geoip2_vars strict
|
||||||
@geofilter expression {{ site.geoip_filter_expression | default(caddy_sites_defaults.geoip_filter_expression) }}
|
@geofilter expression {{ site.geoip_filter_expression | default(caddy_sites_defaults.geoip_filter_expression) }}
|
||||||
respond @geofilter "Access Denied" 403
|
respond @geofilter "Access Denied" 403
|
||||||
@@ -203,7 +233,8 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
}
|
}
|
||||||
|
|
||||||
{% if site.rate_limit | default(caddy_sites_defaults.rate_limit) %}
|
{% if caddy_ratelimit and site.rate_limit | default(caddy_sites_defaults.rate_limit) %}
|
||||||
|
# See: https://github.com/mholt/caddy-ratelimit
|
||||||
rate_limit @not_whitelisted {
|
rate_limit @not_whitelisted {
|
||||||
{% if caddy_consul %}
|
{% if caddy_consul %}
|
||||||
distributed
|
distributed
|
||||||
@@ -216,7 +247,7 @@
|
|||||||
aes_key "{{ caddy_consul_aes_key }}"
|
aes_key "{{ caddy_consul_aes_key }}"
|
||||||
tls_enabled "true"
|
tls_enabled "true"
|
||||||
tls_insecure "false"
|
tls_insecure "false"
|
||||||
}
|
}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
log_key
|
log_key
|
||||||
zone remote_ip {
|
zone remote_ip {
|
||||||
@@ -227,7 +258,7 @@
|
|||||||
}
|
}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if site.crs | default(caddy_sites_defaults.crs) %}
|
{% if caddy_coraza and site.crs | default(caddy_sites_defaults.crs) %}
|
||||||
coraza_waf @not_whitelisted {
|
coraza_waf @not_whitelisted {
|
||||||
load_owasp_crs
|
load_owasp_crs
|
||||||
directives `
|
directives `
|
||||||
@@ -261,7 +292,8 @@
|
|||||||
import cors-deny
|
import cors-deny
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if site.bot_barrier | default(caddy_sites_defaults.bot_barrier) %}
|
{% if caddy_bot_barrier and site.bot_barrier | default(caddy_sites_defaults.bot_barrier) %}
|
||||||
|
# See: https://github.com/steffenbusch/caddy-bot-barrier
|
||||||
bot_barrier @not_whitelisted {
|
bot_barrier @not_whitelisted {
|
||||||
secret {{ site.bot_barrier_secret | default(caddy_sites_defaults.bot_barrier_secret) | mandatory }}
|
secret {{ site.bot_barrier_secret | default(caddy_sites_defaults.bot_barrier_secret) | mandatory }}
|
||||||
complexity {{ site.bot_barrier_complexity | default(caddy_sites_defaults.bot_barrier_complexity) }}
|
complexity {{ site.bot_barrier_complexity | default(caddy_sites_defaults.bot_barrier_complexity) }}
|
||||||
@@ -273,6 +305,7 @@
|
|||||||
}
|
}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if site.header | default(caddy_sites_defaults.header) %}
|
||||||
header {
|
header {
|
||||||
Content-Security-Policy "{{ caddy_sites_defaults.header_content_security_policy | combine(site.header_content_security_policy | default({})) | dict2str(sep1=' ', sep2='; ', sep3=';') }}"
|
Content-Security-Policy "{{ caddy_sites_defaults.header_content_security_policy | combine(site.header_content_security_policy | default({})) | dict2str(sep1=' ', sep2='; ', sep3=';') }}"
|
||||||
Cross-Origin-Embedder-Policy "{{ site.header_cross_origin_embedder_policy | default(caddy_sites_defaults.header_cross_origin_embedder_policy) }}"
|
Cross-Origin-Embedder-Policy "{{ site.header_cross_origin_embedder_policy | default(caddy_sites_defaults.header_cross_origin_embedder_policy) }}"
|
||||||
@@ -294,6 +327,7 @@
|
|||||||
{{ header.name }} "{{ header.value }}"
|
{{ header.name }} "{{ header.value }}"
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
}
|
}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
handle_errors 403 {
|
handle_errors 403 {
|
||||||
header X-Blocked "true"
|
header X-Blocked "true"
|
||||||
@@ -301,12 +335,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
log {
|
log {
|
||||||
format {{ site.log_format | default(caddy_sites_defaults.log_format) }}
|
|
||||||
level INFO
|
level INFO
|
||||||
|
format {{ caddy_log_format }}
|
||||||
format append {
|
format append {
|
||||||
waf_id {{ caddy_my_name }}
|
waf_id {{ caddy_my_name }}
|
||||||
}
|
}
|
||||||
{% if site.log_to_file | default(caddy_sites_defaults.log_to_file) %}
|
{% if caddy_log_to_file %}
|
||||||
output file {{ caddy_log_dir }}/site_{{ site.id }}.log
|
output file {{ caddy_log_dir }}/site_{{ site.id }}.log
|
||||||
{% else %}
|
{% else %}
|
||||||
output stdout
|
output stdout
|
||||||
|
|||||||
@@ -1,16 +1,9 @@
|
|||||||
# Sites default parameter values
|
# Sites default parameter values
|
||||||
caddy_global_sites_defaults:
|
caddy_global_sites_defaults:
|
||||||
|
|
||||||
# Site settings
|
# Site aliases
|
||||||
|
site_aliases_redirect: true
|
||||||
site_aliases: []
|
site_aliases: []
|
||||||
site_redirect_from_aliases: true
|
|
||||||
|
|
||||||
# Log settings
|
|
||||||
# If log_to_file is true, logs will go:
|
|
||||||
# - for each site, in: /var/log/<caddy_my_name>/site_<site id>.log
|
|
||||||
# - for WAF logs (Coraza), in /var/log/<caddy_my_name>/waf.log
|
|
||||||
log_to_file: false
|
|
||||||
log_format: "json"
|
|
||||||
|
|
||||||
# Proxy settings
|
# Proxy settings
|
||||||
# See: https://caddyserver.com/docs/caddyfile/directives/reverse_proxy#lb_policy
|
# See: https://caddyserver.com/docs/caddyfile/directives/reverse_proxy#lb_policy
|
||||||
@@ -90,6 +83,9 @@ caddy_global_sites_defaults:
|
|||||||
- "Content-Length"
|
- "Content-Length"
|
||||||
- "Content-Range"
|
- "Content-Range"
|
||||||
|
|
||||||
|
# Security headers
|
||||||
|
header: true
|
||||||
|
|
||||||
# Security headers
|
# Security headers
|
||||||
header_content_security_policy:
|
header_content_security_policy:
|
||||||
|
|
||||||
@@ -272,19 +268,19 @@ caddy_global_sites_defaults:
|
|||||||
value: "🍷"
|
value: "🍷"
|
||||||
|
|
||||||
# caddy-ratelimit
|
# caddy-ratelimit
|
||||||
rate_limit: true
|
rate_limit: "{{ caddy_ratelimit }}"
|
||||||
rate_limit_events: 1000
|
rate_limit_events: 1000
|
||||||
rate_limit_window: "1m"
|
rate_limit_window: "1m"
|
||||||
|
|
||||||
# steffenbusch/caddy-bot-barrier
|
# steffenbusch/caddy-bot-barrier
|
||||||
bot_barrier: false
|
bot_barrier: "{{ caddy_bot_barrier }}"
|
||||||
bot_barrier_secret: null # Required
|
bot_barrier_secret: null # Required
|
||||||
bot_barrier_complexity: 18
|
bot_barrier_complexity: 18
|
||||||
bot_barrier_valid_for: "60m"
|
bot_barrier_valid_for: "60m"
|
||||||
|
|
||||||
# corazawaf/coraza-caddy
|
# corazawaf/coraza-caddy
|
||||||
crs: true
|
crs: true
|
||||||
crs_version: "4.22.0"
|
crs_version: "4.24.1"
|
||||||
crs_log_only: false
|
crs_log_only: false
|
||||||
crs_plugins: []
|
crs_plugins: []
|
||||||
crs_exceptions:
|
crs_exceptions:
|
||||||
@@ -469,3 +465,5 @@ caddy_global_sites_defaults:
|
|||||||
geoip: false
|
geoip: false
|
||||||
geoip_debug: false
|
geoip_debug: false
|
||||||
geoip_filter_expression: '{geoip2.country_code} == "UNK"'
|
geoip_filter_expression: '{geoip2.country_code} == "UNK"'
|
||||||
|
|
||||||
|
crowdsec: "{{ caddy_crowdsec }}"
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
|
common_search_strings: []
|
||||||
common_default_packages: []
|
common_default_packages: []
|
||||||
common_proxy_server: null
|
common_proxy_server: null
|
||||||
|
|||||||
4
seb4itik/byow/roles/common/handlers/main.yml
Normal file
4
seb4itik/byow/roles/common/handlers/main.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
- name: Restart systemd-resolved
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: "systemd-resolved"
|
||||||
|
state: "restarted"
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
|
- name: Setup hosts file
|
||||||
|
ansible.builtin.include_tasks: "setup_hosts.yml"
|
||||||
|
|
||||||
|
- name: Setup resolved
|
||||||
|
ansible.builtin.include_tasks: "setup_resolved.yml"
|
||||||
|
|
||||||
- name: Setup proxy client
|
- name: Setup proxy client
|
||||||
when: "common_proxy_server != None"
|
|
||||||
ansible.builtin.include_tasks: "setup_proxy_client.yml"
|
ansible.builtin.include_tasks: "setup_proxy_client.yml"
|
||||||
|
|
||||||
- name: Setup packages
|
- name: Setup packages
|
||||||
when: "common_default_packages | length > 0"
|
|
||||||
ansible.builtin.include_tasks: "setup_packages.yml"
|
ansible.builtin.include_tasks: "setup_packages.yml"
|
||||||
|
|||||||
25
seb4itik/byow/roles/common/tasks/setup_hosts.yml
Normal file
25
seb4itik/byow/roles/common/tasks/setup_hosts.yml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
- name: Check if /etc/cloud/cloud.cfg exists
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "/etc/cloud/cloud.cfg"
|
||||||
|
register: common_out_cloud_cfg
|
||||||
|
|
||||||
|
- name: Disable /etc/hosts management by cloud-init
|
||||||
|
when: "common_out_cloud_cfg.stat.exists"
|
||||||
|
block:
|
||||||
|
- name: Disable /etc/hosts management by cloud-init (manage_etc_hosts)
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: "/etc/cloud/cloud.cfg"
|
||||||
|
search_string: 'manage_etc_hosts:'
|
||||||
|
line: "manage_etc_hosts: false"
|
||||||
|
insertafter: "preserve_hostname:"
|
||||||
|
- name: Disable /etc/hosts management by cloud-init (update_etc_hosts)
|
||||||
|
ansible.builtin.replace:
|
||||||
|
path: "/etc/cloud/cloud.cfg"
|
||||||
|
regexp: '^([^#]*update_etc_hosts.*)$'
|
||||||
|
replace: '# \\1'
|
||||||
|
|
||||||
|
- name: Configure /etc/hosts file
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: "templates/hosts"
|
||||||
|
dest: "/etc/hosts"
|
||||||
|
mode: "0644"
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
upgrade: "safe"
|
upgrade: "safe"
|
||||||
|
|
||||||
- name: Install default packages
|
- name: Install default packages
|
||||||
|
when: "common_default_packages | length > 0"
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name: "{{ common_default_packages }}"
|
name: "{{ common_default_packages }}"
|
||||||
autoclean: true
|
autoclean: true
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
- name: Create 00proxy.conf file
|
- name: Create 00proxy.conf file
|
||||||
|
when: "common_proxy_server != None"
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: "templates/apt_proxy.conf"
|
src: "templates/apt_proxy.conf"
|
||||||
dest: "/etc/apt/apt.conf.d/00proxy.conf"
|
dest: "/etc/apt/apt.conf.d/00proxy.conf"
|
||||||
@@ -7,6 +8,7 @@
|
|||||||
group: "root"
|
group: "root"
|
||||||
|
|
||||||
- name: Add http_proxy and https_proxy variable to file /etc/environment
|
- name: Add http_proxy and https_proxy variable to file /etc/environment
|
||||||
|
when: "common_proxy_server != None"
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "/etc/environment"
|
path: "/etc/environment"
|
||||||
regexp: '^{{ item.key }}='
|
regexp: '^{{ item.key }}='
|
||||||
|
|||||||
8
seb4itik/byow/roles/common/tasks/setup_resolved.yml
Normal file
8
seb4itik/byow/roles/common/tasks/setup_resolved.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
- name: Add multipass in search domains
|
||||||
|
when: "common_search_domains | length > 0"
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: "/etc/systemd/resolved.conf"
|
||||||
|
search_string: 'Domains='
|
||||||
|
line: "Domains={{ common_search_domains | join(' ') }}"
|
||||||
|
notify:
|
||||||
|
- "Restart systemd-resolved"
|
||||||
9
seb4itik/byow/roles/common/templates/hosts
Normal file
9
seb4itik/byow/roles/common/templates/hosts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
127.0.0.1 localhost
|
||||||
|
{{ ansible_default_ipv4.address }} {{ ansible_fqdn }} {{ ansible_hostname }}
|
||||||
|
|
||||||
|
# The following lines are desirable for IPv6 capable hosts
|
||||||
|
::1 ip6-localhost ip6-loopback
|
||||||
|
fe00::0 ip6-localnet
|
||||||
|
ff00::0 ip6-mcastprefix
|
||||||
|
ff02::1 ip6-allnodes
|
||||||
|
ff02::2 ip6-allrouters
|
||||||
@@ -18,6 +18,12 @@
|
|||||||
notify:
|
notify:
|
||||||
- "Restart Consul"
|
- "Restart Consul"
|
||||||
|
|
||||||
|
- name: Link consul
|
||||||
|
ansible.builtin.file:
|
||||||
|
src: "/usr/local/consul-{{ consul_version }}/consul"
|
||||||
|
dest: "/usr/local/sbin/consul"
|
||||||
|
state: "link"
|
||||||
|
|
||||||
- name: Create Consul system group
|
- name: Create Consul system group
|
||||||
ansible.builtin.group:
|
ansible.builtin.group:
|
||||||
name: "consul"
|
name: "consul"
|
||||||
|
|||||||
5
seb4itik/byow/roles/crowdsec/README.md
Normal file
5
seb4itik/byow/roles/crowdsec/README.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# BYOW - Build Your Own WAF
|
||||||
|
|
||||||
|
A WAF _à la carte_.
|
||||||
|
|
||||||
|
## CrowdSec
|
||||||
4
seb4itik/byow/roles/crowdsec/defaults/main.yml
Normal file
4
seb4itik/byow/roles/crowdsec/defaults/main.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
crowdsec_collections: []
|
||||||
|
crowdsec_bouncers: []
|
||||||
|
# - name: <name>
|
||||||
|
# key: <LAPI key>
|
||||||
4
seb4itik/byow/roles/crowdsec/handlers/main.yml
Normal file
4
seb4itik/byow/roles/crowdsec/handlers/main.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
- name: Restart Crowdsec Securiy Engine
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: "crowdsec"
|
||||||
|
state: "restarted"
|
||||||
71
seb4itik/byow/roles/crowdsec/tasks/main.yml
Normal file
71
seb4itik/byow/roles/crowdsec/tasks/main.yml
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
# FIXME: cluster
|
||||||
|
# FIXME: BdD PostgreSQL
|
||||||
|
# FIXME: sudo cscli console enroll cmmszy92r000402l1kugvmw76
|
||||||
|
# FIXME: AppSec
|
||||||
|
|
||||||
|
- name: Add Crowdsec repository
|
||||||
|
ansible.builtin.deb822_repository:
|
||||||
|
name: "crowdsec"
|
||||||
|
uris: "https://packagecloud.io/crowdsec/crowdsec/any/"
|
||||||
|
suites: "any"
|
||||||
|
components: "main"
|
||||||
|
signed_by: "https://packagecloud.io/crowdsec/crowdsec/gpgkey"
|
||||||
|
|
||||||
|
- name: Install Crowdsec Security Engine
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name:
|
||||||
|
- "crowdsec"
|
||||||
|
- "jq"
|
||||||
|
update_cache: true
|
||||||
|
notify:
|
||||||
|
- "Restart Crowdsec Securiy Engine"
|
||||||
|
|
||||||
|
- name: Configure Crowdsec
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: "templates/config.yaml"
|
||||||
|
dest: "/etc/crowdsec/config.yaml"
|
||||||
|
mode: "0600"
|
||||||
|
notify:
|
||||||
|
- "Restart Crowdsec Securiy Engine"
|
||||||
|
|
||||||
|
- name: Enable and start Crowdsec Securiy Engine
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: "crowdsec"
|
||||||
|
state: "started"
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
- name: Get collections list
|
||||||
|
ansible.builtin.shell:
|
||||||
|
executable: "/usr/bin/bash"
|
||||||
|
cmd: |
|
||||||
|
set -o pipefail
|
||||||
|
cscli collection list --output=json |jq -r '.collections[] |.name'
|
||||||
|
register: "crowdsec_out_list_collections"
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Install collections
|
||||||
|
loop: "{{ crowdsec_collections }}"
|
||||||
|
when: "item not in crowdsec_out_list_collections.stdout_lines"
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: "cscli collections install {{ item }}"
|
||||||
|
changed_when: true
|
||||||
|
notify:
|
||||||
|
- "Restart Crowdsec Securiy Engine"
|
||||||
|
|
||||||
|
- name: Get bouncers list
|
||||||
|
ansible.builtin.shell:
|
||||||
|
executable: "/usr/bin/bash"
|
||||||
|
cmd: |
|
||||||
|
set -o pipefail
|
||||||
|
cscli bouncers list --output=json |jq -r '.[] |.name'
|
||||||
|
register: "crowdsec_out_list_bouncers"
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Create bouncers API keys
|
||||||
|
loop: "{{ crowdsec_bouncers }}"
|
||||||
|
when: "item.name not in crowdsec_out_list_bouncers.stdout_lines"
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: "cscli bouncers add {{ item.name }} --key '{{ item.key }}'"
|
||||||
|
changed_when: true
|
||||||
|
notify:
|
||||||
|
- "Restart Crowdsec Securiy Engine"
|
||||||
66
seb4itik/byow/roles/crowdsec/templates/config.yaml
Normal file
66
seb4itik/byow/roles/crowdsec/templates/config.yaml
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
common:
|
||||||
|
daemonize: true
|
||||||
|
log_media: "file"
|
||||||
|
log_level: "info"
|
||||||
|
log_dir: "/var/log/"
|
||||||
|
log_max_size: 20
|
||||||
|
compress_logs: true
|
||||||
|
log_max_files: 10
|
||||||
|
|
||||||
|
config_paths:
|
||||||
|
config_dir: "/etc/crowdsec/"
|
||||||
|
data_dir: "/var/lib/crowdsec/data/"
|
||||||
|
simulation_path: "/etc/crowdsec/simulation.yaml"
|
||||||
|
hub_dir: "/etc/crowdsec/hub/"
|
||||||
|
index_path: "/etc/crowdsec/hub/.index.json"
|
||||||
|
notification_dir: "/etc/crowdsec/notifications/"
|
||||||
|
plugin_dir: "/usr/lib/crowdsec/plugins/"
|
||||||
|
|
||||||
|
crowdsec_service:
|
||||||
|
#console_context_path: "/etc/crowdsec/console/context.yaml"
|
||||||
|
#acquisition_path: "/etc/crowdsec/acquis.yaml"
|
||||||
|
acquisition_dir: "/etc/crowdsec/acquis.d"
|
||||||
|
parser_routines: 1
|
||||||
|
|
||||||
|
cscli:
|
||||||
|
output: "human"
|
||||||
|
color: "auto"
|
||||||
|
|
||||||
|
db_config:
|
||||||
|
log_level: "info"
|
||||||
|
type: "sqlite"
|
||||||
|
db_path: "/var/lib/crowdsec/data/crowdsec.db"
|
||||||
|
#max_open_conns: 100
|
||||||
|
#user:
|
||||||
|
#password:
|
||||||
|
#db_name:
|
||||||
|
#host:
|
||||||
|
#port:
|
||||||
|
flush:
|
||||||
|
max_items: 5000
|
||||||
|
max_age: "7d"
|
||||||
|
|
||||||
|
plugin_config:
|
||||||
|
user: "nobody"
|
||||||
|
group: "nogroup"
|
||||||
|
|
||||||
|
api:
|
||||||
|
client:
|
||||||
|
insecure_skip_verify: false
|
||||||
|
credentials_path: "/etc/crowdsec/local_api_credentials.yaml"
|
||||||
|
server:
|
||||||
|
log_level: "info"
|
||||||
|
listen_uri: "127.0.0.1:8080"
|
||||||
|
profiles_path: "/etc/crowdsec/profiles.yaml"
|
||||||
|
console_path: "/etc/crowdsec/console.yaml"
|
||||||
|
online_client: # Central API credentials (to push signals and receive bad IPs)
|
||||||
|
credentials_path: "/etc/crowdsec/online_api_credentials.yaml"
|
||||||
|
trusted_ips: # IP ranges, or IPs which can have admin API access
|
||||||
|
- "127.0.0.1"
|
||||||
|
- "::1"
|
||||||
|
# tls:
|
||||||
|
# cert_file: "/etc/crowdsec/ssl/cert.pem"
|
||||||
|
# key_file: "/etc/crowdsec/ssl/key.pem"
|
||||||
|
|
||||||
|
prometheus:
|
||||||
|
enabled: false
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
- name: Installation de MySQL
|
- name: Installation de MySQL
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name:
|
name:
|
||||||
- "mysql-server"
|
- "{{ mysql_distros[ansible_distribution].mysql_package }}"
|
||||||
- "python3-pymysql"
|
- "python3-pymysql"
|
||||||
notify:
|
notify:
|
||||||
- "Restart MySQL"
|
- "Restart MySQL"
|
||||||
|
|
||||||
- name: Set MySQL bind_address parameter
|
- name: Set MySQL bind_address parameter
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "/etc/mysql/mysql.conf.d/mysqld.cnf"
|
path: "{{ mysql_distros[ansible_distribution].mysql_config_file }}"
|
||||||
regexp: "^bind-address\\s+="
|
regexp: "^bind-address\\s+="
|
||||||
line: "bind-address = *"
|
line: "bind-address = *"
|
||||||
notify:
|
notify:
|
||||||
|
|||||||
7
seb4itik/byow/roles/mysql/vars/main.yml
Normal file
7
seb4itik/byow/roles/mysql/vars/main.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
mysql_distros:
|
||||||
|
Debian:
|
||||||
|
mysql_package: "default-mysql-server"
|
||||||
|
mysql_config_file: "/etc/mysql/mariadb.conf.d/50-server.cnf"
|
||||||
|
Ubuntu:
|
||||||
|
mysql_package: "mysql-server"
|
||||||
|
mysql_config_file: "/etc/mysql/mysql.conf.d/mysqld.cnf"
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
# FIXME: Wait for DB to be ready
|
||||||
|
|
||||||
- name: Téléchargement de Wordpress
|
- name: Téléchargement de Wordpress
|
||||||
become: true
|
become: true
|
||||||
become_user: "{{ wordpress_user }}"
|
become_user: "{{ wordpress_user }}"
|
||||||
@@ -118,7 +120,7 @@
|
|||||||
state: "directory"
|
state: "directory"
|
||||||
owner: "{{ wordpress_user }}"
|
owner: "{{ wordpress_user }}"
|
||||||
group: "www-data"
|
group: "www-data"
|
||||||
mode: "0750"
|
mode: "0775"
|
||||||
|
|
||||||
- name: Apply permissions
|
- name: Apply permissions
|
||||||
loop:
|
loop:
|
||||||
|
|||||||
Reference in New Issue
Block a user