Compare commits
114 Commits
8f50b7756b
...
debian13
| Author | SHA1 | Date | |
|---|---|---|---|
|
43dad7c261
|
|||
|
8439b674dd
|
|||
|
c2c9f1b88d
|
|||
|
3763ce80e1
|
|||
|
a8e4821ad0
|
|||
|
6ff4cf30f7
|
|||
|
8f57a5a974
|
|||
|
cac74c53ef
|
|||
|
078c5b36d8
|
|||
|
a18c1e6a16
|
|||
|
36cf98026b
|
|||
|
98746b3eb8
|
|||
|
afffd87201
|
|||
|
d21f3d9371
|
|||
|
a6ef7a1c4e
|
|||
|
602734acce
|
|||
|
0db7911b70
|
|||
|
ee4c62e5f9
|
|||
|
a315db8a7c
|
|||
|
5f00892df3
|
|||
|
9357265d27
|
|||
|
dd62266340
|
|||
|
a1bec20824
|
|||
|
8e91c44529
|
|||
|
02d4135c79
|
|||
|
37e148d009
|
|||
|
73dbbd23b6
|
|||
|
b84283aa38
|
|||
|
1695fdf8d1
|
|||
|
9f1f7b1c69
|
|||
|
7d725f2084
|
|||
|
4c39b0d48c
|
|||
|
f4023d0b20
|
|||
|
6aaface4a2
|
|||
|
333e1cbeb9
|
|||
|
0c62f4bdf0
|
|||
|
26f22c0447
|
|||
|
05881e2585
|
|||
|
d4d326c2f7
|
|||
|
1d4a6f208b
|
|||
|
8b22076d4a
|
|||
|
38176cb34c
|
|||
|
da737b71f7
|
|||
|
c28189a1a5
|
|||
|
b600141e89
|
|||
|
4be98d1a33
|
|||
|
2bb018a40c
|
|||
|
89a1e11b7a
|
|||
|
0c0cad9084
|
|||
|
9dce701a19
|
|||
|
3e9ee44d5b
|
|||
|
599b5e5e83
|
|||
|
bc700ea532
|
|||
|
8016701b57
|
|||
|
00558c7dea
|
|||
|
c927186837
|
|||
|
690774c862
|
|||
|
cc021bd14a
|
|||
|
73fd06fe3a
|
|||
|
88cb3a370e
|
|||
|
027a43ddbe
|
|||
|
bb30c3be20
|
|||
|
d8d9790d21
|
|||
|
9a500ebc0d
|
|||
|
4bae942585
|
|||
|
99866c0c90
|
|||
|
0afb8a4493
|
|||
|
506695da31
|
|||
|
f67ed7762c
|
|||
|
014f4d9502
|
|||
|
22c16e1ed3
|
|||
|
5aa6a33e51
|
|||
|
7f9b06af9c
|
|||
|
84db337fea
|
|||
|
7b23f5f94f
|
|||
|
9830338be3
|
|||
|
e3eed26765
|
|||
|
8b31c7e148
|
|||
|
3ff8043aaf
|
|||
|
cb79f7ef70
|
|||
|
bb14f05d2a
|
|||
|
5b1530fa91
|
|||
|
5312dc6bd5
|
|||
|
d6e060d3af
|
|||
|
b873af004a
|
|||
|
7ea3ab46f8
|
|||
|
0561bd5b52
|
|||
|
d62572f02c
|
|||
|
2ffe5e87d9
|
|||
|
38d4f1a303
|
|||
|
ed8cb88038
|
|||
|
c31e447861
|
|||
|
545684467c
|
|||
|
24ae5eaab1
|
|||
|
dac23f1427
|
|||
|
41fbc73dd1
|
|||
|
fee794bcf0
|
|||
|
8bce1d8b1b
|
|||
|
6dc2ea36b6
|
|||
|
af71a9b5f8
|
|||
|
4dd57803e2
|
|||
|
18d4245fc0
|
|||
|
1bddf3cccd
|
|||
|
20dbe61fe1
|
|||
|
899e87321b
|
|||
|
06416a3b64
|
|||
|
7a9a24ef5d
|
|||
|
067adcd9f5
|
|||
|
84d210cfab
|
|||
|
17736a4f14
|
|||
|
b9e91c4a3d
|
|||
|
51c95e5d4c
|
|||
|
8dbec29d2a
|
|||
|
d3bf3dab04
|
2
Pipfile
2
Pipfile
@@ -10,4 +10,4 @@ ansible = "*"
|
|||||||
ansible-lint = "*"
|
ansible-lint = "*"
|
||||||
|
|
||||||
[requires]
|
[requires]
|
||||||
python_version = "3.10"
|
python_version = "3.13"
|
||||||
|
|||||||
1210
Pipfile.lock
generated
1210
Pipfile.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@ Ansible playbook for base and initial configuration of the web server hosting my
|
|||||||
## Assumptions
|
## Assumptions
|
||||||
Before you can run this, a few things are assumed:
|
Before you can run this, a few things are assumed:
|
||||||
|
|
||||||
- You have a clean, minimal Ubuntu 20.04 or Debian 11/12 host up and running
|
- You have a clean, minimal Debian 12 host up and running
|
||||||
- Python 3 is installed on the remote server (requirement of Ansible)
|
- Python 3 is installed on the remote server (requirement of Ansible)
|
||||||
- You have a user account with password-less SSH access to the machine
|
- You have a user account with password-less SSH access to the machine
|
||||||
- You have sudo privileges on the remote host
|
- You have sudo privileges on the remote host
|
||||||
|
|||||||
@@ -13,12 +13,6 @@ interpreter_python=auto
|
|||||||
# See: https://docs.ansible.com/ansible/latest/user_guide/connection_details.html#managing-host-key-checking
|
# See: https://docs.ansible.com/ansible/latest/user_guide/connection_details.html#managing-host-key-checking
|
||||||
host_key_checking = False
|
host_key_checking = False
|
||||||
|
|
||||||
ansible_managed = This file is managed by Ansible.%n
|
|
||||||
template: {file}
|
|
||||||
date: %Y-%m-%d %H:%M:%S
|
|
||||||
user: {uid}
|
|
||||||
host: {host}
|
|
||||||
|
|
||||||
[privilege_escalation]
|
[privilege_escalation]
|
||||||
# instead of using -K
|
# instead of using -K
|
||||||
become_ask_pass=True
|
become_ask_pass=True
|
||||||
|
|||||||
@@ -3,4 +3,12 @@
|
|||||||
|
|
||||||
tls_cipher_suite: "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384"
|
tls_cipher_suite: "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384"
|
||||||
|
|
||||||
|
ansible_managed: |-
|
||||||
|
This file is managed by Ansible.
|
||||||
|
|
||||||
|
{{ 'template: ' + template_path }}
|
||||||
|
{{ 'date: ' + (template_mtime | string) }}
|
||||||
|
{{ 'user: ' + template_uid }}
|
||||||
|
{{ 'host: ' + template_host }}
|
||||||
|
|
||||||
# vim: set ts=2 sw=2:
|
# vim: set ts=2 sw=2:
|
||||||
|
|||||||
@@ -8,4 +8,7 @@ webserver: nginx
|
|||||||
extra_fail2ban_filters:
|
extra_fail2ban_filters:
|
||||||
- nginx
|
- nginx
|
||||||
|
|
||||||
|
# root prefix for all web servers
|
||||||
|
web_root_prefix: /var/www
|
||||||
|
|
||||||
# vim: set ts=2 sw=2:
|
# vim: set ts=2 sw=2:
|
||||||
|
|||||||
@@ -1,88 +0,0 @@
|
|||||||
$ANSIBLE_VAULT;1.1;AES256
|
|
||||||
30626135313830363339656165316536336564353362383439346465373932326136363337343762
|
|
||||||
3566343231306635313739303335616162396232303139620a323764663132323135663063393334
|
|
||||||
62656434643333663062356266626235363439393231333734343432333363643934393636373935
|
|
||||||
6332353333303231370a373839636135363730636539326335343533316633623366663230353262
|
|
||||||
37396264313763366438663139376638613337336634393665663032623035646631653564353966
|
|
||||||
30353165333638363864656531396165363430653438376465656233306639353336353237343532
|
|
||||||
62363330333662316630656662633333626462363062366637386163336230386634353933316238
|
|
||||||
36373365323735373435616262613933333964323033633233333766396362616534316166386432
|
|
||||||
31333831353130616166633735366131653137363361313333363763623364303435346338643838
|
|
||||||
63323831616135643830653839323663386239343430356437346665343937306666333836363163
|
|
||||||
37386663616136653861663530383865343930306263663366633438363332336561326330353235
|
|
||||||
64613332643962323930323436393934636263396239366364306136303437323739343237656263
|
|
||||||
33613964363139363862396235636435626432326432663166633765613635666165363165663539
|
|
||||||
62366232316632356233326564633737643466343535656564653833623766373637313833373331
|
|
||||||
38356336396461666535386363633437376232396330623162333936366434376361326261343336
|
|
||||||
35396237346663646334306663306633383061353333643639613335643661633835313732353963
|
|
||||||
64623234373033656366613566363639663762646663396462323361363463373961383530653962
|
|
||||||
61613962316336653266383638393630323338383161303565333862633932646463313134613232
|
|
||||||
31326262336561383066633430383833353835373363623163303830663837313265663662313862
|
|
||||||
39353062333234663631653565613135396337626664626264366534633566386236393562303861
|
|
||||||
66316335343638356261396339353932633331356363343231363862333066366438323764633331
|
|
||||||
39316236343262666337303839356138666338306130323462646633373464646163613734366132
|
|
||||||
37623739333435396266316131383238323365646632636339353631376166613532386133393165
|
|
||||||
64633933393062623230346430653961646366316662356336646162313466393964323332616431
|
|
||||||
34336562343337636138616431313736613539373137303666666435373238346233383438383963
|
|
||||||
39346138393635626263376137643436393736636435393234646439353932386136653034393961
|
|
||||||
65336230356336386539386334653236303964623632323738383333623361643235656530363731
|
|
||||||
39306538353533663538366362613739386463336632653665636533616462363530636466626165
|
|
||||||
32623762616266623231393938663931306231626139663736613862363234643861366563633532
|
|
||||||
31393934333433316138323131373836306135333061363231363461643933303836633231343266
|
|
||||||
37323732383036326664376438343261333733636532303664613965353561376337633564373062
|
|
||||||
64316133333263393138333261323062626363343765393161363935386232353862353762626334
|
|
||||||
31346661303239383832343637376663316537353938346534306134626534363438386162653133
|
|
||||||
66616237663864633837356132663139633734303532653637366138386534653462323163313836
|
|
||||||
34633337643661656465653839316362633236633833646632393930656136313730646566316537
|
|
||||||
39653935633636363635386435373062333031356363633661366530616537356533323133366339
|
|
||||||
34336139323138336532313833633364363566613833636339396462326530313961613133613761
|
|
||||||
63356231313363303862663032373663626262646565353933663963363633363663373238656632
|
|
||||||
31393264333732366565376164623766663162386365356233383132303835643932386436333631
|
|
||||||
65663334336434663562326238326338376662303339616233616464313139363864623463613761
|
|
||||||
36326235396433633435366263393964383936616433653861326431343133346435663832363437
|
|
||||||
33333232636536363863373037616436313335393639393966653062303330366463323861376661
|
|
||||||
39383665316665303363636331373461623339323031393333323465313733336236303037313132
|
|
||||||
37613163373432316132306235343061393530366237626134323431323836316261326237323965
|
|
||||||
33643662663361356164653430323566666230656561633434333538303365663334373537306164
|
|
||||||
65633264323836656537623766316533386564663765376661663537303835393438623430343263
|
|
||||||
64353031633436343938383263313439383033326532313466653766616164653463333434353664
|
|
||||||
30653034353632373561346565616631656235323637333562613538663538363936663464383064
|
|
||||||
31336365613037626331363731376663653537613639313839303934633462666430306635613434
|
|
||||||
65333736653430363936663566666535346231383563366630653535313038383964326630616264
|
|
||||||
63616563356361313439303833646438386163313865356634636536336661626664316163333739
|
|
||||||
63303465643861656362386530353363383836396534373461663630636461633336333862353830
|
|
||||||
38666536353663386466313066376562383366643062343965386132666435376433626165353735
|
|
||||||
61666432613133646130373839336261333565303532643164306264633736346637373835393266
|
|
||||||
33306133346531333835303238393361663463346162636161646565313266616133623735653838
|
|
||||||
62396531313634343936363861373031383830636538376334316161326364303930383435653936
|
|
||||||
36653233343935646337376232396638343033613130663563326135633231636362373162623565
|
|
||||||
39323762623966393332376235643666383461356263346332663939616235346564636233333463
|
|
||||||
35356161616536613939313436616233386563343764643335653961643366656632646338313536
|
|
||||||
35323732333539326239386436306230646230663336623566633763383534626162386463613961
|
|
||||||
62353737363435653866383633343830356536633462373636323734656231636466336235306162
|
|
||||||
62666133656166633838363262613930396236393862306438316135643131393737363531373631
|
|
||||||
31626635613233313063326463663738393632373135373632323731396332323138633962356364
|
|
||||||
39396565393038623532313230383539656564383134363161393663373539393837313335303636
|
|
||||||
38626138613932643265643231366364373964623436663566623838643939323331646661653435
|
|
||||||
37373765393736303861346164373938393532636637353737326539333435666562643664363365
|
|
||||||
65646662626630663238336264663665663762666439626336376434386436653965363832346339
|
|
||||||
30396630343430323762666232366336376563616430643136336630373864623132386465393761
|
|
||||||
66396439346563393539616335383562633237353962383033356230323339353336343964366134
|
|
||||||
38623661326336376561633937613565386164656462313863336339643733663834373732643266
|
|
||||||
61666438666635656236376239393433306239613936613731636235353638396432326438396432
|
|
||||||
63333237333633333761666630663339613232313136316232346234363562333937363463333137
|
|
||||||
39653336343732303536616662643961623932643330653936343337316135366535363964616439
|
|
||||||
37376433326332386339363961656537326632333830346435353234333661636434343730356139
|
|
||||||
37346131303930306364623334313335323563333631653539383637376433623439386564633035
|
|
||||||
38346436376661333233663334623762646633346530643466336664386134353662363430316438
|
|
||||||
63393333333034623537303030353136633035353865383366613961373766646463366131623564
|
|
||||||
34646630666233333834383761363566373935333037633666336261313566613762616531653739
|
|
||||||
34643162323438646165643433333438656664383232376233306233623539366233633337663565
|
|
||||||
35323636633533343064376434666435666564666134343839653630326236343262633431326133
|
|
||||||
36663432396666306631613162643065313135373332303863326234356537366436333938303637
|
|
||||||
36636334396231316564643733646662376138313637643232373836373632643362383363363530
|
|
||||||
32363736646162303532356132373337616162636464643164323432623338363463663736373433
|
|
||||||
34343136646339376132383434623261356163393032306134633665323130623766333738656639
|
|
||||||
64306632346162396533316431343339366664333335643464386266376464393039633439653837
|
|
||||||
36303363326239316663346434613336636239653331626661393962356166383339333234376135
|
|
||||||
653361363631363366323165353538313438
|
|
||||||
276
host_vars/web22
276
host_vars/web22
@@ -1,137 +1,141 @@
|
|||||||
$ANSIBLE_VAULT;1.1;AES256
|
$ANSIBLE_VAULT;1.1;AES256
|
||||||
63356538383464316265363339393262623161313332333136363039613462393065323039333839
|
65636230346264393938656566653961393466306338353435333061356463363836616435333731
|
||||||
3437666230393631643932373532646537376132643736310a376432616165386434306637356530
|
3537316534663335343333643435383663303438333433650a666133633965643939306661383536
|
||||||
34643036663438363264346130653636623930643462343566313365393161623033663632376331
|
33626364316338306530393036653134373339653264616537623731323063646531383137333131
|
||||||
3934336365366334620a613436336239303131353165663562343865336631303433656630636266
|
6263363037613631360a343831393830646536326538363764643136613732636165316466316566
|
||||||
36366433623938643932643765393238653935623861303939326637306439313039613566396336
|
65346162383337626631663533626230643061633139663661656365333738353530316661313864
|
||||||
35666638396239356630353762356463353137393462336532643930343366336233343730656334
|
32373831396437386434313430666434363534656130613632643264393538663131336635653537
|
||||||
32373335623539333339666662633965363061613434366463613239353466333462646234643635
|
61613065336133343130353862646130386136333231393962353064666335363330623064626631
|
||||||
34383866623936396437396361363761363337326539393439663830303663643163636137656565
|
34333137363566313764343335646531326337616563366636316232633936333264373731653332
|
||||||
64633961373835373739666162643233373036656134303863316166323061663362626431323331
|
66366361643261626563633838663061303762386234336133366233356564343562323965663731
|
||||||
33643763363563373332613131363166616432376230356636623530313463636337363235626532
|
38326631333166643534313836323337663131313766306166333534336333613735643033326633
|
||||||
61343465656534623965636638303032363261613430343030656330653239656465386434383234
|
39396335613362363230333863396535343464346437366632316336626539623865313239353539
|
||||||
31636336343162616134333536373632353733373136356165313662623063306661306131646533
|
30643834633130333564666162623365323439396630333136616137633532363530623234376332
|
||||||
37626138393035613864316539396338386563333338633834356334313766346161363130313231
|
66353539306637633432353231326666643261386466633533313063353061643761313132623035
|
||||||
66336131323931633963653464636361653739623537616563663533313734343666623237333036
|
62653263636237666432336662633136653930323532623137386261333862623337326431336365
|
||||||
39616564333334366361356135353132363033323461383166663531306135626135353766343361
|
36663364386364346631393031326434326334636166663739366435616166363130623463633733
|
||||||
33393939333532363465383632353031383065353830643038303665613430313334343630616566
|
35383834326231363264623061303066326433613139333237656635643835393762313866356237
|
||||||
38663963356631613234623435636361333935613964626330636331346432663733303561336166
|
62616435613863616161376666333966323030326531323261646436633233613635383438373834
|
||||||
31633436363438373966666431366232323136356139643333393363323232363261356433353333
|
31343133326231636661353466396566656365396466343430613262316537623631376433633630
|
||||||
31336332623038323130303938356131396131386335646466366263346530616439363539306165
|
62336664346363393363306163333662323338343139646238633830326535313034613739616138
|
||||||
37343834656333343034653435323934623462333330613764336361323535663563653835643535
|
38313637333333383032316134316164363036396338306634633436633564306333336437393566
|
||||||
61386630306465353037386531353263656238333461313063626164343231303163663030363165
|
61656337343030393936353364386461643766636564333864396130343762323630393839393463
|
||||||
32653332383931653535663266393631373236643236616432303166646634363637346539626263
|
35343864393035333930313238663465663633633862623336663136626165666131383933626437
|
||||||
36396666653730333962366265663334323765623137643130653335613861313163656339663263
|
31323936653737646231363036383764333335313762356465333635303334663734636531343331
|
||||||
64303261353062376536343830353236653163386339373534323934343861323231303733303733
|
37386461643239363434373864373561353339343031346364383530663430393938333963333837
|
||||||
62393439626566373230383734396137346436623932363564383030626638643330666264306564
|
63303966366364626665303530356433643264343861346238353937386338383034356633623231
|
||||||
63656236356535613362346137653438623765656437313137666365346464326161646262346136
|
36663735386233396138306561326339626262326463336535646265666637383032396435333835
|
||||||
65636363316530346130343237383161643539616536373266343865323832343634623761616335
|
31363266666230366438313432356637663632333530646263663563373137313262663937636532
|
||||||
39626632373865313661316335336130303462383266623135646437643736616561326266396332
|
66633731333166386564386666363130633734643963653030386533393766623038383234646161
|
||||||
35663339326531626366376530326134303363343930656539326433366662393662653764323133
|
36343135663231323030306430623535373534353835623339333738376362663930343436343637
|
||||||
34643364343637383930353036613339393639363534663938623966633833346666616536616134
|
34383963306266623437323462356466336533643933653839366666393839626663353264326334
|
||||||
63643031383464663139313066656335623164636666346265396564626665653935333833353730
|
32663461663561396631363533383334363361373764363132643435373537333839613066396463
|
||||||
63393062363439303435623663363331343732656563663233366630646163323564666437346566
|
35386436326638353431363064626131306634363339653132396563356239653265303930333634
|
||||||
61303736653536663662326430366330313239353535613135663336653334316435323262396634
|
32376332643863376237383966623233323864393338346537393865363661616338333631383532
|
||||||
36313761613836353937356665346135633162653239383033613438356435313234373638656339
|
34373635316138663261633839333664353432666234306463306338653634633038373266646462
|
||||||
33366462613432346533663231313535333665646635333436343237373935373838376533363165
|
32336534356537306366656236356663616336333031306431653239343132336234626165333032
|
||||||
63303735663564333732363363393038636531653264613965666235333331623663346534366566
|
38303137666131363462363263333832356333616130346337663837376365346166306261373036
|
||||||
33333764356665363638616561656537613039626631363066316133623963626338343231616361
|
63383236323738303562623631633064363564663861336162356262373861383965623935343931
|
||||||
34373266313863663831363639663439643936303931666532653962323733366635653035646664
|
65663934623431363164356331353135633837616130363464353661663438323132363165343766
|
||||||
32666239663062316437313737346161376562663630636466623431386266363263623633373963
|
31393633306261303762613537343034316535373731363365666530623361623630633137326466
|
||||||
35666665383738656437313438303832326137343033633562666436303535613538343832613839
|
32326533313362333863383561343230626466303831623033613065363136396362373333306333
|
||||||
35383330613538383164353233336335376266343336616430303638363365613065393262356435
|
32336464356364663564626234653832323265313364343631646633396362373438666165353962
|
||||||
30346537616335316661333533363763393633616438633066316232623738366230646364353735
|
38396330333161356365626562383531323664636235643666613631636636323638376638396531
|
||||||
38386236316539343063633765386235663866323433666531613666646365376330333539376562
|
38646531666164653161353932643662363261323564373537343731666232666532633063353431
|
||||||
66653762633630366638323334393132383635373663343830653431363534353961303139373734
|
61386163363562313330393037656139303365396438313935306333656264373531373037303939
|
||||||
38346438663966363166363464393863393861643936333536343035626239326238363131343966
|
63373962356233346164383163323532373163376364623766323933623063653939346537306338
|
||||||
64646435663863303937646364616630633266326237326330323733396165663134383432343862
|
65353266656532636633326137356430666432333465626437633733356435363163626430303964
|
||||||
39666238346336353531653165313066343039653430373833323832326631386430326435646530
|
39343935623937616130326637323061373538616633393465653266656666376661393635333662
|
||||||
33343233353331626533383864303235366538663338376465316161653664386361373761376134
|
30363364653130356137393463613038663762396336306234363461396133306562323838336330
|
||||||
65333437306165346331376664646161616230316530373630383965333434313937333637393530
|
63303735646132353766313137303162366164613530303966383636393934393035306264626465
|
||||||
39373334653164646233323064623431313832313662313832613837646561373534623535656239
|
36613233376234633932663963623432663032656236323963353036356437383066373532323865
|
||||||
31663939616634613235386564333962626333616164326466656163376362346437396532616238
|
36643431373966613533646164303564653336396535343366303339303134613936656137653939
|
||||||
65656138323430633137373030376661653231303237396331333839626365376533313038316132
|
31333062623734613538333666636561386338306235633165386262383261333264623638383366
|
||||||
35623464323934616361663164323137316135326566393339316161666437343238333031633832
|
34313266333636376337393736343062363539366235393136663561303663386438333834613539
|
||||||
34356561333565623532656332353463343430336531383364383733323664383365356263393539
|
38623632656161653766363166653661336136653833336663616261663831656133666232633362
|
||||||
33666332623665343336353365396163386334613232663962663131383734353762396466313464
|
31373166306134653162313134333432323134623336666632613766386662653831643732326330
|
||||||
61396265333037636232323738373462313638663033343437376431656464636137306661636561
|
63643737333638626162646136373466613536653831663835616432343537323864343166316461
|
||||||
39646537393131613539633032616338333265386562326532636136303039383034626465373139
|
34393732353930343430356231626636373763636561343430616533663861346566326262313232
|
||||||
66636363316461643537356439303861356439656661643663653335383565616532623435383634
|
39623936366633363136353632346134643563383833376134363833336137613337326435613764
|
||||||
66313436366663656464643061643531633161626635643235633930353339386663346232366235
|
37653232613632333334316162383261383836613936376230393633343336346633386539356232
|
||||||
62386161323934343730646439353163663538633562626232323333373839363430323239366131
|
30316232373738363038356665366663623536626539376364303038643061386363636337386663
|
||||||
62343832346235643863353134636261616262386364623236643966333636323637646532333634
|
61383634336530666163346239343838326138373932383339396265653764313039653138643938
|
||||||
33643932656165383031303931383634623231663335613035316537373731323963376565333962
|
31613163653632656238376533363739346539623863623332653936643731623565613234663430
|
||||||
34363939616334326134363661633833386433373430363766383461663136376466306661386639
|
39363935306330386634363634363233376234613837353765353732646638663830323335616234
|
||||||
64343236393738326339663963396635393739623232313463333063653133343461633564393735
|
34366334636436633734333830306136333563666337623035653239313361626438316535313434
|
||||||
61353562626362383432636430343062643166353035633232613035636634383064663734633934
|
37343930643832383136343737313365316238373638323130653766646637343464653134616137
|
||||||
65633430613138643837346535623865613931383338306663633466343932393837333333313836
|
38313034383833626433326237633863313364353662326233636333333932633039396565356133
|
||||||
61346163316630353133616661346133346239623763303262373637303030336639643563646665
|
64376166383064343239633364363861616136643061646636323437376162313438396230393331
|
||||||
35646462643531356635376331303565663630356161323565333737363462666161633761623431
|
32633662323031666238643934646665303666383834336432363430363166356632353033336333
|
||||||
63666161353639393734613631396566336137333830653531643436623462316535333537666365
|
64383861663563653531643832656238643066323564656134633639666234363363363132623836
|
||||||
36643662353664383233613131643761346433356265333761326361303439326535396438613061
|
61386431643130333761376161646262346562363532353632633332343666393562313465303337
|
||||||
63633335326339323437316331613033643934323238663636636431653632363165666232363631
|
31333732626164363464323531323239333963303333626466623966346361383832353765346565
|
||||||
35363231363165306236326662656166373739373761316466353663393836336631326465646265
|
37303765363834376237636632386663373061346534643132636333623137366662646538306231
|
||||||
66363766663333333765653032366161363437383735646664633635306562323363343863643936
|
33353538623231636166653838333264396463616437396264353537633661313932353133316438
|
||||||
64656536333531393564303864386631663635613263316137653435303962313561646334383664
|
61323439363635383035316335363132383366613733383363306366356466333364633537393033
|
||||||
63623133383531303563386562633233636436323236643764646336663038363062663032313232
|
66636434623962633063306236303831633637656430376533353436613934636466363461333562
|
||||||
65643136666664306537343433393262306534356536383038323337623835326632636464656138
|
34613339373732343632343435333331353935303735633732656663643938663439656233613163
|
||||||
39613237616365303333303737333431343361303563326266663533353639623636393961363531
|
65356232633865656439643430636332386663333761376638323630373930663837653638363963
|
||||||
33393737643062373365633431613564383962616337666631376264356431633035303665626136
|
63656437323138633664613166353537306466666261353532326363346332343363343035386435
|
||||||
30373731383361333035356138626162656238373337613334343739383064666133383432646665
|
33326238333730303539363265383761663862313961383030326263353034303866626661623334
|
||||||
65396466663762613036346137636538336130326334656634656238656664343431363365376664
|
61623365373332366333376630626539343835663466666534636561643736646537646431386631
|
||||||
63386264313665363464623335343862353432366336393032666434363131656339326632316538
|
36366132663830336234613065626262336564316339383038333330323237363665373935326438
|
||||||
63363864373462303136323133383136653732343639343964376137613337353934353061303966
|
38646335346239316432636138633365373062663564326465643032633438306230363434323262
|
||||||
30363433333631306432316462393137636361393535303938646662306263636639663637313037
|
34313932653361346261623030623739313665356464373666346361663430336362383063666134
|
||||||
63616363366139303036353633663031353366373462303234343264643136393736623735393966
|
38323539653437623030333437373231646634333563306165393231653465313731633536323362
|
||||||
32636131633065383530316336663463653134323566633262666635303831343035333433623235
|
65613262633563653031306139383436663834616339316164393365336437653730393331636464
|
||||||
37616331366263643231383264386336316264343531663736383736643235376532363736323637
|
32313537313164386164313832396566353137376239303663656130383336336634313235376363
|
||||||
62343831636636663137313032303837663331633135633632366337386161633631393438653862
|
63326530333339356432343938306465623636336161363133613864336339393635306234656263
|
||||||
64326161626131646536313830383166613163373134623532663164656265306138313766313438
|
34343437336461303831393562653934633439336562663366643066393439396531653663386531
|
||||||
61376635326165366335393730343736366536623566373866363730626434343931636531343166
|
65623061643064396534353364663633653331653535306133386466356236623239646432373066
|
||||||
34383830396530393631326135386262323037303162343665663339616266343565363433363630
|
61313261366466663866613162323939646534653561356335393237376138633930663364636236
|
||||||
31656238383533366333376463303538646538333735306435326565303833353333636439626438
|
36613834303338646530663565303438363831663865323531386635303239646464343936303832
|
||||||
62343232303863663733623231633439613333313336303733373032613862363736336137663935
|
31323531363263333830623838666437636262306164386236643032356165323037656630383739
|
||||||
37373230356234636438303966323934633530396335653463333137366533333930343236666336
|
65666333656639333263346465666463616534353835656337353464336134303732323037393538
|
||||||
35333030623835376635353936343437653563383031663133663264366530303830376336373731
|
37366263656133643039373438636537343636663065646534616339303833666532396633616565
|
||||||
37326334616538623931346462623130333165643232386566356366313431393736633765396334
|
38353139323739656564623065613364346164633863343738633163383031663531663365616534
|
||||||
39376564323431303630363836613963323532386234656431363165393439373532613139373734
|
31663835323435643463666264623932396133336531626331303862356261306238326333366164
|
||||||
61363434633363356165616664316336373335383030393732306432633765326161313934343038
|
66306262386137363432376530366432356432653333393833376532623333373337393830316263
|
||||||
33323065356539633761643032383132656466646235623131663830346535613130313964373033
|
30326531613662313430663130613734663937613663353936346134356537393761373238393433
|
||||||
34343134666463633135313036323237386235616636613237376630303536376166303137653534
|
37356136393731626561303430626339386531386333386536656465646232633934393630613339
|
||||||
38316238366665653166613937623465376332386238643066643161363666303338386366323164
|
61333163613862346564316336353766346461626639303661353464633835626663313462613666
|
||||||
64663531383162373865623063396562336639393837623062356631303266643533346232613234
|
33343561613662303036643937656431393432333831383461323631393262346464393539353537
|
||||||
62623430346165373139343562373463623166623138396435616234623961656663633163626466
|
33633364383261663535323136393138333739356439663731636136393530323864333566323361
|
||||||
31663061666630653664356463336363383462343766616162313866623734376337346533623762
|
62643961323264336662316661303630636430323838633535343036303437393439656637326566
|
||||||
32643330393161633262333230363366613837386138636536316665656435383336373835393039
|
34363832366434316639393939313965633037653931323462363465643262653539623063326432
|
||||||
62363436663435633462633761396439306264666638636230383038396635393037353134306566
|
36616434366432303235663062663138623336336165373734353838333662363239333762323932
|
||||||
39373661633030323332333733343366343333303263323861383365663132356334373465336539
|
65393765326232373230666437656433373930643638386131363339343630636634636434326464
|
||||||
65316530626663333665663338346430333032333933353839333165356465373361343765613833
|
39366339326263666239646237326534383665376536313536303263373265306537316161663262
|
||||||
31303265303538396662613164393038366261383739623963613562363234363035643166343164
|
31346635346436313261626366333738333966643333313230623133313434373530366462653435
|
||||||
63346336323737643732643863633138373831393735313036316632646138363032616462626337
|
33353434643635383833643736653461373765326537313430353164306566323733653237343632
|
||||||
35386631303266313932346466383533356634643733376536636535623063653632356362376566
|
66346133656333303538306133313563393363313230323664303836323861346466343230343264
|
||||||
64313963643461326533363164373634663663303233666136336535366539633135323335386539
|
36613934643662626365653036636136623630333638373565316437646232316263663433313762
|
||||||
31323265633234323563396666323065623236623837616362353261663235623836663566616232
|
39353234333131623731643662303130626465386338353833393533646564646565623736343039
|
||||||
31326666653533383838346565386131373238333630613634386662343630323136333438333866
|
38356635393461353166653565336535626366396532633961393334343234353764303431303663
|
||||||
39343030326632373334636430353538396237653366663434396531303031326331626633316436
|
61666533633731663666346132383037646433336463643062396465383034346631346165323939
|
||||||
31626165316333343266343764666138663034316139366332663165393264663136363866363239
|
33313937343338383737373164363930336236326432346465646166363430653932333932343236
|
||||||
35393032666638333130356666613862643761313065666430663332306561663734373061363438
|
38336235613034386533613665393666633635383164646538373035623862343737353463623730
|
||||||
31623433383162333066303362653966383638616364623262623062623539303336646333326363
|
33396233353331633463373538326365636231323535633737303562613262613730636237336632
|
||||||
62616433643731643462663362663030306264616365653531633138316361363865306237333636
|
38626230313637336436623661666438666538333838356632653034303864313232623337306333
|
||||||
32323732613364393232343833343731323037623331333739613538646361363064383736646336
|
66363464643061363337393732323065306335656531376337323438313733616539613538333837
|
||||||
35646331323265313166653232393731646562333962333339336630316538333834383366663466
|
34363033666366613933343563303537613564356462313931353533323938656362393536386334
|
||||||
61663033636636626166623861393433366261336139656136316366343264363735666132633632
|
38336237616335346334613534323130613861663239356363366564623933303737306138613535
|
||||||
34363539336662656661326139346561303061366262616130626232313030313664623130306238
|
63643639323135663232336131643331343063363234336230653536623765323562393161663266
|
||||||
31663062653734303136336634313736346437326266346537633533316238356464643534623766
|
32663839613564613636343166396463366665666333306239386338616366363236393931313439
|
||||||
61383934636636366565393330363666363131646330343434393938663231333435323062636464
|
30386238316261323630633464386265353464333735336435646663656638316130333762666531
|
||||||
38363265663566313535353565623733323363666132636139383638306635363661306463653537
|
38626463316165373434613436343335303633643965633230326534323761616365376630363039
|
||||||
36343734356562323164396136383261623464646534643738333864653035336266383131353866
|
30336661313737383535343934366466353231396430353030653762383934666235646161653832
|
||||||
37363436393039653431336562363263363536336639396632323937323431366139313235663839
|
31613565643031353535353234386665373636356362653337366563316630343838626231646462
|
||||||
63663263326232333162326633623863623333653932643339626263326337646264656134383733
|
34623262343761373831303861313661666435373565386465336166306631376666643631303863
|
||||||
38613065393931393862633732306139646663346136393765343432313131636165336630616537
|
37633934326262623737373266326631663932373863346466613133303961386466366336643235
|
||||||
37646461313764666138386538303937623034336163376130623365383566653463313930653333
|
39303933333236626637663636633739343761393432616232643238663738313636346137316430
|
||||||
64316134663438636664313339393734383464663631346465666363363961313562376336373965
|
34623238326430616134396166306339626261643032613661343763366138653830376463306461
|
||||||
65373430343962303339626164656234346234363033636339656362333136626631356233363365
|
62366564393364306139633837646264633130383064383730393862633561303538363232663366
|
||||||
31313131643030633364306162303238303163663934366262636639353636326339616530316563
|
30343633666632303530356637646337623339303236376164633962383839386265336666396436
|
||||||
36626530336335333338343535633137663961363363613933336230306533353434643534306166
|
38616238656336343066333063393833623862646237323238393465633662393362353161313963
|
||||||
37663334626263316538366637376562316537386632366637623235343838626639306131313138
|
63663539383630366536313933643565346162646363353035386666396363633635386564346666
|
||||||
38393636313037393535
|
64336362633033346461353133396363646237613433306366333064626563656637383863323361
|
||||||
|
31386262346631343565653836333764636366313330633462303533616531316537353538313031
|
||||||
|
64366263666138356339373864383866303632366162633738383437323564313732373738373038
|
||||||
|
39643862336136663165343736613730306339643237313361333438613438323439373966396138
|
||||||
|
62323661383336396636
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# file: roles/caddy/defaults/main.yml
|
# file: roles/caddy/defaults/main.yml
|
||||||
|
|
||||||
# parent directory of vhost document roots
|
# parent directory of vhost document roots
|
||||||
caddy_root_prefix: /var/www
|
caddy_root_prefix: "{{ web_root_prefix }}"
|
||||||
|
|
||||||
# Email address to use for the ACME account managing the site's certificates.
|
# Email address to use for the ACME account managing the site's certificates.
|
||||||
# Not sure what Caddy does if this doesn't exist.
|
# Not sure what Caddy does if this doesn't exist.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
# I'm currently not sure when we need to restart versus reload
|
# I'm currently not sure when we need to restart versus reload
|
||||||
- name: reload caddy
|
- name: reload caddy
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd_service:
|
||||||
name: caddy
|
name: caddy
|
||||||
state: reloaded
|
state: reloaded
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
dest: /etc/apt/keyrings/caddy-stable-archive-keyring.key
|
dest: /etc/apt/keyrings/caddy-stable-archive-keyring.key
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: "0644"
|
||||||
register: download_caddy_signing_key
|
register: download_caddy_signing_key
|
||||||
when: not caddy_signing_key_stat.stat.exists
|
when: not caddy_signing_key_stat.stat.exists
|
||||||
tags:
|
tags:
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
- name: Add Caddy stable repo
|
- name: Add Caddy stable repo
|
||||||
ansible.builtin.apt_repository:
|
ansible.builtin.apt_repository:
|
||||||
repo: 'deb [signed-by=/etc/apt/keyrings/caddy-stable-archive-keyring.key] https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main'
|
repo: deb [signed-by=/etc/apt/keyrings/caddy-stable-archive-keyring.key] https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main
|
||||||
filename: caddy-stable
|
filename: caddy-stable
|
||||||
state: present
|
state: present
|
||||||
register: add_caddy_apt_repository
|
register: add_caddy_apt_repository
|
||||||
@@ -38,9 +38,7 @@
|
|||||||
- name: Update apt cache
|
- name: Update apt cache
|
||||||
ansible.builtin.apt: # noqa no-handler
|
ansible.builtin.apt: # noqa no-handler
|
||||||
update_cache: true
|
update_cache: true
|
||||||
when:
|
when: (download_caddy_signing_key.status_code is defined and download_caddy_signing_key.status_code == 200) or add_caddy_apt_repository is changed
|
||||||
(download_caddy_signing_key.status_code is defined and download_caddy_signing_key.status_code == 200) or
|
|
||||||
add_caddy_apt_repository is changed
|
|
||||||
tags:
|
tags:
|
||||||
- packages
|
- packages
|
||||||
- caddy
|
- caddy
|
||||||
@@ -59,7 +57,7 @@
|
|||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: etc/caddy/Caddyfile.j2
|
src: etc/caddy/Caddyfile.j2
|
||||||
dest: /etc/caddy/Caddyfile
|
dest: /etc/caddy/Caddyfile
|
||||||
mode: 0755
|
mode: "0755"
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
notify:
|
notify:
|
||||||
@@ -70,9 +68,10 @@
|
|||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: /etc/caddy/conf.d
|
path: /etc/caddy/conf.d
|
||||||
state: directory
|
state: directory
|
||||||
mode: 0755
|
mode: "0755"
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
|
tags: caddy
|
||||||
|
|
||||||
# TODO: the variable is still named nginx_vhosts
|
# TODO: the variable is still named nginx_vhosts
|
||||||
- name: Configure Caddy virtual hosts
|
- name: Configure Caddy virtual hosts
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: Configure vhosts
|
- name: Configure vhosts
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: etc/caddy/conf.d/vhost.j2
|
src: etc/caddy/conf.d/vhost.j2
|
||||||
dest: /etc/caddy/conf.d/{{ item.domain_name }}
|
dest: /etc/caddy/conf.d/{{ item.domain_name }}
|
||||||
mode: 0644
|
mode: "0644"
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
loop: "{{ nginx_vhosts }}"
|
loop: "{{ nginx_vhosts }}"
|
||||||
|
|||||||
@@ -8,6 +8,12 @@
|
|||||||
{% set needs_php = item.needs_php | default(false) %}
|
{% set needs_php = item.needs_php | default(false) %}
|
||||||
{% set has_gitea = item.has_gitea | default(false) %}
|
{% set has_gitea = item.has_gitea | default(false) %}
|
||||||
{% set static_site = item.static_site | default(false) %}
|
{% set static_site = item.static_site | default(false) %}
|
||||||
|
{# Allow sites to override the document root #}
|
||||||
|
{% if item.document_root is defined %}
|
||||||
|
{% set document_root = item.document_root %}
|
||||||
|
{% else %}
|
||||||
|
{% set document_root = (caddy_root_prefix, domain_name) | ansible.builtin.path_join %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if domain_aliases %}
|
{% if domain_aliases %}
|
||||||
{# domain_aliases is a string, so we split on space #}
|
{# domain_aliases is a string, so we split on space #}
|
||||||
@@ -21,15 +27,20 @@
|
|||||||
{{ domain_name }} {
|
{{ domain_name }} {
|
||||||
{% if has_gitea %}
|
{% if has_gitea %}
|
||||||
reverse_proxy :3000
|
reverse_proxy :3000
|
||||||
{% endif %}
|
{% elif static_site -%}
|
||||||
|
root * {{ document_root }}
|
||||||
|
|
||||||
{% if static_site -%}
|
encode
|
||||||
root * {{ item.document_root }}
|
|
||||||
|
|
||||||
encode zstd gzip
|
|
||||||
|
|
||||||
file_server
|
file_server
|
||||||
{% endif %}
|
{% elif has_wordpress -%}
|
||||||
|
root * {{ document_root }}
|
||||||
|
encode
|
||||||
|
{% if ansible_facts["distribution_major_version"] is version('12', '==') -%}
|
||||||
|
php_fastcgi unix//run/php/php8.2-fpm-{{ domain_name }}.sock
|
||||||
|
{% endif -%}
|
||||||
|
file_server
|
||||||
|
{% endif -%}
|
||||||
|
|
||||||
import security-headers
|
import security-headers
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ fail2ban_maxretry: 6
|
|||||||
fail2ban_findtime: 3600
|
fail2ban_findtime: 3600
|
||||||
# 2 weeks in seconds
|
# 2 weeks in seconds
|
||||||
fail2ban_bantime: 1209600
|
fail2ban_bantime: 1209600
|
||||||
fail2ban_ignoreip: 127.0.0.1/8 172.26.0.0/16 192.168.5.0/24
|
fail2ban_ignoreip: 127.0.0.0/8
|
||||||
|
|
||||||
# Disable SSH passwords. Must use SSH keys. This is OK because we add the keys
|
# Disable SSH passwords. Must use SSH keys. This is OK because we add the keys
|
||||||
# before re-configuring the SSH daemon to disable passwords.
|
# before re-configuring the SSH daemon to disable passwords.
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +0,0 @@
|
|||||||
#!/usr/sbin/nft -f
|
|
||||||
|
|
||||||
define ABUSEIPDB_IPV6 = {
|
|
||||||
fd21:3523:74e0:7301::
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
#!/usr/bin/perl
|
|
||||||
#
|
|
||||||
# aggregate-cidr-addresses - combine a list of CIDR address blocks
|
|
||||||
# Copyright (C) 2001,2007 Mark Suter <suter@zwitterion.org>
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see L<http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
# [MJS 22 Oct 2001] Aggregate CIDR addresses
|
|
||||||
# [MJS 9 Oct 2007] Overlap idea from Anthony Ledesma at theplanet dot com.
|
|
||||||
# [MJS 16 Feb 2012] Prompted to clarify license by Alexander Talos-Zens - at at univie dot ac dot at
|
|
||||||
# [MJS 21 Feb 2012] IPv6 fixes by Alexander Talos-Zens
|
|
||||||
# [MJS 21 Feb 2012] Split ranges into prefixes (fixes a 10+ year old bug)
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
use English qw( -no_match_vars );
|
|
||||||
use Net::IP;
|
|
||||||
|
|
||||||
## Read in all the IP addresses
|
|
||||||
my @addrs = map { Net::IP->new($_) or die "$PROGRAM_NAME: Not an IP: \"$_\"."; }
|
|
||||||
map { / \A \s* (.+?) \s* \Z /msix and $1; } <>;
|
|
||||||
|
|
||||||
## Split any ranges into prefixes
|
|
||||||
@addrs = map {
|
|
||||||
defined $_->prefixlen ? $_ : map { Net::IP->new($_) }
|
|
||||||
$_->find_prefixes
|
|
||||||
} @addrs;
|
|
||||||
|
|
||||||
## Sort the IP addresses
|
|
||||||
@addrs = sort { $a->version <=> $b->version or $a->bincomp( 'lt', $b ) ? -1 : $a->bincomp( 'gt', $b ) ? 1 : 0 } @addrs;
|
|
||||||
|
|
||||||
## Handle overlaps
|
|
||||||
my $count = 0;
|
|
||||||
my $current = $addrs[0];
|
|
||||||
foreach my $next ( @addrs[ 1 .. $#addrs ] ) {
|
|
||||||
my $r = $current->overlaps($next);
|
|
||||||
if ( $current->version != $next->version or $r == $IP_NO_OVERLAP ) {
|
|
||||||
$current = $next;
|
|
||||||
$count++;
|
|
||||||
}
|
|
||||||
elsif ( $r == $IP_A_IN_B_OVERLAP ) {
|
|
||||||
$current = $next;
|
|
||||||
splice @addrs, $count, 1;
|
|
||||||
}
|
|
||||||
elsif ( $r == $IP_B_IN_A_OVERLAP or $r == $IP_IDENTICAL ) {
|
|
||||||
splice @addrs, $count + 1, 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
die "$PROGRAM_NAME: internal error - overlaps() returned an unexpected value!\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
## Keep aggregating until we don't change anything
|
|
||||||
my $change = 1;
|
|
||||||
while ($change) {
|
|
||||||
$change = 0;
|
|
||||||
my @new_addrs = ();
|
|
||||||
$current = $addrs[0];
|
|
||||||
foreach my $next ( @addrs[ 1 .. $#addrs ] ) {
|
|
||||||
if ( my $total = $current->aggregate($next) ) {
|
|
||||||
$current = $total;
|
|
||||||
$change = 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
push @new_addrs, $current;
|
|
||||||
$current = $next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
push @new_addrs, $current;
|
|
||||||
@addrs = @new_addrs;
|
|
||||||
}
|
|
||||||
|
|
||||||
## Print out the IP addresses
|
|
||||||
foreach (@addrs) {
|
|
||||||
print $_->prefix(), "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
# $Id: aggregate-cidr-addresses,v 1.9 2012/02/21 10:14:22 suter Exp suter $
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
autoclean -y
|
|
||||||
upgrade -y -o APT::Get::Show-Upgraded=true
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Configuration for cron-apt. For further information about the possible
|
|
||||||
# configuration settings see the README file.
|
|
||||||
|
|
||||||
MAILON="never"
|
|
||||||
OPTIONS="-o quiet=1 -o Dir::Etc::SourceList=/etc/apt/security.sources.list -o Dir::Etc::SourceParts=\"/dev/null\""
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
provisioning ALL=(ALL) ALL
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/sbin/nft -f
|
#!/usr/sbin/nft -f
|
||||||
|
|
||||||
define SPAMHAUS_IPV4 = {
|
define FIREHOL_LEVEL1_IPV4 = {
|
||||||
192.168.254.254/32
|
192.168.254.254/32
|
||||||
}
|
}
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#!/usr/sbin/nft -f
|
|
||||||
|
|
||||||
define SPAMHAUS_IPV6 = {
|
|
||||||
fd21:3523:74e0:7301::/64
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Update Abuse.ch SSL Blacklist IPs
|
|
||||||
# This service will fail if nftables is not running so we use Requires to make
|
|
||||||
# sure that nftables is started.
|
|
||||||
Requires=nftables.service
|
|
||||||
# Make sure the network is up and nftables is started
|
|
||||||
After=network-online.target nftables.service
|
|
||||||
Wants=network-online.target update-abusech-nftables.timer
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
# https://www.ctrl.blog/entry/systemd-service-hardening.html
|
|
||||||
# Doesn't need access to /home or /root
|
|
||||||
ProtectHome=true
|
|
||||||
# Possibly only works on Ubuntu 18.04+
|
|
||||||
ProtectKernelTunables=true
|
|
||||||
ProtectSystem=full
|
|
||||||
# Newer systemd can use ReadWritePaths to list files, but this works everywhere
|
|
||||||
ReadWriteDirectories=/etc/nftables
|
|
||||||
PrivateTmp=true
|
|
||||||
WorkingDirectory=/var/tmp
|
|
||||||
|
|
||||||
SyslogIdentifier=update-abusech-nftables
|
|
||||||
ExecStart=/usr/bin/flock -x update-abusech-nftables.lck \
|
|
||||||
/usr/local/bin/update-abusech-nftables.sh
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
#
|
|
||||||
# update-abuseipdb-nftables.sh v0.0.1
|
|
||||||
#
|
|
||||||
# Download IP addresses seen using a blacklisted SSL certificate and load them
|
|
||||||
# into nftables sets. As of 2021-07-28 these appear to only be IPv4.
|
|
||||||
#
|
|
||||||
# See: https://sslbl.abuse.ch/blacklist
|
|
||||||
#
|
|
||||||
# Copyright (C) 2021 Alan Orth
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
|
|
||||||
# Exit on first error
|
|
||||||
set -o errexit
|
|
||||||
|
|
||||||
abusech_ipv4_set_path=/etc/nftables/abusech-ipv4.nft
|
|
||||||
abusech_list_temp=$(mktemp)
|
|
||||||
|
|
||||||
echo "Downloading Abuse.sh SSL Blacklist IPs"
|
|
||||||
|
|
||||||
abusech_response=$(curl -s -G -w "%{http_code}\n" https://sslbl.abuse.ch/blacklist/sslipblacklist.txt --output "$abusech_list_temp")
|
|
||||||
|
|
||||||
if [[ $abusech_response -ne 200 ]]; then
|
|
||||||
echo "Abuse.ch responded: HTTP $abusech_response"
|
|
||||||
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -f "$abusech_list_temp" ]]; then
|
|
||||||
echo "Processing IPv4 list"
|
|
||||||
|
|
||||||
abusech_ipv4_list_temp=$(mktemp)
|
|
||||||
abusech_ipv4_set_temp=$(mktemp)
|
|
||||||
|
|
||||||
# Remove comments, DOS carriage returns, and IPv6 addresses (even though
|
|
||||||
# Abuse.ch seems to only have IPv4 addresses, let's not break our shit on
|
|
||||||
# that assumption some time down the line).
|
|
||||||
sed -e '/#/d' -e 's/
|
|
||||||
//' -e '/:/d' "$abusech_list_temp" > "$abusech_ipv4_list_temp"
|
|
||||||
|
|
||||||
echo "Building abusech-ipv4 set"
|
|
||||||
cat << NFT_HEAD > "$abusech_ipv4_set_temp"
|
|
||||||
#!/usr/sbin/nft -f
|
|
||||||
|
|
||||||
define ABUSECH_IPV4 = {
|
|
||||||
NFT_HEAD
|
|
||||||
|
|
||||||
while read -r network; do
|
|
||||||
# nftables doesn't mind if the last element in the set has a trailing
|
|
||||||
# comma so we don't need to do anything special here.
|
|
||||||
echo "$network," >> "$abusech_ipv4_set_temp"
|
|
||||||
done < $abusech_ipv4_list_temp
|
|
||||||
|
|
||||||
echo "}" >> "$abusech_ipv4_set_temp"
|
|
||||||
|
|
||||||
install -m 0600 "$abusech_ipv4_set_temp" "$abusech_ipv4_set_path"
|
|
||||||
|
|
||||||
rm -f "$abusech_list_temp" "$abusech_ipv4_list_temp" "$abusech_ipv4_set_temp"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Reloading nftables"
|
|
||||||
# The abusech nftables sets are included by nftables.conf
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Update Abuse.ch SSL Blacklist IPs
|
|
||||||
|
|
||||||
[Timer]
|
|
||||||
# Once a day at midnight
|
|
||||||
OnCalendar=*-*-* 00:00:00
|
|
||||||
# Add a random delay of 0–3600 seconds
|
|
||||||
RandomizedDelaySec=3600
|
|
||||||
Persistent=true
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=timers.target
|
|
||||||
24
roles/common/files/update-firehol-nftables.service
Normal file
24
roles/common/files/update-firehol-nftables.service
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Update FireHOL lists
|
||||||
|
# Make sure the network is up
|
||||||
|
After=network-online.target
|
||||||
|
Wants=network-online.target update-firehol-nftables.timer
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
# https://www.ctrl.blog/entry/systemd-service-hardening.html
|
||||||
|
# Doesn't need access to /home or /root
|
||||||
|
ProtectHome=true
|
||||||
|
# Possibly only works on Ubuntu 18.04+
|
||||||
|
ProtectKernelTunables=true
|
||||||
|
ProtectSystem=full
|
||||||
|
# Newer systemd can use ReadWritePaths to list files, but this works everywhere
|
||||||
|
ReadWriteDirectories=/etc/nftables
|
||||||
|
PrivateTmp=true
|
||||||
|
WorkingDirectory=/var/tmp
|
||||||
|
|
||||||
|
SyslogIdentifier=update-firehol-nftables
|
||||||
|
ExecStart=/usr/bin/flock -x update-firehol-nftables.lck \
|
||||||
|
/usr/local/bin/update-firehol-nftables.sh
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Update Spamhaus lists
|
Description=Update FireHOL lists
|
||||||
|
|
||||||
[Timer]
|
[Timer]
|
||||||
# Once a day at midnight
|
# Once a day at midnight
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Update Spamhaus lists
|
|
||||||
# This service will fail if nftables is not running so we use Requires to make
|
|
||||||
# sure that nftables is started.
|
|
||||||
Requires=nftables.service
|
|
||||||
# Make sure the network is up and nftables is started
|
|
||||||
After=network-online.target nftables.service
|
|
||||||
Wants=network-online.target update-spamhaus-nftables.timer
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
# https://www.ctrl.blog/entry/systemd-service-hardening.html
|
|
||||||
# Doesn't need access to /home or /root
|
|
||||||
ProtectHome=true
|
|
||||||
# Possibly only works on Ubuntu 18.04+
|
|
||||||
ProtectKernelTunables=true
|
|
||||||
ProtectSystem=full
|
|
||||||
# Newer systemd can use ReadWritePaths to list files, but this works everywhere
|
|
||||||
ReadWriteDirectories=/etc/nftables
|
|
||||||
PrivateTmp=true
|
|
||||||
WorkingDirectory=/var/tmp
|
|
||||||
|
|
||||||
SyslogIdentifier=update-spamhaus-nftables
|
|
||||||
ExecStart=/usr/bin/flock -x update-spamhaus-nftables.lck \
|
|
||||||
/usr/local/bin/update-spamhaus-nftables.sh
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
#
|
|
||||||
# update-spamhaus-nftables.sh v0.0.1
|
|
||||||
#
|
|
||||||
# Download Spamhaus DROP lists and load them into nftables sets.
|
|
||||||
#
|
|
||||||
# See: https://www.spamhaus.org/drop/
|
|
||||||
#
|
|
||||||
# Copyright (C) 2021 Alan Orth
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
|
|
||||||
# Exit on first error
|
|
||||||
set -o errexit
|
|
||||||
|
|
||||||
spamhaus_ipv4_set_path=/etc/nftables/spamhaus-ipv4.nft
|
|
||||||
spamhaus_ipv6_set_path=/etc/nftables/spamhaus-ipv6.nft
|
|
||||||
|
|
||||||
function download() {
|
|
||||||
echo "Downloading $1"
|
|
||||||
wget -q -O - "https://www.spamhaus.org/drop/$1" > "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
download drop.txt
|
|
||||||
download edrop.txt
|
|
||||||
download dropv6.txt
|
|
||||||
|
|
||||||
if [[ -f "drop.txt" && -f "edrop.txt" ]]; then
|
|
||||||
echo "Processing IPv4 DROP lists"
|
|
||||||
|
|
||||||
spamhaus_ipv4_list_temp=$(mktemp)
|
|
||||||
spamhaus_ipv4_set_temp=$(mktemp)
|
|
||||||
|
|
||||||
# Extract all networks from drop.txt and edrop.txt, skipping blank lines and
|
|
||||||
# comments. Use aggregate-cidr-addresses.pl to merge overlapping IPv4 CIDR
|
|
||||||
# ranges to work around a firewalld bug.
|
|
||||||
#
|
|
||||||
# See: https://bugzilla.redhat.com/show_bug.cgi?id=1836571
|
|
||||||
cat drop.txt edrop.txt | sed -e '/^$/d' -e '/^;.*/d' -e 's/[[:space:]];[[:space:]].*//' | aggregate-cidr-addresses.pl > "$spamhaus_ipv4_list_temp"
|
|
||||||
|
|
||||||
echo "Building spamhaus-ipv4 set"
|
|
||||||
cat << NFT_HEAD > "$spamhaus_ipv4_set_temp"
|
|
||||||
#!/usr/sbin/nft -f
|
|
||||||
|
|
||||||
define SPAMHAUS_IPV4 = {
|
|
||||||
NFT_HEAD
|
|
||||||
|
|
||||||
while read -r network; do
|
|
||||||
# nftables doesn't mind if the last element in the set has a trailing
|
|
||||||
# comma so we don't need to do anything special here.
|
|
||||||
echo "$network," >> "$spamhaus_ipv4_set_temp"
|
|
||||||
done < $spamhaus_ipv4_list_temp
|
|
||||||
|
|
||||||
echo "}" >> "$spamhaus_ipv4_set_temp"
|
|
||||||
|
|
||||||
install -m 0600 "$spamhaus_ipv4_set_temp" "$spamhaus_ipv4_set_path"
|
|
||||||
|
|
||||||
rm -f "$spamhaus_ipv4_list_temp" "$spamhaus_ipv4_set_temp"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -f "dropv6.txt" ]]; then
|
|
||||||
echo "Processing IPv6 DROP lists"
|
|
||||||
|
|
||||||
spamhaus_ipv6_list_temp=$(mktemp)
|
|
||||||
spamhaus_ipv6_set_temp=$(mktemp)
|
|
||||||
|
|
||||||
sed -e '/^$/d' -e '/^;.*/d' -e 's/[[:space:]];[[:space:]].*//' dropv6.txt > "$spamhaus_ipv6_list_temp"
|
|
||||||
|
|
||||||
echo "Building spamhaus-ipv6 set"
|
|
||||||
cat << NFT_HEAD > "$spamhaus_ipv6_set_temp"
|
|
||||||
#!/usr/sbin/nft -f
|
|
||||||
|
|
||||||
define SPAMHAUS_IPV6 = {
|
|
||||||
NFT_HEAD
|
|
||||||
|
|
||||||
while read -r network; do
|
|
||||||
echo "$network," >> "$spamhaus_ipv6_set_temp"
|
|
||||||
done < $spamhaus_ipv6_list_temp
|
|
||||||
|
|
||||||
echo "}" >> "$spamhaus_ipv6_set_temp"
|
|
||||||
|
|
||||||
install -m 0600 "$spamhaus_ipv6_set_temp" "$spamhaus_ipv6_set_path"
|
|
||||||
|
|
||||||
rm -f "$spamhaus_ipv6_list_temp" "$spamhaus_ipv6_set_temp"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Reloading nftables"
|
|
||||||
# The spamhaus nftables sets are included by nftables.conf
|
|
||||||
/usr/sbin/nft -f /etc/nftables.conf
|
|
||||||
|
|
||||||
rm -v drop.txt edrop.txt dropv6.txt
|
|
||||||
@@ -1,20 +1,27 @@
|
|||||||
---
|
---
|
||||||
# ansible.builtin.file: roles/common/handlers/main.yml
|
# ansible.builtin.file: roles/common/handlers/main.yml
|
||||||
|
|
||||||
- name: reload sshd
|
- name: Reload sshd
|
||||||
ansible.builtin.systemd: name={{ sshd_service_name }} state=reloaded
|
ansible.builtin.systemd_service:
|
||||||
|
name: "{{ sshd_service_name }}"
|
||||||
|
state: reloaded
|
||||||
|
|
||||||
- name: reload sysctl
|
- name: Reload sysctl
|
||||||
command: sysctl -p /etc/sysctl.conf
|
ansible.builtin.command: sysctl -p /etc/sysctl.conf
|
||||||
|
|
||||||
- name: reload systemd
|
- name: Reload systemd
|
||||||
ansible.builtin.systemd: daemon_reload=true
|
ansible.builtin.systemd_service:
|
||||||
|
daemon_reload: true
|
||||||
|
|
||||||
- name: restart nftables
|
- name: Restart nftables
|
||||||
ansible.builtin.systemd: name=nftables state=restarted
|
ansible.builtin.systemd_service:
|
||||||
|
name: nftables
|
||||||
|
state: restarted
|
||||||
|
|
||||||
# 2021-09-28: note to self to keep fail2ban at the end, as handlers are executed
|
# 2021-09-28: note to self to keep fail2ban at the end, as handlers are executed
|
||||||
# in the order they are defined, not in the order they are listed in the task's
|
# in the order they are defined, not in the order they are listed in the task's
|
||||||
# notify statement and we must restart fail2ban after updating the firewall.
|
# notify statement and we must restart fail2ban after updating the firewall.
|
||||||
- name: restart fail2ban
|
- name: Restart fail2ban
|
||||||
ansible.builtin.systemd: name=fail2ban state=restarted
|
ansible.builtin.systemd_service:
|
||||||
|
name: fail2ban
|
||||||
|
state: restarted
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
---
|
---
|
||||||
|
- name: Remove cron-apt
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: cron-apt
|
||||||
|
state: absent
|
||||||
|
cache_valid_time: 3600
|
||||||
|
|
||||||
- name: Configure cron-apt (config)
|
- name: Remove cron-apt configs
|
||||||
ansible.builtin.copy: src={{ item.src }} dest={{ item.dest }} mode={{ item.mode }} owner={{ item.owner }} group={{ item.group }}
|
ansible.builtin.file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: absent
|
||||||
loop:
|
loop:
|
||||||
- { src: 'etc/cron-apt/config', dest: '/etc/cron-apt/config', mode: '0644', owner: 'root', group: 'root' }
|
- /etc/cron-apt/config
|
||||||
- { src: 'etc/cron-apt/3-download', dest: '/etc/cron-apt/action.d/3-download', mode: '0644', owner: 'root', group: 'root' }
|
- /etc/cron-apt/action.d/3-download
|
||||||
|
- /etc/apt/security.sources.list
|
||||||
- name: Configure cron-apt (security)
|
|
||||||
ansible.builtin.template: src=security.sources.list.j2 dest=/etc/apt/security.sources.list mode=0644 owner=root group=root
|
|
||||||
|
|
||||||
# vim: set ts=2 sw=2:
|
# vim: set ts=2 sw=2:
|
||||||
|
|||||||
@@ -1,29 +1,39 @@
|
|||||||
---
|
---
|
||||||
|
- name: Install fail2ban
|
||||||
|
when: ansible_facts["distribution_version"] is version('11', '>=')
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name:
|
||||||
|
- fail2ban
|
||||||
|
- python3-systemd
|
||||||
|
state: present
|
||||||
|
cache_valid_time: 3600
|
||||||
|
|
||||||
- name: Configure fail2ban sshd filter
|
- name: Configure fail2ban sshd filter
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: etc/fail2ban/jail.d/sshd.local.j2
|
src: etc/fail2ban/jail.d/sshd.local.j2
|
||||||
dest: /etc/fail2ban/jail.d/sshd.local
|
dest: /etc/fail2ban/jail.d/sshd.local
|
||||||
owner: root
|
owner: root
|
||||||
mode: 0644
|
mode: "0644"
|
||||||
notify: restart fail2ban
|
notify: Restart fail2ban
|
||||||
|
|
||||||
- name: Configure fail2ban nginx filter
|
- name: Configure fail2ban nginx filter
|
||||||
when:
|
when:
|
||||||
|
- webserver is defined and webserver == 'nginx'
|
||||||
- extra_fail2ban_filters is defined
|
- extra_fail2ban_filters is defined
|
||||||
- "'nginx' in extra_fail2ban_filters"
|
- "'nginx' in extra_fail2ban_filters"
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: etc/fail2ban/jail.d/nginx.local.j2
|
src: etc/fail2ban/jail.d/nginx.local.j2
|
||||||
dest: /etc/fail2ban/jail.d/nginx.local
|
dest: /etc/fail2ban/jail.d/nginx.local
|
||||||
owner: root
|
owner: root
|
||||||
mode: 0644
|
mode: "0644"
|
||||||
notify: restart fail2ban
|
notify: Restart fail2ban
|
||||||
|
|
||||||
- name: Create fail2ban service override directory
|
- name: Create fail2ban service override directory
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: /etc/systemd/system/fail2ban.service.d
|
path: /etc/systemd/system/fail2ban.service.d
|
||||||
state: directory
|
state: directory
|
||||||
owner: root
|
owner: root
|
||||||
mode: 0755
|
mode: "0755"
|
||||||
|
|
||||||
# See Arch Linux's example: https://wiki.archlinux.org/index.php/Fail2ban
|
# See Arch Linux's example: https://wiki.archlinux.org/index.php/Fail2ban
|
||||||
- name: Configure fail2ban service override
|
- name: Configure fail2ban service override
|
||||||
@@ -31,13 +41,13 @@
|
|||||||
src: etc/systemd/system/fail2ban.service.d/override.conf.j2
|
src: etc/systemd/system/fail2ban.service.d/override.conf.j2
|
||||||
dest: /etc/systemd/system/fail2ban.service.d/override.conf
|
dest: /etc/systemd/system/fail2ban.service.d/override.conf
|
||||||
owner: root
|
owner: root
|
||||||
mode: 0644
|
mode: "0644"
|
||||||
notify:
|
notify:
|
||||||
- reload systemd
|
- Reload systemd
|
||||||
- restart fail2ban
|
- Restart fail2ban
|
||||||
|
|
||||||
- name: Start and enable fail2ban service
|
- name: Start and enable fail2ban service
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd_service:
|
||||||
name: fail2ban
|
name: fail2ban
|
||||||
state: started
|
state: started
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|||||||
25
roles/common/tasks/firewall.yml
Normal file
25
roles/common/tasks/firewall.yml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
# Debian 11+ will use nftables directly, with no firewalld.
|
||||||
|
|
||||||
|
- name: Install Debian firewall packages
|
||||||
|
when: ansible_facts["distribution_version"] is version('11', '>=')
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: nftables
|
||||||
|
state: present
|
||||||
|
cache_valid_time: 3600
|
||||||
|
|
||||||
|
- name: Remove iptables on newer Debian
|
||||||
|
when: ansible_facts["distribution_version"] is version('11', '>=')
|
||||||
|
ansible.builtin.apt:
|
||||||
|
pkg: iptables
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Configure nftables
|
||||||
|
when: ansible_facts["distribution_version"] is version('11', '>=')
|
||||||
|
ansible.builtin.include_tasks: nftables.yml
|
||||||
|
|
||||||
|
- name: Configure fail2ban
|
||||||
|
when: ansible_facts["distribution_version"] is version('9', '>=')
|
||||||
|
ansible.builtin.include_tasks: fail2ban.yml
|
||||||
|
|
||||||
|
# vim: set sw=2 ts=2:
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
---
|
|
||||||
# Debian 11+ will use nftables directly, with no firewalld.
|
|
||||||
|
|
||||||
- block:
|
|
||||||
- name: Install Debian firewall packages
|
|
||||||
when: ansible_distribution_major_version is version('11', '>=')
|
|
||||||
ansible.builtin.package:
|
|
||||||
name:
|
|
||||||
- fail2ban
|
|
||||||
- libnet-ip-perl # for aggregate-cidr-addresses.pl
|
|
||||||
- nftables
|
|
||||||
- python3-systemd
|
|
||||||
- curl # for nftables update scripts
|
|
||||||
state: present
|
|
||||||
cache_valid_time: 3600
|
|
||||||
|
|
||||||
- name: Remove iptables on newer Debian
|
|
||||||
when: ansible_distribution_major_version is version('11', '>=')
|
|
||||||
ansible.builtin.apt:
|
|
||||||
pkg: iptables
|
|
||||||
state: absent
|
|
||||||
|
|
||||||
- name: Copy nftables.conf
|
|
||||||
when: ansible_distribution_major_version is version('11', '>=')
|
|
||||||
ansible.builtin.template:
|
|
||||||
src: nftables.conf.j2
|
|
||||||
dest: /etc/nftables.conf
|
|
||||||
owner: root
|
|
||||||
mode: 0644
|
|
||||||
notify:
|
|
||||||
- restart nftables
|
|
||||||
- restart fail2ban
|
|
||||||
|
|
||||||
- name: Create /etc/nftables extra config directory
|
|
||||||
when: ansible_distribution_major_version is version('11', '>=')
|
|
||||||
ansible.builtin.file:
|
|
||||||
path: /etc/nftables
|
|
||||||
state: directory
|
|
||||||
owner: root
|
|
||||||
mode: 0755
|
|
||||||
|
|
||||||
- name: Copy extra nftables configuration files
|
|
||||||
when: ansible_distribution_major_version is version('11', '>=')
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: "{{ item.src }}"
|
|
||||||
dest: "/etc/nftables/{{ item.src }}"
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: 0644
|
|
||||||
force: "{{ item.force }}"
|
|
||||||
loop:
|
|
||||||
- { src: "spamhaus-ipv4.nft", force: "no" }
|
|
||||||
- { src: "spamhaus-ipv6.nft", force: "no" }
|
|
||||||
- { src: "abusech-ipv4.nft", force: "no" }
|
|
||||||
- { src: "abuseipdb-ipv4.nft", force: "yes" }
|
|
||||||
- { src: "abuseipdb-ipv6.nft", force: "yes" }
|
|
||||||
notify:
|
|
||||||
- restart nftables
|
|
||||||
- restart fail2ban
|
|
||||||
|
|
||||||
- name: Copy nftables update scripts
|
|
||||||
when: ansible_distribution_version is version('11', '>=')
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: "{{ item }}"
|
|
||||||
dest: "/usr/local/bin/{{ item }}"
|
|
||||||
mode: 0755
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
loop:
|
|
||||||
- update-spamhaus-nftables.sh
|
|
||||||
- aggregate-cidr-addresses.pl
|
|
||||||
- update-abusech-nftables.sh
|
|
||||||
|
|
||||||
- name: Copy nftables systemd units
|
|
||||||
when: ansible_distribution_version is version('11', '>=')
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: "{{ item }}"
|
|
||||||
dest: "/etc/systemd/system/{{ item }}"
|
|
||||||
mode: 0644
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
loop:
|
|
||||||
- update-spamhaus-nftables.service
|
|
||||||
- update-spamhaus-nftables.timer
|
|
||||||
- update-abusech-nftables.service
|
|
||||||
- update-abusech-nftables.timer
|
|
||||||
register: nftables_systemd_units
|
|
||||||
|
|
||||||
# need to reload to pick up service/timer/environment changes
|
|
||||||
- name: Reload systemd daemon
|
|
||||||
ansible.builtin.systemd:
|
|
||||||
daemon_reload: true
|
|
||||||
when: nftables_systemd_units is changed
|
|
||||||
|
|
||||||
- name: Start and enable nftables update timers
|
|
||||||
when: ansible_distribution_version is version('11', '>=')
|
|
||||||
ansible.builtin.systemd:
|
|
||||||
name: "{{ item }}"
|
|
||||||
state: started
|
|
||||||
enabled: true
|
|
||||||
loop:
|
|
||||||
- update-spamhaus-nftables.timer
|
|
||||||
- update-abusech-nftables.timer
|
|
||||||
|
|
||||||
- name: Start and enable nftables
|
|
||||||
when: ansible_distribution_major_version is version('11', '>=')
|
|
||||||
ansible.builtin.systemd:
|
|
||||||
name: nftables
|
|
||||||
state: started
|
|
||||||
enabled: true
|
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: fail2ban.yml
|
|
||||||
when: ansible_distribution_major_version is version('9', '>=')
|
|
||||||
tags: firewall
|
|
||||||
|
|
||||||
# vim: set sw=2 ts=2:
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
---
|
|
||||||
# Ubuntu 20.04 will use nftables directly, with no firewalld.
|
|
||||||
|
|
||||||
- block:
|
|
||||||
- name: Install Ubuntu firewall packages
|
|
||||||
ansible.builtin.package:
|
|
||||||
name:
|
|
||||||
- fail2ban
|
|
||||||
- libnet-ip-perl # for aggregate-cidr-addresses.pl
|
|
||||||
- nftables
|
|
||||||
- python3-systemd
|
|
||||||
- curl # for nftables update scripts
|
|
||||||
state: present
|
|
||||||
cache_valid_time: 3600
|
|
||||||
|
|
||||||
- name: Remove ufw
|
|
||||||
ansible.builtin.package:
|
|
||||||
name: ufw
|
|
||||||
state: absent
|
|
||||||
|
|
||||||
- name: Copy nftables.conf
|
|
||||||
when: ansible_distribution_version is version('20.04', '>=')
|
|
||||||
ansible.builtin.template:
|
|
||||||
src: nftables.conf.j2
|
|
||||||
dest: /etc/nftables.conf
|
|
||||||
owner: root
|
|
||||||
mode: 0644
|
|
||||||
notify:
|
|
||||||
- restart nftables
|
|
||||||
- restart fail2ban
|
|
||||||
|
|
||||||
- name: Create /etc/nftables extra config directory
|
|
||||||
when: ansible_distribution_version is version('20.04', '>=')
|
|
||||||
ansible.builtin.file:
|
|
||||||
path: /etc/nftables
|
|
||||||
state: directory
|
|
||||||
owner: root
|
|
||||||
mode: 0755
|
|
||||||
|
|
||||||
- name: Copy extra nftables configuration files
|
|
||||||
when: ansible_distribution_version is version('20.04', '>=')
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: "{{ item.src }}"
|
|
||||||
dest: "/etc/nftables/{{ item.src }}"
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: 0644
|
|
||||||
force: "{{ item.force }}"
|
|
||||||
loop:
|
|
||||||
- { src: "spamhaus-ipv4.nft", force: "no" }
|
|
||||||
- { src: "spamhaus-ipv6.nft", force: "no" }
|
|
||||||
- { src: "abusech-ipv4.nft", force: "no" }
|
|
||||||
- { src: "abuseipdb-ipv4.nft", force: "yes" }
|
|
||||||
- { src: "abuseipdb-ipv6.nft", force: "yes" }
|
|
||||||
notify:
|
|
||||||
- restart nftables
|
|
||||||
- restart fail2ban
|
|
||||||
|
|
||||||
- name: Copy nftables update scripts
|
|
||||||
when: ansible_distribution_version is version('20.04', '>=')
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: "{{ item }}"
|
|
||||||
dest: "/usr/local/bin/{{ item }}"
|
|
||||||
mode: 0755
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
loop:
|
|
||||||
- update-spamhaus-nftables.sh
|
|
||||||
- aggregate-cidr-addresses.pl
|
|
||||||
- update-abusech-nftables.sh
|
|
||||||
|
|
||||||
- name: Copy nftables systemd units
|
|
||||||
when: ansible_distribution_version is version('20.04', '>=')
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: "{{ item }}"
|
|
||||||
dest: "/etc/systemd/system/{{ item }}"
|
|
||||||
mode: 0644
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
loop:
|
|
||||||
- update-spamhaus-nftables.service
|
|
||||||
- update-spamhaus-nftables.timer
|
|
||||||
- update-abusech-nftables.service
|
|
||||||
- update-abusech-nftables.timer
|
|
||||||
register: nftables_systemd_units
|
|
||||||
|
|
||||||
# need to reload to pick up service/timer/environment changes
|
|
||||||
- name: Reload systemd daemon
|
|
||||||
ansible.builtin.systemd:
|
|
||||||
daemon_reload: true
|
|
||||||
when: nftables_systemd_units is changed
|
|
||||||
|
|
||||||
- name: Start and enable nftables update timers
|
|
||||||
when: ansible_distribution_version is version('20.04', '>=')
|
|
||||||
ansible.builtin.systemd:
|
|
||||||
name: "{{ item }}"
|
|
||||||
state: started
|
|
||||||
enabled: true
|
|
||||||
loop:
|
|
||||||
- update-spamhaus-nftables.timer
|
|
||||||
- update-abusech-nftables.timer
|
|
||||||
|
|
||||||
- name: Start and enable nftables
|
|
||||||
when: ansible_distribution_version is version('20.04', '>=')
|
|
||||||
ansible.builtin.systemd:
|
|
||||||
name: nftables
|
|
||||||
state: started
|
|
||||||
enabled: true
|
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: fail2ban.yml
|
|
||||||
when: ansible_distribution_version is version('16.04', '>=')
|
|
||||||
tags: firewall
|
|
||||||
|
|
||||||
# vim: set sw=2 ts=2:
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
- name: Import OS-specific variables
|
- name: Import OS-specific variables
|
||||||
ansible.builtin.include_vars: "vars/{{ ansible_distribution }}.yml"
|
ansible.builtin.include_vars: vars/{{ ansible_facts["distribution"] }}.yml
|
||||||
tags: always
|
tags: always
|
||||||
|
|
||||||
- name: Configure network time
|
- name: Configure network time
|
||||||
@@ -8,23 +8,11 @@
|
|||||||
tags: ntp
|
tags: ntp
|
||||||
|
|
||||||
- name: Install common packages
|
- name: Install common packages
|
||||||
ansible.builtin.include_tasks: packages_Debian.yml
|
ansible.builtin.include_tasks: packages.yml
|
||||||
when: ansible_distribution == 'Debian'
|
|
||||||
tags: packages
|
|
||||||
|
|
||||||
- name: Install common packages
|
|
||||||
ansible.builtin.include_tasks: packages_Ubuntu.yml
|
|
||||||
when: ansible_distribution == 'Ubuntu'
|
|
||||||
tags: packages
|
tags: packages
|
||||||
|
|
||||||
- name: Configure firewall
|
- name: Configure firewall
|
||||||
ansible.builtin.include_tasks: firewall_Debian.yml
|
ansible.builtin.import_tasks: firewall.yml
|
||||||
when: ansible_distribution == 'Debian'
|
|
||||||
tags: firewall
|
|
||||||
|
|
||||||
- name: Configure firewall
|
|
||||||
ansible.builtin.include_tasks: firewall_Ubuntu.yml
|
|
||||||
when: ansible_distribution == 'Ubuntu'
|
|
||||||
tags: firewall
|
tags: firewall
|
||||||
|
|
||||||
- name: Configure secure shell daemon
|
- name: Configure secure shell daemon
|
||||||
@@ -33,14 +21,24 @@
|
|||||||
|
|
||||||
# containers identify as virtualization hosts, which makes this tricky, because we have actual Debian VM hosts!
|
# containers identify as virtualization hosts, which makes this tricky, because we have actual Debian VM hosts!
|
||||||
- name: Reconfigure /etc/sysctl.conf
|
- name: Reconfigure /etc/sysctl.conf
|
||||||
when: ansible_virtualization_role != 'host'
|
when: ansible_facts["virtualization_role"] != 'host'
|
||||||
ansible.builtin.template: src=sysctl_{{ ansible_distribution }}.j2 dest=/etc/sysctl.conf owner=root group=root mode=0644
|
ansible.builtin.template:
|
||||||
|
src: "sysctl_{{ ansible_facts['distribution'] }}.j2"
|
||||||
|
dest: /etc/sysctl.conf
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
notify:
|
notify:
|
||||||
- reload sysctl
|
- Reload sysctl
|
||||||
tags: sysctl
|
tags: sysctl
|
||||||
|
|
||||||
- name: Set I/O scheduler
|
- name: Set I/O scheduler
|
||||||
ansible.builtin.template: src=etc/udev/rules.d/60-scheduler.rules.j2 dest=/etc/udev/rules.d/60-scheduler.rules owner=root group=root mode=0644
|
ansible.builtin.template:
|
||||||
|
src: etc/udev/rules.d/60-scheduler.rules.j2
|
||||||
|
dest: /etc/udev/rules.d/60-scheduler.rules
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
tags: udev
|
tags: udev
|
||||||
|
|
||||||
- name: Copy admin SSH keys
|
- name: Copy admin SSH keys
|
||||||
|
|||||||
69
roles/common/tasks/nftables.yml
Normal file
69
roles/common/tasks/nftables.yml
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
---
|
||||||
|
# Common nftables tasks for Debian 11 and Debian 12.
|
||||||
|
|
||||||
|
- name: Copy nftables.conf
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: nftables.conf.j2
|
||||||
|
dest: /etc/nftables.conf
|
||||||
|
owner: root
|
||||||
|
mode: "0644"
|
||||||
|
notify:
|
||||||
|
- Restart nftables
|
||||||
|
|
||||||
|
- name: Create /etc/nftables extra config directory
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/nftables
|
||||||
|
state: directory
|
||||||
|
owner: root
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
|
- name: Copy extra nftables configuration files
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: firehol_level1-ipv4.nft
|
||||||
|
dest: /etc/nftables/firehol_level1-ipv4.nft
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
force: false
|
||||||
|
notify:
|
||||||
|
- Restart nftables
|
||||||
|
|
||||||
|
- name: Copy nftables update scripts
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: update-firehol-nftables.sh.j2
|
||||||
|
dest: /usr/local/bin/update-firehol-nftables.sh
|
||||||
|
mode: "0755"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
|
||||||
|
- name: Copy nftables systemd units
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: "{{ item }}"
|
||||||
|
dest: /etc/systemd/system/{{ item }}
|
||||||
|
mode: "0644"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
loop:
|
||||||
|
- update-firehol-nftables.service
|
||||||
|
- update-firehol-nftables.timer
|
||||||
|
register: nftables_systemd_units
|
||||||
|
|
||||||
|
# need to reload to pick up service/timer/environment changes
|
||||||
|
- name: Reload systemd daemon
|
||||||
|
when: nftables_systemd_units is changed
|
||||||
|
ansible.builtin.systemd_service: # noqa no-handler
|
||||||
|
daemon_reload: true
|
||||||
|
|
||||||
|
- name: Start and enable nftables update timers
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: update-firehol-nftables.timer
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
- name: Start and enable nftables
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: nftables
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# vim: set sw=2 ts=2:
|
||||||
@@ -1,27 +1,40 @@
|
|||||||
---
|
---
|
||||||
# Hosts running Ubuntu 16.04+ and Debian 9+ use systemd init system and should
|
# Hosts running Debian 9+ use systemd init system and can use systemd-timesyncd
|
||||||
# use systemd-timesyncd as a network time client instead of the standalone ntp
|
# as a network time client instead of the standalone ntp client.
|
||||||
# client.
|
|
||||||
|
|
||||||
- name: Set timezone
|
- name: Set timezone
|
||||||
when: timezone is defined and ansible_service_mgr == 'systemd'
|
when:
|
||||||
command: /usr/bin/timedatectl set-timezone {{ timezone }}
|
- timezone is defined
|
||||||
|
- ansible_facts["service_mgr"] == 'systemd'
|
||||||
|
community.general.timezone:
|
||||||
|
name: "{{ timezone }}"
|
||||||
tags: timezone
|
tags: timezone
|
||||||
|
|
||||||
# Apparently some cloud images don't have this installed by default. From what
|
# Apparently some cloud images don't have this installed by default. From what
|
||||||
# I can see on existing servers, systemd-timesyncd is a standalone package on
|
# I can see on existing servers, systemd-timesyncd is a standalone package on
|
||||||
# Ubuntu 20.04 and Debian 11.
|
# Debian 11 and Debian 12.
|
||||||
- name: Install systemd-timesyncd
|
- name: Install systemd-timesyncd
|
||||||
when: (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('20.04', '==')) or
|
when: ansible_facts["distribution_version"] is version('11', '>=')
|
||||||
(ansible_distribution == 'Debian' and ansible_distribution_version is version('11', '>='))
|
ansible.builtin.apt:
|
||||||
ansible.builtin.apt: name=systemd-timesyncd state=present cache_valid_time=3600
|
name: systemd-timesyncd
|
||||||
|
state: present
|
||||||
|
cache_valid_time: 3600
|
||||||
|
|
||||||
- name: Start and enable systemd's NTP client
|
- name: Start and enable systemd's NTP client
|
||||||
when: ansible_service_mgr == 'systemd'
|
when: ansible_facts["service_mgr"] == 'systemd'
|
||||||
ansible.builtin.systemd: name=systemd-timesyncd state=started enabled=true
|
ansible.builtin.systemd_service:
|
||||||
|
name: systemd-timesyncd
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
|
||||||
- name: Uninstall ntp on modern Ubuntu/Debian
|
# On Debian 12 ntp doesn't conflict with systemd-timesyncd so we should try to
|
||||||
ansible.builtin.apt: name=ntp state=absent
|
# remove it to be sure.
|
||||||
when: ansible_service_mgr == 'systemd'
|
- name: Uninstall ntp on Debian 12
|
||||||
|
when:
|
||||||
|
- ansible_facts["service_mgr"] == 'systemd'
|
||||||
|
- ansible_facts["distribution_major_version"] is version('12', '==')
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: ntp
|
||||||
|
state: absent
|
||||||
|
|
||||||
# vim: set ts=2 sw=2:
|
# vim: set ts=2 sw=2:
|
||||||
|
|||||||
@@ -1,20 +1,7 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: Configure Debian packages
|
- name: Configure Debian packages
|
||||||
|
tags: packages
|
||||||
block:
|
block:
|
||||||
# Create directory for third-party package signing keys. Required on distros
|
|
||||||
# older than Debian 12 / Ubuntu 22.04.
|
|
||||||
#
|
|
||||||
# See: https://wiki.debian.org/DebianRepository/UseThirdParty
|
|
||||||
- name: Create /etc/apt/keyrings
|
|
||||||
file:
|
|
||||||
path: /etc/apt/keyrings
|
|
||||||
mode: 0755
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
state: directory
|
|
||||||
when: ansible_distribution_major_version is version('12', '<')
|
|
||||||
|
|
||||||
# Scaleway seems to use a weird sources.list format as of Debian 12?
|
# Scaleway seems to use a weird sources.list format as of Debian 12?
|
||||||
- name: Check for weird Debian sources
|
- name: Check for weird Debian sources
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
@@ -22,10 +9,15 @@
|
|||||||
register: weird_debian_sources_stat
|
register: weird_debian_sources_stat
|
||||||
|
|
||||||
- name: Configure apt mirror
|
- name: Configure apt mirror
|
||||||
ansible.builtin.template: src=sources.list.j2 dest=/etc/apt/sources.list owner=root group=root mode=0644
|
|
||||||
when:
|
when:
|
||||||
- ansible_architecture != 'armv7l'
|
- ansible_facts["architecture"] != 'armv7l'
|
||||||
- not weird_debian_sources_stat
|
- not weird_debian_sources_stat
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: sources.list.j2
|
||||||
|
dest: /etc/apt/sources.list
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
|
||||||
- name: Set fact for base packages
|
- name: Set fact for base packages
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
@@ -36,7 +28,6 @@
|
|||||||
- iotop
|
- iotop
|
||||||
- htop
|
- htop
|
||||||
- strace
|
- strace
|
||||||
- cron-apt
|
|
||||||
- safe-rm
|
- safe-rm
|
||||||
- debian-goodies
|
- debian-goodies
|
||||||
- mosh
|
- mosh
|
||||||
@@ -48,16 +39,19 @@
|
|||||||
- zstd
|
- zstd
|
||||||
- rsync
|
- rsync
|
||||||
- lsof
|
- lsof
|
||||||
|
- unattended-upgrades
|
||||||
|
|
||||||
- name: Install base packages
|
- name: Install base packages
|
||||||
ansible.builtin.apt: name={{ base_packages }} state=present cache_valid_time=3600
|
ansible.builtin.apt:
|
||||||
|
name: "{{ base_packages }}"
|
||||||
|
state: present
|
||||||
|
cache_valid_time: 3600
|
||||||
|
|
||||||
- name: Configure cron-apt
|
- name: Remove cron-apt
|
||||||
ansible.builtin.import_tasks: cron-apt.yml
|
|
||||||
tags: cron-apt
|
tags: cron-apt
|
||||||
|
ansible.builtin.import_tasks: cron-apt.yml
|
||||||
|
|
||||||
- name: Install tarsnap
|
- name: Install tarsnap
|
||||||
ansible.builtin.import_tasks: tarsnap.yml
|
ansible.builtin.import_tasks: tarsnap.yml
|
||||||
tags: packages
|
|
||||||
|
|
||||||
# vim: set sw=2 ts=2:
|
# vim: set sw=2 ts=2:
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
- name: Configure Ubuntu packages
|
|
||||||
block:
|
|
||||||
# Create directory for third-party package signing keys. Required on distros
|
|
||||||
# older than Debian 12 / Ubuntu 22.04.
|
|
||||||
#
|
|
||||||
# See: https://wiki.debian.org/DebianRepository/UseThirdParty
|
|
||||||
- name: Create /etc/apt/keyrings
|
|
||||||
file:
|
|
||||||
path: /etc/apt/keyrings
|
|
||||||
mode: 0755
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
state: directory
|
|
||||||
when: ansible_distribution_major_version is version('22.04', '<')
|
|
||||||
|
|
||||||
- name: Configure apt mirror
|
|
||||||
ansible.builtin.template: src=sources.list.j2 dest=/etc/apt/sources.list owner=root group=root mode=0644
|
|
||||||
when: ansible_architecture != 'armv7l'
|
|
||||||
|
|
||||||
- name: Upgrade base OS
|
|
||||||
ansible.builtin.apt: upgrade=dist cache_valid_time=3600
|
|
||||||
|
|
||||||
- name: Set Ubuntu base packages
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
ubuntu_base_packages:
|
|
||||||
- git
|
|
||||||
- git-lfs
|
|
||||||
- tmux
|
|
||||||
- iotop
|
|
||||||
- htop
|
|
||||||
- strace
|
|
||||||
- cron-apt
|
|
||||||
- safe-rm
|
|
||||||
- debian-goodies
|
|
||||||
- mosh
|
|
||||||
- python-pycurl # for ansible's apt_repository
|
|
||||||
- vim
|
|
||||||
- unzip
|
|
||||||
- apt-transport-https # for https support in apt
|
|
||||||
- zstd
|
|
||||||
- rsync
|
|
||||||
- lsof
|
|
||||||
|
|
||||||
- name: Install base packages
|
|
||||||
ansible.builtin.apt: pkg={{ ubuntu_base_packages }} state=present cache_valid_time=3600
|
|
||||||
|
|
||||||
# We have to remove snaps one by one in a specific order because some depend
|
|
||||||
# on others. Only after that can we remove the corresponding system packages.
|
|
||||||
- name: Remove lxd snap
|
|
||||||
community.general.snap: name=lxd state=absent
|
|
||||||
when: ansible_distribution_version is version('20.04', '==')
|
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
- name: Remove core18 snap
|
|
||||||
community.general.snap: name=core18 state=absent
|
|
||||||
when: ansible_distribution_version is version('20.04', '==')
|
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
- name: Remove snapd snap
|
|
||||||
community.general.snap: name=snapd state=absent
|
|
||||||
when: ansible_distribution_version is version('20.04', '==')
|
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
- name: Set fact for packages to remove (Ubuntu 20.04)
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
ubuntu_annoying_packages:
|
|
||||||
- whoopsie # security (CIS 4.1)
|
|
||||||
- apport # security (CIS 4.1)
|
|
||||||
- command-not-found # annoying
|
|
||||||
- command-not-found-data # annoying
|
|
||||||
- python3-commandnotfound # annoying
|
|
||||||
- snapd # annoying (Ubuntu >= 16.04)
|
|
||||||
- lxd-agent-loader # annoying (Ubuntu 20.04)
|
|
||||||
when: ansible_distribution_version is version('20.04', '==')
|
|
||||||
|
|
||||||
- name: Remove packages
|
|
||||||
ansible.builtin.apt: name={{ ubuntu_annoying_packages }} state=absent purge=true
|
|
||||||
|
|
||||||
- name: Disable annoying Canonical spam in MOTD
|
|
||||||
ansible.builtin.file: path={{ item }} mode=0644 state=absent
|
|
||||||
loop:
|
|
||||||
- /etc/update-motd.d/99-esm # Ubuntu 14.04
|
|
||||||
- /etc/update-motd.d/10-help-text # Ubuntu 14.04+
|
|
||||||
- /etc/update-motd.d/50-motd-news # Ubuntu 18.04+
|
|
||||||
- /etc/update-motd.d/80-esm # Ubuntu 18.04+
|
|
||||||
- /etc/update-motd.d/80-livepatch # Ubuntu 18.04+
|
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
- name: Disable annoying Canonical spam in MOTD
|
|
||||||
ansible.builtin.systemd: name={{ item }} state=stopped enabled=no
|
|
||||||
when: ansible_service_mgr == 'systemd'
|
|
||||||
loop:
|
|
||||||
- motd-news.service
|
|
||||||
- motd-news.timer
|
|
||||||
|
|
||||||
- name: Configure cron-apt
|
|
||||||
ansible.builtin.import_tasks: cron-apt.yml
|
|
||||||
tags: cron-apt
|
|
||||||
|
|
||||||
- name: Install tarsnap
|
|
||||||
ansible.builtin.import_tasks: tarsnap.yml
|
|
||||||
tags: packages
|
|
||||||
|
|
||||||
# vim: set sw=2 ts=2:
|
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
---
|
---
|
||||||
- name: Zero .ssh/authorized_keys for provisioning user
|
- name: Zero .ssh/authorized_keys for provisioning user
|
||||||
ansible.builtin.file: dest={{ provisioning_user.home }}/.ssh/authorized_keys state=absent
|
ansible.builtin.file:
|
||||||
|
dest: "{{ provisioning_user.home }}/.ssh/authorized_keys"
|
||||||
|
state: absent
|
||||||
|
|
||||||
- name: Add public keys to authorized_keys
|
- name: Add public keys to authorized_keys
|
||||||
ansible.posix.authorized_key: { user: '{{ provisioning_user.name }}', key: "{{ lookup('file',item) }}" }
|
ansible.posix.authorized_key: { user: "{{ provisioning_user.name }}", key: "{{ lookup('file', item) }}" }
|
||||||
with_fileglob:
|
with_fileglob:
|
||||||
# use descriptive names for keys, like: aorth-mzito-rsa.pub
|
# use descriptive names for keys, like: aorth-mzito-rsa.pub
|
||||||
- ssh-pub-keys/*.pub
|
- ssh-pub-keys/*.pub
|
||||||
|
|||||||
@@ -1,17 +1,26 @@
|
|||||||
---
|
---
|
||||||
|
# Only override the system sshd configuration on older Debian.
|
||||||
# SSH configs don't change in Debian minor versions
|
|
||||||
- name: Reconfigure /etc/ssh/sshd_config
|
- name: Reconfigure /etc/ssh/sshd_config
|
||||||
ansible.builtin.template: src=sshd_config_{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.j2 dest=/etc/ssh/sshd_config owner=root group=root mode=0600
|
when: ansible_facts["distribution_version"] is version('12', '<=')
|
||||||
when: ansible_distribution == 'Debian'
|
ansible.builtin.template:
|
||||||
notify: reload sshd
|
src: "sshd_config_{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_major_version'] }}.j2"
|
||||||
|
dest: /etc/ssh/sshd_config
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0600"
|
||||||
|
notify: Reload sshd
|
||||||
|
|
||||||
# Ubuntu is the only distro we have where SSH version is very different from 14.04 -> 14.10,
|
# Newer OpenSSH versions support including extra configuration. The includes
|
||||||
# ie with new ciphers supported etc.
|
# happen at the beginning of the file and the first value to be read is used.
|
||||||
- name: Reconfigure /etc/ssh/sshd_config
|
- name: Configure sshd_config.d overrides
|
||||||
ansible.builtin.template: src=sshd_config_{{ ansible_distribution }}-{{ ansible_distribution_version }}.j2 dest=/etc/ssh/sshd_config owner=root group=root mode=0600
|
when: ansible_facts["distribution_version"] is version('13', '>=')
|
||||||
when: ansible_distribution == 'Ubuntu'
|
ansible.builtin.template:
|
||||||
notify: reload sshd
|
src: etc/ssh/sshd_config.d/01-{{ ansible_facts["distribution"] }}-{{ ansible_facts["distribution_major_version"] }}.conf.j2
|
||||||
|
dest: /etc/ssh/sshd_config.d/01-custom.conf
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0600"
|
||||||
|
notify: Reload sshd
|
||||||
|
|
||||||
# See: WeakDH (2015): https://weakdh.org/sysadmin.html
|
# See: WeakDH (2015): https://weakdh.org/sysadmin.html
|
||||||
- name: Remove small Diffie-Hellman SSH moduli
|
- name: Remove small Diffie-Hellman SSH moduli
|
||||||
@@ -24,28 +33,30 @@
|
|||||||
register: check_unsafe_moduli
|
register: check_unsafe_moduli
|
||||||
|
|
||||||
- name: Extract safe Diffie-Hellman SSH moduli
|
- name: Extract safe Diffie-Hellman SSH moduli
|
||||||
|
when: check_unsafe_moduli.stdout | length > 0
|
||||||
ansible.builtin.shell:
|
ansible.builtin.shell:
|
||||||
cmd: awk '$5 >= 3071' moduli > moduli.safe
|
cmd: awk '$5 >= 3071' moduli > moduli.safe
|
||||||
chdir: /etc/ssh
|
chdir: /etc/ssh
|
||||||
creates: moduli.safe
|
creates: moduli.safe
|
||||||
when: check_unsafe_moduli.stdout | length > 0
|
|
||||||
register: extract_safe_moduli
|
register: extract_safe_moduli
|
||||||
|
|
||||||
- name: Replace unsafe Diffie-Hellman SSH moduli
|
- name: Replace unsafe Diffie-Hellman SSH moduli
|
||||||
|
when: extract_safe_moduli is changed
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
cmd: mv moduli.safe moduli
|
cmd: mv moduli.safe moduli
|
||||||
chdir: /etc/ssh
|
chdir: /etc/ssh
|
||||||
register: replace_small_moduli
|
register: replace_small_moduli
|
||||||
when: extract_safe_moduli is changed
|
notify: Reload sshd
|
||||||
notify: reload sshd
|
|
||||||
|
|
||||||
- name: Remove DSA and ECDSA host keys
|
- name: Remove DSA and ECDSA host keys
|
||||||
ansible.builtin.file: name=/etc/ssh/{{ item }} state=absent
|
ansible.builtin.file:
|
||||||
|
name: "/etc/ssh/{{ item }}"
|
||||||
|
state: absent
|
||||||
loop:
|
loop:
|
||||||
- ssh_host_dsa_key
|
- ssh_host_dsa_key
|
||||||
- ssh_host_dsa_key.pub
|
- ssh_host_dsa_key.pub
|
||||||
- ssh_host_ecdsa_key
|
- ssh_host_ecdsa_key
|
||||||
- ssh_host_ecdsa_key.pub
|
- ssh_host_ecdsa_key.pub
|
||||||
notify: reload sshd
|
notify: Reload sshd
|
||||||
|
|
||||||
# vim: set sw=2 ts=2:
|
# vim: set sw=2 ts=2:
|
||||||
|
|||||||
@@ -1,24 +1,45 @@
|
|||||||
---
|
---
|
||||||
- name: Add Tarsnap apt mirror
|
- name: Check tarsnap apt signing key
|
||||||
ansible.builtin.template: src=tarsnap_sources.list.j2 dest=/etc/apt/sources.list.d/tarsnap.list owner=root group=root mode=0644
|
ansible.builtin.stat:
|
||||||
register: add_tarsnap_apt_repository
|
path: /etc/apt/keyrings/tarsnap-deb-packaging-key.asc
|
||||||
when: ansible_architecture != 'armv7l'
|
register: tarsnap_signing_key_stat
|
||||||
|
|
||||||
- name: Add GPG key for Tarsnap
|
- name: Download tarsnap apt signing key
|
||||||
ansible.builtin.apt_key: id=0xF608BA1BFB5CE8F8CAB088359F084BEE7F938A76 url=https://pkg.tarsnap.com/tarsnap-deb-packaging-key.asc state=present
|
when: not tarsnap_signing_key_stat.stat.exists
|
||||||
register: add_tarsnap_apt_key
|
ansible.builtin.get_url:
|
||||||
|
url: https://pkg.tarsnap.com/tarsnap-deb-packaging-key.asc
|
||||||
|
dest: /etc/apt/keyrings/tarsnap-deb-packaging-key.asc
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
register: download_tarsnap_signing_key
|
||||||
|
|
||||||
|
- name: Add tarsnap.org repo
|
||||||
|
when: ansible_facts["architecture"] != 'armv7l'
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: tarsnap_sources.list.j2
|
||||||
|
dest: /etc/apt/sources.list.d/tarsnap.list
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
register: add_tarsnap_apt_repository
|
||||||
|
|
||||||
- name: Update apt cache
|
- name: Update apt cache
|
||||||
ansible.builtin.apt:
|
when: (download_tarsnap_signing_key.status_code is defined and download_tarsnap_signing_key.status_code == 200) or add_tarsnap_apt_repository is changed
|
||||||
|
ansible.builtin.apt: # noqa no-handler
|
||||||
update_cache: true
|
update_cache: true
|
||||||
when:
|
|
||||||
add_tarsnap_apt_key is changed or
|
|
||||||
add_tarsnap_apt_repository is changed
|
|
||||||
|
|
||||||
- name: Install tarsnap
|
- name: Install tarsnap
|
||||||
ansible.builtin.apt: pkg=tarsnap cache_valid_time=3600
|
ansible.builtin.apt:
|
||||||
|
pkg: tarsnap
|
||||||
|
cache_valid_time: 3600
|
||||||
|
|
||||||
- name: Copy tarsnaprc
|
- name: Copy tarsnaprc
|
||||||
ansible.builtin.copy: src=tarsnaprc dest=/root/.tarsnaprc owner=root group=root mode=0600
|
ansible.builtin.copy:
|
||||||
|
src: tarsnaprc
|
||||||
|
dest: /root/.tarsnaprc
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0600"
|
||||||
|
|
||||||
# vim: set sw=2 ts=2:
|
# vim: set sw=2 ts=2:
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
{{ ansible_managed | comment }}
|
||||||
|
|
||||||
|
HostKey /etc/ssh/ssh_host_ed25519_key
|
||||||
|
|
||||||
|
# LogLevel VERBOSE logs user's key fingerprint on login. Needed to have a clear
|
||||||
|
# audit track of which key was using to log in.
|
||||||
|
LogLevel VERBOSE
|
||||||
|
|
||||||
|
MaxAuthTries 4
|
||||||
|
|
||||||
|
AuthorizedKeysFile .ssh/authorized_keys
|
||||||
|
|
||||||
|
# To disable tunneled clear text passwords, change to no here!
|
||||||
|
{% if ssh_password_authentication == 'disabled' %}
|
||||||
|
PasswordAuthentication no
|
||||||
|
{% else %}
|
||||||
|
PasswordAuthentication yes
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
X11Forwarding no
|
||||||
|
|
||||||
|
# Based on the ssh-audit profile for Debian 13, but with but with all algos with
|
||||||
|
# less than 256 bits removed, as NSA's Suite B removed them years ago and the
|
||||||
|
# new (2018) CNSA suite is 256 bits and up.
|
||||||
|
#
|
||||||
|
# See: ssh-audit.py -P "Hardened Debian 13 (version 1)"
|
||||||
|
# See: https://en.wikipedia.org/wiki/Commercial_National_Security_Algorithm_Suite
|
||||||
|
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes256-ctr
|
||||||
|
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com
|
||||||
|
KexAlgorithms mlkem768x25519-sha256,sntrup761x25519-sha512,sntrup761x25519-sha512@openssh.com
|
||||||
|
|
||||||
|
{% if ssh_allowed_users is defined and ssh_allowed_users %}
|
||||||
|
AllowUsers {{ ssh_allowed_users|join(" ") }} {{ provisioning_user.name }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
PerSourcePenaltyExemptList {{ fail2ban_ignoreip | replace(" ", ",") }}
|
||||||
|
|
||||||
|
# Mask to use for IPv4 and IPv6 respectively when applying network penalties.
|
||||||
|
# The default is 32:128.
|
||||||
|
PerSourceNetBlockSize 24:56
|
||||||
@@ -1,15 +1,19 @@
|
|||||||
|
[Unit]
|
||||||
|
# If nftables is stopped or restarted, propagate to fail2ban as well
|
||||||
|
PartOf=nftables.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
PrivateDevices=yes
|
PrivateDevices=yes
|
||||||
PrivateTmp=yes
|
PrivateTmp=yes
|
||||||
ProtectHome=read-only
|
ProtectHome=read-only
|
||||||
{% if (ansible_distribution == 'Ubuntu' and ansible_distribution_major_version is version('18','>=')) or (ansible_distribution == 'Debian' and ansible_distribution_major_version is version('11','>=')) %}
|
{% if ansible_facts["distribution_version"] is version('11','>=') %}
|
||||||
ProtectSystem=strict
|
ProtectSystem=strict
|
||||||
{% else %}
|
{% else %}
|
||||||
{# Older systemd versions don't have ProtectSystem=strict #}
|
{# Older systemd versions don't have ProtectSystem=strict #}
|
||||||
ProtectSystem=full
|
ProtectSystem=full
|
||||||
{% endif %}
|
{% endif %}
|
||||||
NoNewPrivileges=yes
|
NoNewPrivileges=yes
|
||||||
{% if (ansible_distribution == 'Ubuntu' and ansible_distribution_major_version is version('18','>=')) or (ansible_distribution == 'Debian' and ansible_distribution_major_version is version('11','>=')) %}
|
{% if ansible_facts["distribution_version"] is version('11','>=') %}
|
||||||
ReadWritePaths=-/var/run/fail2ban
|
ReadWritePaths=-/var/run/fail2ban
|
||||||
ReadWritePaths=-/var/lib/fail2ban
|
ReadWritePaths=-/var/lib/fail2ban
|
||||||
ReadWritePaths=-/var/log/fail2ban.log
|
ReadWritePaths=-/var/log/fail2ban.log
|
||||||
|
|||||||
@@ -5,47 +5,18 @@
|
|||||||
|
|
||||||
flush ruleset
|
flush ruleset
|
||||||
|
|
||||||
# Lists updated daily by update-spamhaus-nftables.sh
|
# List updated daily by update-firehol-nftables.sh
|
||||||
include "/etc/nftables/spamhaus-ipv4.nft"
|
include "/etc/nftables/firehol_level1-ipv4.nft"
|
||||||
include "/etc/nftables/spamhaus-ipv6.nft"
|
|
||||||
|
|
||||||
# Lists updated monthly (manually)
|
|
||||||
include "/etc/nftables/abuseipdb-ipv4.nft"
|
|
||||||
include "/etc/nftables/abuseipdb-ipv6.nft"
|
|
||||||
|
|
||||||
# Lists updated daily by update-abusech-nftables.sh
|
|
||||||
include "/etc/nftables/abusech-ipv4.nft"
|
|
||||||
|
|
||||||
# Notes:
|
# Notes:
|
||||||
# - tables hold chains, chains hold rules
|
# - tables hold chains, chains hold rules
|
||||||
# - inet is for both ipv4 and ipv6
|
# - inet is for both ipv4 and ipv6
|
||||||
table inet filter {
|
table inet filter {
|
||||||
set spamhaus-ipv4 {
|
set firehol_level1-ipv4 {
|
||||||
type ipv4_addr
|
type ipv4_addr
|
||||||
# if the set contains prefixes we need to use the interval flag
|
# if the set contains prefixes we need to use the interval flag
|
||||||
flags interval
|
flags interval
|
||||||
elements = $SPAMHAUS_IPV4
|
elements = $FIREHOL_LEVEL1_IPV4
|
||||||
}
|
|
||||||
|
|
||||||
set spamhaus-ipv6 {
|
|
||||||
type ipv6_addr
|
|
||||||
flags interval
|
|
||||||
elements = $SPAMHAUS_IPV6
|
|
||||||
}
|
|
||||||
|
|
||||||
set abusech-ipv4 {
|
|
||||||
type ipv4_addr
|
|
||||||
elements = $ABUSECH_IPV4
|
|
||||||
}
|
|
||||||
|
|
||||||
set abuseipdb-ipv4 {
|
|
||||||
type ipv4_addr
|
|
||||||
elements = $ABUSEIPDB_IPV4
|
|
||||||
}
|
|
||||||
|
|
||||||
set abuseipdb-ipv6 {
|
|
||||||
type ipv6_addr
|
|
||||||
elements = $ABUSEIPDB_IPV6
|
|
||||||
}
|
}
|
||||||
|
|
||||||
chain input {
|
chain input {
|
||||||
@@ -55,13 +26,7 @@ table inet filter {
|
|||||||
|
|
||||||
ct state invalid counter drop comment "Early drop of invalid connections"
|
ct state invalid counter drop comment "Early drop of invalid connections"
|
||||||
|
|
||||||
ip saddr @spamhaus-ipv4 counter drop comment "Early drop of incoming packets matching spamhaus-ipv4 list"
|
ip saddr @firehol_level1-ipv4 counter drop comment "Early drop of incoming packets matching firehol_level1-ipv4 list"
|
||||||
ip6 saddr @spamhaus-ipv6 counter drop comment "Early drop of incoming packets matching spamhaus-ipv6 list"
|
|
||||||
|
|
||||||
ip saddr @abusech-ipv4 counter drop comment "Early drop of packets matching abusech-ipv4 list"
|
|
||||||
|
|
||||||
ip saddr @abuseipdb-ipv4 counter drop comment "Early drop of incoming packets matching abuseipdb-ipv4 list"
|
|
||||||
ip6 saddr @abuseipdb-ipv6 counter drop comment "Early drop of incoming packets matching abuseipdb-ipv6 list"
|
|
||||||
|
|
||||||
iifname lo accept comment "Allow from loopback"
|
iifname lo accept comment "Allow from loopback"
|
||||||
|
|
||||||
@@ -105,12 +70,6 @@ table inet filter {
|
|||||||
chain output {
|
chain output {
|
||||||
type filter hook output priority 0;
|
type filter hook output priority 0;
|
||||||
|
|
||||||
ip daddr @spamhaus-ipv4 counter drop comment "Drop outgoing packets matching spamhaus-ipv4 list"
|
ip daddr @firehol_level1-ipv4 counter drop comment "Drop outgoing packets matching firehol_level1-ipv4 list"
|
||||||
ip6 daddr @spamhaus-ipv6 counter drop comment "Drop outgoing packets matching spamhaus-ipv6 list"
|
|
||||||
|
|
||||||
ip daddr @abusech-ipv4 counter drop comment "Drop outgoing packets matching abusech-ipv4 list"
|
|
||||||
|
|
||||||
ip daddr @abuseipdb-ipv4 counter drop comment "Drop outgoing packets matching abuseipdb-ipv4 list"
|
|
||||||
ip6 daddr @abuseipdb-ipv6 counter drop comment "Drop outgoing packets matching abuseipdb-ipv6 list"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
{% if ansible_distribution == 'Ubuntu' %}
|
|
||||||
deb http://security.ubuntu.com/ubuntu {{ ansible_distribution_release }}-security main restricted universe multiverse
|
|
||||||
{% elif ansible_distribution == 'Debian' %}
|
|
||||||
deb http://security.debian.org/debian-security {{ ansible_distribution_release }}/updates main contrib non-free
|
|
||||||
{% endif %}
|
|
||||||
@@ -1,16 +1,6 @@
|
|||||||
{% if ansible_distribution == 'Ubuntu' %}
|
|
||||||
{% set apt_mirror = apt_mirror | default("ubuntu.mirror.ac.ke") %}
|
|
||||||
|
|
||||||
deb http://{{ apt_mirror }}/ubuntu/ {{ ansible_distribution_release }} main restricted universe multiverse
|
|
||||||
deb http://{{ apt_mirror }}/ubuntu/ {{ ansible_distribution_release }}-updates main restricted universe multiverse
|
|
||||||
deb http://security.ubuntu.com/ubuntu/ {{ ansible_distribution_release }}-security main restricted universe multiverse
|
|
||||||
|
|
||||||
{% else %}
|
|
||||||
{% set apt_mirror = apt_mirror | default('deb.debian.org') %}
|
{% set apt_mirror = apt_mirror | default('deb.debian.org') %}
|
||||||
deb http://{{ apt_mirror }}/debian/ {{ ansible_distribution_release }} main contrib non-free
|
deb http://{{ apt_mirror }}/debian/ {{ ansible_distribution_release }} main contrib non-free
|
||||||
|
|
||||||
deb http://security.debian.org/debian-security {{ ansible_distribution_release }}-security main contrib non-free
|
deb http://security.debian.org/debian-security {{ ansible_distribution_release }}-security main contrib non-free
|
||||||
|
|
||||||
deb http://{{ apt_mirror }}/debian/ {{ ansible_distribution_release }}-updates main contrib non-free
|
deb http://{{ apt_mirror }}/debian/ {{ ansible_distribution_release }}-updates main contrib non-free
|
||||||
|
|
||||||
{% endif %} {# ansible_distribution #}
|
|
||||||
|
|||||||
@@ -1,143 +0,0 @@
|
|||||||
# $OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $
|
|
||||||
|
|
||||||
# This is the sshd server system-wide configuration file. See
|
|
||||||
# sshd_config(5) for more information.
|
|
||||||
|
|
||||||
# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin
|
|
||||||
|
|
||||||
# The strategy used for options in the default sshd_config shipped with
|
|
||||||
# OpenSSH is to specify options with their default value where
|
|
||||||
# possible, but leave them commented. Uncommented options override the
|
|
||||||
# default value.
|
|
||||||
|
|
||||||
Include /etc/ssh/sshd_config.d/*.conf
|
|
||||||
|
|
||||||
#Port 22
|
|
||||||
#AddressFamily any
|
|
||||||
#ListenAddress 0.0.0.0
|
|
||||||
#ListenAddress ::
|
|
||||||
|
|
||||||
#HostKey /etc/ssh/ssh_host_rsa_key
|
|
||||||
HostKey /etc/ssh/ssh_host_ed25519_key
|
|
||||||
|
|
||||||
# Ciphers and keying
|
|
||||||
#RekeyLimit default none
|
|
||||||
|
|
||||||
# Logging
|
|
||||||
#SyslogFacility AUTH
|
|
||||||
# LogLevel VERBOSE logs user's key fingerprint on login. Needed to have a clear audit track of which key was using to log in.
|
|
||||||
LogLevel VERBOSE
|
|
||||||
|
|
||||||
# Authentication:
|
|
||||||
|
|
||||||
#LoginGraceTime 2m
|
|
||||||
PermitRootLogin prohibit-password
|
|
||||||
#StrictModes yes
|
|
||||||
MaxAuthTries 4
|
|
||||||
#MaxSessions 10
|
|
||||||
|
|
||||||
#PubkeyAuthentication yes
|
|
||||||
|
|
||||||
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
|
|
||||||
# but this is overridden so installations will only check .ssh/authorized_keys
|
|
||||||
AuthorizedKeysFile .ssh/authorized_keys
|
|
||||||
|
|
||||||
#AuthorizedPrincipalsFile none
|
|
||||||
|
|
||||||
#AuthorizedKeysCommand none
|
|
||||||
#AuthorizedKeysCommandUser nobody
|
|
||||||
|
|
||||||
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
|
|
||||||
#HostbasedAuthentication no
|
|
||||||
# Change to yes if you don't trust ~/.ssh/known_hosts for
|
|
||||||
# HostbasedAuthentication
|
|
||||||
#IgnoreUserKnownHosts no
|
|
||||||
# Don't read the user's ~/.rhosts and ~/.shosts files
|
|
||||||
#IgnoreRhosts yes
|
|
||||||
|
|
||||||
# To disable tunneled clear text passwords, change to no here!
|
|
||||||
{% if ssh_password_authentication == 'disabled' %}
|
|
||||||
PasswordAuthentication no
|
|
||||||
{% else %}
|
|
||||||
PasswordAuthentication yes
|
|
||||||
{% endif %}
|
|
||||||
#PermitEmptyPasswords no
|
|
||||||
|
|
||||||
# Change to yes to enable challenge-response passwords (beware issues with
|
|
||||||
# some PAM modules and threads)
|
|
||||||
ChallengeResponseAuthentication no
|
|
||||||
|
|
||||||
# Kerberos options
|
|
||||||
#KerberosAuthentication no
|
|
||||||
#KerberosOrLocalPasswd yes
|
|
||||||
#KerberosTicketCleanup yes
|
|
||||||
#KerberosGetAFSToken no
|
|
||||||
|
|
||||||
# GSSAPI options
|
|
||||||
#GSSAPIAuthentication no
|
|
||||||
#GSSAPICleanupCredentials yes
|
|
||||||
#GSSAPIStrictAcceptorCheck yes
|
|
||||||
#GSSAPIKeyExchange no
|
|
||||||
|
|
||||||
# Set this to 'yes' to enable PAM authentication, account processing,
|
|
||||||
# and session processing. If this is enabled, PAM authentication will
|
|
||||||
# be allowed through the ChallengeResponseAuthentication and
|
|
||||||
# PasswordAuthentication. Depending on your PAM configuration,
|
|
||||||
# PAM authentication via ChallengeResponseAuthentication may bypass
|
|
||||||
# the setting of "PermitRootLogin without-password".
|
|
||||||
# If you just want the PAM account and session checks to run without
|
|
||||||
# PAM authentication, then enable this but set PasswordAuthentication
|
|
||||||
# and ChallengeResponseAuthentication to 'no'.
|
|
||||||
UsePAM yes
|
|
||||||
|
|
||||||
#AllowAgentForwarding yes
|
|
||||||
#AllowTcpForwarding yes
|
|
||||||
#GatewayPorts no
|
|
||||||
X11Forwarding no
|
|
||||||
#X11DisplayOffset 10
|
|
||||||
#X11UseLocalhost yes
|
|
||||||
#PermitTTY yes
|
|
||||||
PrintMotd no
|
|
||||||
#PrintLastLog yes
|
|
||||||
#TCPKeepAlive yes
|
|
||||||
#PermitUserEnvironment no
|
|
||||||
#Compression delayed
|
|
||||||
#ClientAliveInterval 0
|
|
||||||
#ClientAliveCountMax 3
|
|
||||||
#UseDNS no
|
|
||||||
#PidFile /var/run/sshd.pid
|
|
||||||
#MaxStartups 10:30:100
|
|
||||||
#PermitTunnel no
|
|
||||||
#ChrootDirectory none
|
|
||||||
#VersionAddendum none
|
|
||||||
|
|
||||||
# no default banner path
|
|
||||||
#Banner none
|
|
||||||
|
|
||||||
# Allow client to pass locale environment variables
|
|
||||||
AcceptEnv LANG LC_*
|
|
||||||
|
|
||||||
# override default of no subsystems
|
|
||||||
Subsystem sftp /usr/lib/openssh/sftp-server
|
|
||||||
|
|
||||||
# Example of overriding settings on a per-user basis
|
|
||||||
#Match User anoncvs
|
|
||||||
# X11Forwarding no
|
|
||||||
# AllowTcpForwarding no
|
|
||||||
# PermitTTY no
|
|
||||||
# ForceCommand cvs server
|
|
||||||
|
|
||||||
# Originally from: https://stribika.github.io/2015/01/04/secure-secure-shell.html
|
|
||||||
# ... but with ciphers and MACs with < 256 bits removed, as NSA's Suite B now
|
|
||||||
# does away with these! See: https://www.nsa.gov/ia/programs/suiteb_cryptography/index.shtml
|
|
||||||
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes256-ctr
|
|
||||||
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com
|
|
||||||
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256
|
|
||||||
|
|
||||||
{% if ssh_allowed_users is defined and ssh_allowed_users %}
|
|
||||||
# Is there a list of allowed users?
|
|
||||||
# Is it populated? (An empty list is 'None', which evaluates as False in Python)
|
|
||||||
# merge the items of a list into one string using a space as a separator
|
|
||||||
# http://jinja.pocoo.org/docs/dev/templates/#join
|
|
||||||
AllowUsers {{ ssh_allowed_users|join(" ") }} {{ provisioning_user.name }}
|
|
||||||
{% endif %}
|
|
||||||
@@ -90,7 +90,7 @@ net.ipv4.tcp_wmem = 4096 65536 16777216
|
|||||||
# increase the length of the processor input queue
|
# increase the length of the processor input queue
|
||||||
net.core.netdev_max_backlog = 30000
|
net.core.netdev_max_backlog = 30000
|
||||||
{# kernels after 2.6.32 don't have buggy cubic #}
|
{# kernels after 2.6.32 don't have buggy cubic #}
|
||||||
{% if ansible_kernel < "2.6.33" %}
|
{% if ansible_facts["kernel"] < "2.6.33" %}
|
||||||
# recommended default congestion control is htcp
|
# recommended default congestion control is htcp
|
||||||
net.ipv4.tcp_congestion_control=htcp
|
net.ipv4.tcp_congestion_control=htcp
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -98,7 +98,7 @@ net.ipv4.tcp_congestion_control=htcp
|
|||||||
#net.ipv4.tcp_mtu_probing=1
|
#net.ipv4.tcp_mtu_probing=1
|
||||||
|
|
||||||
{# disable iptables on bridge interfaces on VM hosts #}
|
{# disable iptables on bridge interfaces on VM hosts #}
|
||||||
{% if ansible_virtualization_role == "host" %}
|
{% if ansible_facts["virtualization_role"] == "host" %}
|
||||||
net.bridge.bridge-nf-call-ip6tables = 0
|
net.bridge.bridge-nf-call-ip6tables = 0
|
||||||
net.bridge.bridge-nf-call-iptables = 0
|
net.bridge.bridge-nf-call-iptables = 0
|
||||||
net.bridge.bridge-nf-call-arptables = 0
|
net.bridge.bridge-nf-call-arptables = 0
|
||||||
|
|||||||
@@ -1,100 +0,0 @@
|
|||||||
#
|
|
||||||
# /etc/sysctl.conf - Configuration file for setting system variables
|
|
||||||
# See /etc/sysctl.d/ for additional system variables
|
|
||||||
# See sysctl.conf (5) for information.
|
|
||||||
#
|
|
||||||
|
|
||||||
#kernel.domainname = example.com
|
|
||||||
|
|
||||||
# Uncomment the following to stop low-level messages on console
|
|
||||||
#kernel.printk = 3 4 1 3
|
|
||||||
|
|
||||||
##############################################################3
|
|
||||||
# Functions previously found in netbase
|
|
||||||
#
|
|
||||||
|
|
||||||
# Uncomment the next two lines to enable Spoof protection (reverse-path filter)
|
|
||||||
# Turn on Source Address Verification in all interfaces to
|
|
||||||
# prevent some spoofing attacks
|
|
||||||
#net.ipv4.conf.default.rp_filter=1
|
|
||||||
#net.ipv4.conf.all.rp_filter=1
|
|
||||||
|
|
||||||
# Uncomment the next line to enable TCP/IP SYN cookies
|
|
||||||
# See http://lwn.net/Articles/277146/
|
|
||||||
# Note: This may impact IPv6 TCP sessions too
|
|
||||||
#net.ipv4.tcp_syncookies=1
|
|
||||||
|
|
||||||
# Uncomment the next line to enable packet forwarding for IPv4
|
|
||||||
#net.ipv4.ip_forward=1
|
|
||||||
|
|
||||||
# Uncomment the next line to enable packet forwarding for IPv6
|
|
||||||
# Enabling this option disables Stateless Address Autoconfiguration
|
|
||||||
# based on Router Advertisements for this host
|
|
||||||
#net.ipv6.conf.all.forwarding=1
|
|
||||||
|
|
||||||
|
|
||||||
###################################################################
|
|
||||||
# Additional settings - these settings can improve the network
|
|
||||||
# security of the host and prevent against some network attacks
|
|
||||||
# including spoofing attacks and man in the middle attacks through
|
|
||||||
# redirection. Some network environments, however, require that these
|
|
||||||
# settings are disabled so review and enable them as needed.
|
|
||||||
#
|
|
||||||
# Do not accept ICMP redirects (prevent MITM attacks)
|
|
||||||
#net.ipv4.conf.all.accept_redirects = 0
|
|
||||||
#net.ipv6.conf.all.accept_redirects = 0
|
|
||||||
# _or_
|
|
||||||
# Accept ICMP redirects only for gateways listed in our default
|
|
||||||
# gateway list (enabled by default)
|
|
||||||
# net.ipv4.conf.all.secure_redirects = 1
|
|
||||||
#
|
|
||||||
# Do not send ICMP redirects (we are not a router)
|
|
||||||
#net.ipv4.conf.all.send_redirects = 0
|
|
||||||
#
|
|
||||||
# Do not accept IP source route packets (we are not a router)
|
|
||||||
#net.ipv4.conf.all.accept_source_route = 0
|
|
||||||
#net.ipv6.conf.all.accept_source_route = 0
|
|
||||||
#
|
|
||||||
# Log Martian Packets
|
|
||||||
#net.ipv4.conf.all.log_martians = 1
|
|
||||||
#
|
|
||||||
|
|
||||||
# CIS Benchmark Adjustments
|
|
||||||
# See: https://github.com/alanorth/securekickstarts
|
|
||||||
kernel.randomize_va_space = 2
|
|
||||||
net.ipv4.ip_forward = 0
|
|
||||||
net.ipv4.conf.all.send_redirects = 0
|
|
||||||
net.ipv4.conf.default.send_redirects = 0
|
|
||||||
net.ipv4.conf.all.accept_source_route = 0
|
|
||||||
net.ipv4.conf.default.accept_source_route = 0
|
|
||||||
net.ipv4.conf.all.accept_redirects = 0
|
|
||||||
net.ipv4.conf.default.accept_redirects = 0
|
|
||||||
net.ipv4.conf.all.secure_redirects = 0
|
|
||||||
net.ipv4.conf.default.secure_redirects = 0
|
|
||||||
net.ipv4.conf.all.log_martians = 1
|
|
||||||
net.ipv4.conf.default.log_martians = 1
|
|
||||||
net.ipv4.icmp_echo_ignore_broadcasts = 1
|
|
||||||
net.ipv4.icmp_ignore_bogus_error_responses = 1
|
|
||||||
net.ipv4.conf.all.rp_filter = 1
|
|
||||||
net.ipv4.conf.default.rp_filter = 1
|
|
||||||
net.ipv4.tcp_syncookies = 1
|
|
||||||
|
|
||||||
# TCP stuff
|
|
||||||
# See: http://fasterdata.es.net/host-tuning/linux/
|
|
||||||
# increase TCP max buffer size settable using setsockopt()
|
|
||||||
net.core.rmem_max = 16777216
|
|
||||||
net.core.wmem_max = 16777216
|
|
||||||
# increase Linux autotuning TCP buffer limit
|
|
||||||
net.ipv4.tcp_rmem = 4096 87380 16777216
|
|
||||||
net.ipv4.tcp_wmem = 4096 65536 16777216
|
|
||||||
# increase the length of the processor input queue
|
|
||||||
net.core.netdev_max_backlog = 30000
|
|
||||||
# recommended for hosts with jumbo frames enabled
|
|
||||||
#net.ipv4.tcp_mtu_probing=1
|
|
||||||
|
|
||||||
# increase quadruplets (src ip, src port, dest ip, dest port)
|
|
||||||
# see: http://vincent.bernat.im/en/blog/2014-tcp-time-wait-state-linux.html
|
|
||||||
net.ipv4.ip_local_port_range = 10240 65535
|
|
||||||
# recommended for web servers, especially if running SPDY
|
|
||||||
# see: http://www.chromium.org/spdy/spdy-best-practices
|
|
||||||
net.ipv4.tcp_slow_start_after_idle = 0
|
|
||||||
@@ -1 +1 @@
|
|||||||
deb [arch=amd64] https://pkg.tarsnap.com/deb/{{ ansible_distribution_release }} ./
|
deb [arch=amd64 signed-by=/etc/apt/keyrings/tarsnap-deb-packaging-key.asc] https://pkg.tarsnap.com/deb/{{ ansible_facts["distribution_release"] }} ./
|
||||||
|
|||||||
65
roles/common/templates/update-firehol-nftables.sh.j2
Executable file
65
roles/common/templates/update-firehol-nftables.sh.j2
Executable file
@@ -0,0 +1,65 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# update-firehol-nftables.sh v0.0.1
|
||||||
|
#
|
||||||
|
# Download FireHOL lists and load them into nftables sets.
|
||||||
|
#
|
||||||
|
# See: https://iplists.firehol.org/
|
||||||
|
#
|
||||||
|
# Copyright (C) 2025 Alan Orth
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
|
# Exit on first error
|
||||||
|
set -o errexit
|
||||||
|
|
||||||
|
firehol_level1_ipv4_set_path=/etc/nftables/firehol_level1-ipv4.nft
|
||||||
|
|
||||||
|
function download() {
|
||||||
|
echo "Downloading $1"
|
||||||
|
wget -q -O - "https://iplists.firehol.org/files/$1" > "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
download firehol_level1.netset
|
||||||
|
|
||||||
|
if [[ -f "firehol_level1.netset" ]]; then
|
||||||
|
echo "Processing FireHOL Level 1 list"
|
||||||
|
|
||||||
|
firehol_level1_ipv4_list_temp=$(mktemp)
|
||||||
|
firehol_level1_ipv4_set_temp=$(mktemp)
|
||||||
|
|
||||||
|
# Filter blank lines, comments, and bogons we use inside the LAN, DMZ, and
|
||||||
|
# for local services like systemd-resolved and others on localhost. Ideally
|
||||||
|
# these are blocked already at the WAN side by network administrators.
|
||||||
|
cat firehol_level1.netset \
|
||||||
|
| sed \
|
||||||
|
-e '/^$/d' \
|
||||||
|
-e '/^#.*/d' \
|
||||||
|
-e '/^127\.0\.0\.0\/8/d' \
|
||||||
|
> "$firehol_level1_ipv4_list_temp"
|
||||||
|
|
||||||
|
echo "Building firehol_level1-ipv4 set"
|
||||||
|
cat << NFT_HEAD > "$firehol_level1_ipv4_set_temp"
|
||||||
|
#!/usr/sbin/nft -f
|
||||||
|
|
||||||
|
define FIREHOL_LEVEL1_IPV4 = {
|
||||||
|
NFT_HEAD
|
||||||
|
|
||||||
|
while read -r network; do
|
||||||
|
# nftables doesn't mind if the last element in the set has a trailing
|
||||||
|
# comma so we don't need to do anything special here.
|
||||||
|
echo "$network," >> "$firehol_level1_ipv4_set_temp"
|
||||||
|
done < $firehol_level1_ipv4_list_temp
|
||||||
|
|
||||||
|
echo "}" >> "$firehol_level1_ipv4_set_temp"
|
||||||
|
|
||||||
|
install -m 0600 "$firehol_level1_ipv4_set_temp" "$firehol_level1_ipv4_set_path"
|
||||||
|
|
||||||
|
rm -f "$firehol_level1_ipv4_list_temp" "$firehol_level1_ipv4_set_temp"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Restarting nftables"
|
||||||
|
|
||||||
|
/usr/bin/systemctl restart nftables.service
|
||||||
|
|
||||||
|
rm -v firehol_level1.netset
|
||||||
@@ -1,15 +1,4 @@
|
|||||||
---
|
---
|
||||||
# ansible.builtin.file: roles/mariadb/defaults/main.yml
|
|
||||||
#
|
|
||||||
# Based on my running of mysqltuner.pl on a host with three WordPress databases
|
|
||||||
#
|
|
||||||
|
|
||||||
# default is 128MB but is a waste because it seems only the mysql table uses it
|
|
||||||
key_buffer_size: 8M
|
|
||||||
|
|
||||||
# default is 128MB but is a waste because it seems only information_schema uses
|
|
||||||
# AriaDB, see: https://mariadb.com/kb/en/mariadb/aria-system-variables
|
|
||||||
aria_pagecache_buffer_size: 8M
|
|
||||||
|
|
||||||
# default is 128M, but set to at least the size of your InnoDB data
|
# default is 128M, but set to at least the size of your InnoDB data
|
||||||
innodb_buffer_pool_size: 256M
|
innodb_buffer_pool_size: 256M
|
||||||
@@ -22,10 +11,6 @@ mariadb_login_unix_socket: /run/mysqld/mysqld.sock
|
|||||||
# default is 100 but the max I've seen used is 5, so let's reduce it
|
# default is 100 but the max I've seen used is 5, so let's reduce it
|
||||||
max_connections: 33
|
max_connections: 33
|
||||||
|
|
||||||
# disable the query cache by default
|
|
||||||
query_cache_size: 0
|
|
||||||
query_cache_type: 0
|
|
||||||
|
|
||||||
# mysqltuner says we should use larger than 32M on our setup
|
# mysqltuner says we should use larger than 32M on our setup
|
||||||
tmp_table_size: 64M
|
tmp_table_size: 64M
|
||||||
max_heap_table_size: 64M
|
max_heap_table_size: 64M
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
---
|
---
|
||||||
- name: restart mariadb
|
- name: restart mariadb
|
||||||
ansible.builtin.systemd: name=mariadb state=restarted
|
ansible.builtin.systemd_service:
|
||||||
|
name: mariadb
|
||||||
|
state: restarted
|
||||||
|
|
||||||
# vim: set ts=2 sw=2:
|
# vim: set ts=2 sw=2:
|
||||||
|
|||||||
@@ -1,67 +1,18 @@
|
|||||||
---
|
---
|
||||||
- name: Remove MariaDB key from apt-key
|
|
||||||
ansible.builtin.apt_key:
|
|
||||||
id: 0x177F4010FE56CA3336300305F1656F24C74CD1D8
|
|
||||||
state: absent
|
|
||||||
tags:
|
|
||||||
- packages
|
|
||||||
- mariadb
|
|
||||||
|
|
||||||
- name: Check MariaDB package signing key
|
|
||||||
ansible.builtin.stat:
|
|
||||||
path: /etc/apt/keyrings/mariadb_release_signing_key.asc
|
|
||||||
register: mariadb_signing_key_stat
|
|
||||||
tags:
|
|
||||||
- packages
|
|
||||||
- mariadb
|
|
||||||
|
|
||||||
- name: Download MariaDB package signing key
|
|
||||||
ansible.builtin.get_url:
|
|
||||||
url: https://mariadb.org/mariadb_release_signing_key.asc
|
|
||||||
dest: /etc/apt/keyrings/mariadb_release_signing_key.asc
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: 0644
|
|
||||||
register: download_mariadb_signing_key
|
|
||||||
when: not mariadb_signing_key_stat.stat.exists
|
|
||||||
tags:
|
|
||||||
- packages
|
|
||||||
- mariadb
|
|
||||||
|
|
||||||
- name: Add MariaDB 10.6 repo
|
|
||||||
ansible.builtin.apt_repository:
|
|
||||||
repo: 'deb [arch=amd64 signed-by=/etc/apt/keyrings/mariadb_release_signing_key.asc] https://dlm.mariadb.com/repo/mariadb-server/10.6/repo/debian {{ ansible_distribution_release }} main'
|
|
||||||
filename: mariadb
|
|
||||||
state: present
|
|
||||||
register: add_mariadb_apt_repository
|
|
||||||
tags:
|
|
||||||
- packages
|
|
||||||
- mariadb
|
|
||||||
|
|
||||||
- name: Update apt cache
|
|
||||||
ansible.builtin.apt: # noqa no-handler
|
|
||||||
update_cache: true
|
|
||||||
when:
|
|
||||||
(download_mariadb_signing_key.status_code is defined and download_mariadb_signing_key.status_code == 200) or
|
|
||||||
add_mariadb_apt_repository is changed
|
|
||||||
tags:
|
|
||||||
- packages
|
|
||||||
- mariadb
|
|
||||||
|
|
||||||
- name: Install mariadb-server
|
- name: Install mariadb-server
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name: ['mariadb-server', 'python3-pymysql']
|
name: [mariadb-server, python3-pymysql]
|
||||||
state: present
|
state: present
|
||||||
cache_valid_time: 3600
|
cache_valid_time: 3600
|
||||||
tags: mariadb, packages
|
tags: mariadb, packages
|
||||||
|
|
||||||
- name: Create system my.cnf
|
- name: Add MariaDB configuration overrides
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: my.cnf.j2
|
src: 70-local.cnf.j2
|
||||||
dest: /etc/mysql/my.cnf
|
dest: /etc/mysql/mariadb.conf.d/70-local.cnf
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: "0644"
|
||||||
notify:
|
notify:
|
||||||
- restart mariadb
|
- restart mariadb
|
||||||
tags: mariadb
|
tags: mariadb
|
||||||
@@ -83,21 +34,22 @@
|
|||||||
src: .my.cnf.j2
|
src: .my.cnf.j2
|
||||||
dest: /root/.my.cnf
|
dest: /root/.my.cnf
|
||||||
owner: root
|
owner: root
|
||||||
mode: 0600
|
mode: "0600"
|
||||||
tags: mariadb
|
tags: mariadb
|
||||||
|
|
||||||
# See: https://docs.ansible.com/ansible/latest/collections/community/mysql/mysql_db_module.html
|
# See: https://docs.ansible.com/ansible/latest/collections/community/mysql/mysql_db_module.html
|
||||||
- name: Create MariaDB database(s)
|
- name: Create MariaDB database(s)
|
||||||
|
when: mariadb_databases is defined
|
||||||
community.mysql.mysql_db:
|
community.mysql.mysql_db:
|
||||||
db: "{{ item.name }}"
|
db: "{{ item.name }}"
|
||||||
state: present
|
state: present
|
||||||
encoding: utf8mb4
|
encoding: utf8mb4
|
||||||
login_unix_socket: "{{ mariadb_login_unix_socket }}"
|
login_unix_socket: "{{ mariadb_login_unix_socket }}"
|
||||||
loop: "{{ mariadb_databases }}"
|
loop: "{{ mariadb_databases }}"
|
||||||
when: mariadb_databases is defined
|
|
||||||
tags: mariadb
|
tags: mariadb
|
||||||
|
|
||||||
- name: Create MariaDB user(s)
|
- name: Create MariaDB user(s)
|
||||||
|
when: mariadb_databases is defined
|
||||||
community.mysql.mysql_user:
|
community.mysql.mysql_user:
|
||||||
name: "{{ item.user }}"
|
name: "{{ item.user }}"
|
||||||
password: "{{ item.pass }}"
|
password: "{{ item.pass }}"
|
||||||
@@ -106,7 +58,6 @@
|
|||||||
state: present
|
state: present
|
||||||
login_unix_socket: "{{ mariadb_login_unix_socket }}"
|
login_unix_socket: "{{ mariadb_login_unix_socket }}"
|
||||||
loop: "{{ mariadb_databases }}"
|
loop: "{{ mariadb_databases }}"
|
||||||
when: mariadb_databases is defined
|
|
||||||
tags: mariadb
|
tags: mariadb
|
||||||
|
|
||||||
# vim: set ts=2 sw=2:
|
# vim: set ts=2 sw=2:
|
||||||
|
|||||||
10
roles/mariadb/templates/70-local.cnf.j2
Normal file
10
roles/mariadb/templates/70-local.cnf.j2
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{{ ansible_managed | comment }}
|
||||||
|
|
||||||
|
[mysqld]
|
||||||
|
# don't resolve connection IPs to hostnames (make sure user accounts are using
|
||||||
|
# IPs instead of "localhost")
|
||||||
|
skip-name-resolve=1
|
||||||
|
max_connections = {{ max_connections }}
|
||||||
|
tmp_table_size = {{ tmp_table_size }}
|
||||||
|
max_heap_table_size = {{ max_heap_table_size }}
|
||||||
|
innodb_buffer_pool_size = {{ innodb_buffer_pool_size }}
|
||||||
@@ -1,196 +0,0 @@
|
|||||||
{{ ansible_managed | comment }}
|
|
||||||
|
|
||||||
# MariaDB database server configuration file.
|
|
||||||
#
|
|
||||||
# You can copy this file to one of:
|
|
||||||
# - "/etc/mysql/my.cnf" to set global options,
|
|
||||||
# - "~/.my.cnf" to set user-specific options.
|
|
||||||
#
|
|
||||||
# One can use all long options that the program supports.
|
|
||||||
# Run program with --help to get a list of available options and with
|
|
||||||
# --print-defaults to see which it would actually understand and use.
|
|
||||||
#
|
|
||||||
# For explanations see
|
|
||||||
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
|
|
||||||
|
|
||||||
# This will be passed to all mysql clients
|
|
||||||
# It has been reported that passwords should be enclosed with ticks/quotes
|
|
||||||
# escpecially if they contain "#" chars...
|
|
||||||
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
|
|
||||||
[client]
|
|
||||||
port = 3306
|
|
||||||
socket = /run/mysqld/mysqld.sock
|
|
||||||
|
|
||||||
# Here is entries for some specific programs
|
|
||||||
# The following values assume you have at least 32M ram
|
|
||||||
|
|
||||||
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
|
|
||||||
[mysqld_safe]
|
|
||||||
socket = /run/mysqld/mysqld.sock
|
|
||||||
nice = 0
|
|
||||||
|
|
||||||
[mysqld]
|
|
||||||
#
|
|
||||||
# * Basic Settings
|
|
||||||
#
|
|
||||||
user = mysql
|
|
||||||
pid-file = /run/mysqld/mysqld.pid
|
|
||||||
socket = /run/mysqld/mysqld.sock
|
|
||||||
port = 3306
|
|
||||||
basedir = /usr
|
|
||||||
datadir = /var/lib/mysql
|
|
||||||
tmpdir = /tmp
|
|
||||||
lc_messages_dir = /usr/share/mysql
|
|
||||||
lc_messages = en_US
|
|
||||||
skip-external-locking
|
|
||||||
#
|
|
||||||
# Instead of skip-networking the default is now to listen only on
|
|
||||||
# localhost which is more compatible and is not less secure.
|
|
||||||
bind-address = 127.0.0.1
|
|
||||||
|
|
||||||
# don't resolve connection IPs to hostnames (make sure user accounts are using
|
|
||||||
# IPs instead of "localhost")
|
|
||||||
skip-name-resolve=1
|
|
||||||
#
|
|
||||||
# * Fine Tuning
|
|
||||||
#
|
|
||||||
max_connections = {{ max_connections }}
|
|
||||||
connect_timeout = 5
|
|
||||||
wait_timeout = 600
|
|
||||||
max_allowed_packet = 16M
|
|
||||||
thread_cache_size = 128
|
|
||||||
sort_buffer_size = 4M
|
|
||||||
bulk_insert_buffer_size = 16M
|
|
||||||
tmp_table_size = {{ tmp_table_size }}
|
|
||||||
max_heap_table_size = {{ max_heap_table_size }}
|
|
||||||
#
|
|
||||||
# * MyISAM
|
|
||||||
#
|
|
||||||
# This replaces the startup script and checks MyISAM tables if needed
|
|
||||||
# the first time they are touched. On error, make copy and try a repair.
|
|
||||||
myisam_recover_options = BACKUP
|
|
||||||
key_buffer_size = {{ key_buffer_size }}
|
|
||||||
#open-files-limit = 2000
|
|
||||||
table_open_cache = 400
|
|
||||||
myisam_sort_buffer_size = 512M
|
|
||||||
concurrent_insert = 2
|
|
||||||
read_buffer_size = 2M
|
|
||||||
read_rnd_buffer_size = 1M
|
|
||||||
#
|
|
||||||
# * Query Cache Configuration
|
|
||||||
#
|
|
||||||
query_cache_limit = 128K
|
|
||||||
query_cache_size = {{ query_cache_size }}
|
|
||||||
query_cache_type = {{ query_cache_type }}
|
|
||||||
#
|
|
||||||
# * Logging and Replication
|
|
||||||
#
|
|
||||||
# Both location gets rotated by the cronjob.
|
|
||||||
# Be aware that this log type is a performance killer.
|
|
||||||
# As of 5.1 you can enable the log at runtime!
|
|
||||||
#general_log_file = /var/log/mysql/mysql.log
|
|
||||||
#general_log = 1
|
|
||||||
#
|
|
||||||
# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
|
|
||||||
#
|
|
||||||
# we do want to know about network errors and such
|
|
||||||
log_warnings = 2
|
|
||||||
#
|
|
||||||
# Enable the slow query log to see queries with especially long duration
|
|
||||||
#slow_query_log[={0|1}]
|
|
||||||
slow_query_log_file = /var/log/mysql/mariadb-slow.log
|
|
||||||
long_query_time = 10
|
|
||||||
#log_slow_rate_limit = 1000
|
|
||||||
log_slow_verbosity = query_plan
|
|
||||||
|
|
||||||
#log-queries-not-using-indexes
|
|
||||||
#log_slow_admin_statements
|
|
||||||
#
|
|
||||||
# The following can be used as easy to replay backup logs or for replication.
|
|
||||||
# note: if you are setting up a replication slave, see README.Debian about
|
|
||||||
# other settings you may need to change.
|
|
||||||
#server-id = 1
|
|
||||||
#report_host = master1
|
|
||||||
#auto_increment_increment = 2
|
|
||||||
#auto_increment_offset = 1
|
|
||||||
log_bin = /var/log/mysql/mariadb-bin
|
|
||||||
log_bin_index = /var/log/mysql/mariadb-bin.index
|
|
||||||
# not fab for performance, but safer
|
|
||||||
#sync_binlog = 1
|
|
||||||
expire_logs_days = 10
|
|
||||||
max_binlog_size = 100M
|
|
||||||
# slaves
|
|
||||||
#relay_log = /var/log/mysql/relay-bin
|
|
||||||
#relay_log_index = /var/log/mysql/relay-bin.index
|
|
||||||
#relay_log_info_file = /var/log/mysql/relay-bin.info
|
|
||||||
#log_slave_updates
|
|
||||||
#read_only
|
|
||||||
#
|
|
||||||
# If applications support it, this stricter sql_mode prevents some
|
|
||||||
# mistakes like inserting invalid dates etc.
|
|
||||||
#sql_mode = NO_ENGINE_SUBSTITUTION,TRADITIONAL
|
|
||||||
#
|
|
||||||
# * InnoDB
|
|
||||||
#
|
|
||||||
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
|
|
||||||
# Read the manual for more InnoDB related options. There are many!
|
|
||||||
default_storage_engine = InnoDB
|
|
||||||
# you can't just change log file size, requires special procedure
|
|
||||||
#innodb_log_file_size = 50M
|
|
||||||
innodb_buffer_pool_size = {{ innodb_buffer_pool_size }}
|
|
||||||
innodb_log_buffer_size = 8M
|
|
||||||
innodb_file_per_table = 1
|
|
||||||
innodb_open_files = 400
|
|
||||||
innodb_io_capacity = 400
|
|
||||||
innodb_flush_method = O_DIRECT
|
|
||||||
|
|
||||||
aria_pagecache_buffer_size = {{ aria_pagecache_buffer_size }}
|
|
||||||
#
|
|
||||||
# * Security Features
|
|
||||||
#
|
|
||||||
# Read the manual, too, if you want chroot!
|
|
||||||
# chroot = /var/lib/mysql/
|
|
||||||
#
|
|
||||||
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
|
|
||||||
#
|
|
||||||
# ssl-ca=/etc/mysql/cacert.pem
|
|
||||||
# ssl-cert=/etc/mysql/server-cert.pem
|
|
||||||
# ssl-key=/etc/mysql/server-key.pem
|
|
||||||
|
|
||||||
#
|
|
||||||
# * Galera-related settings
|
|
||||||
#
|
|
||||||
[galera]
|
|
||||||
# Mandatory settings
|
|
||||||
#wsrep_on=ON
|
|
||||||
#wsrep_provider=
|
|
||||||
#wsrep_cluster_address=
|
|
||||||
#binlog_format=row
|
|
||||||
#default_storage_engine=InnoDB
|
|
||||||
#innodb_autoinc_lock_mode=2
|
|
||||||
#
|
|
||||||
# Allow server to accept connections on all interfaces.
|
|
||||||
#
|
|
||||||
#bind-address=0.0.0.0
|
|
||||||
#
|
|
||||||
# Optional setting
|
|
||||||
#wsrep_slave_threads=1
|
|
||||||
#innodb_flush_log_at_trx_commit=0
|
|
||||||
|
|
||||||
[mysqldump]
|
|
||||||
quick
|
|
||||||
quote-names
|
|
||||||
max_allowed_packet = 16M
|
|
||||||
|
|
||||||
[mysql]
|
|
||||||
#no-auto-rehash # faster start of mysql but no tab completion
|
|
||||||
|
|
||||||
[isamchk]
|
|
||||||
key_buffer = 16M
|
|
||||||
|
|
||||||
#
|
|
||||||
# * IMPORTANT: Additional settings that can override those from this file!
|
|
||||||
# The files must end with '.cnf', otherwise they'll be ignored.
|
|
||||||
#
|
|
||||||
!include /etc/mysql/mariadb.cnf
|
|
||||||
!includedir /etc/mysql/conf.d/
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
---
|
---
|
||||||
# ansible.builtin.file: roles/munin/handlers/main.yml
|
# ansible.builtin.file: roles/munin/handlers/main.yml
|
||||||
- name: restart munin-node
|
- name: restart munin-node
|
||||||
ansible.builtin.systemd: name=munin-node state=restarted
|
ansible.builtin.systemd_service: name=munin-node state=restarted
|
||||||
|
|||||||
@@ -1,16 +1,22 @@
|
|||||||
---
|
---
|
||||||
- name: Install munin-node
|
- name: Install munin-node
|
||||||
ansible.builtin.apt: name=munin-node state=present
|
ansible.builtin.apt:
|
||||||
|
name: munin-node
|
||||||
|
state: present
|
||||||
tags: packages
|
tags: packages
|
||||||
|
|
||||||
# some nice things to have for munin-node on Ubuntu
|
# some nice things to have for munin-node on Ubuntu
|
||||||
# libwww-perl: for munin's nginx_status check
|
# libwww-perl: for munin's nginx_status check
|
||||||
- name: Install munin-node deps
|
- name: Install munin-node deps
|
||||||
ansible.builtin.apt: name=libwww-perl state=present
|
ansible.builtin.apt:
|
||||||
|
name: libwww-perl
|
||||||
|
state: present
|
||||||
tags: packages
|
tags: packages
|
||||||
|
|
||||||
- name: Create munin-node.conf
|
- name: Create munin-node.conf
|
||||||
ansible.builtin.template: src=munin-node.conf.j2 dest=/etc/munin/munin-node.conf
|
ansible.builtin.template:
|
||||||
|
src: munin-node.conf.j2
|
||||||
|
dest: /etc/munin/munin-node.conf
|
||||||
notify:
|
notify:
|
||||||
- restart munin-node
|
- restart munin-node
|
||||||
|
|
||||||
@@ -20,6 +26,9 @@
|
|||||||
- restart munin-node
|
- restart munin-node
|
||||||
|
|
||||||
- name: Start munin-node
|
- name: Start munin-node
|
||||||
ansible.builtin.systemd: name=munin-node state=started enabled=true
|
ansible.builtin.systemd_service:
|
||||||
|
name: munin-node
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
|
||||||
# vim: set ts=2 sw=2:
|
# vim: set ts=2 sw=2:
|
||||||
|
|||||||
@@ -1,9 +1,16 @@
|
|||||||
---
|
---
|
||||||
- name: Install munin package
|
- name: Install munin package
|
||||||
ansible.builtin.apt: name=munin state=present
|
ansible.builtin.apt:
|
||||||
|
name: munin
|
||||||
|
state: present
|
||||||
tags: packages
|
tags: packages
|
||||||
|
|
||||||
- name: Create munin configuration file
|
- name: Create munin configuration file
|
||||||
ansible.builtin.template: src=munin.conf.j2 dest=/etc/munin/munin.conf owner=root group=root mode=0644
|
ansible.builtin.template:
|
||||||
|
src: munin.conf.j2
|
||||||
|
dest: /etc/munin/munin.conf
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
|
||||||
# vim: set ts=2 sw=2:
|
# vim: set ts=2 sw=2:
|
||||||
|
|||||||
@@ -5,20 +5,20 @@
|
|||||||
nginx_confd_path: /etc/nginx/conf.d
|
nginx_confd_path: /etc/nginx/conf.d
|
||||||
|
|
||||||
# parent directory of vhost roots
|
# parent directory of vhost roots
|
||||||
nginx_root_prefix: /var/www
|
nginx_root_prefix: "{{ web_root_prefix }}"
|
||||||
|
|
||||||
# 1 hour timeout
|
# 1 day timeout
|
||||||
nginx_ssl_session_timeout: 1h
|
nginx_ssl_session_timeout: 1d
|
||||||
# 10MB -> 40,000 sessions
|
# 10MB -> 40,000 sessions
|
||||||
nginx_ssl_session_cache: shared:SSL:10m
|
nginx_ssl_session_cache: shared:SSL:10m
|
||||||
# 1400 bytes to fit in one MTU (default is 16k!)
|
nginx_ssl_buffer_size: 4k
|
||||||
nginx_ssl_buffer_size: 1400
|
|
||||||
nginx_ssl_dhparam: /etc/ssl/certs/dhparam.pem
|
nginx_ssl_dhparam: /etc/ssl/certs/dhparam.pem
|
||||||
nginx_ssl_protocols: 'TLSv1.2 TLSv1.3'
|
nginx_ssl_protocols: TLSv1.2 TLSv1.3
|
||||||
|
nginx_ssl_ecdh_curve: X25519:prime256v1:secp384r1
|
||||||
|
|
||||||
# DNS resolvers for OCSP stapling (default to Cloudflare public DNS)
|
# DNS resolvers for OCSP stapling (default to Cloudflare public DNS)
|
||||||
# See: https://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_stapling
|
# See: https://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_stapling
|
||||||
nginx_ssl_stapling_resolver: '1.1.1.1 1.0.0.1 [2606:4700:4700::1111] [2606:4700:4700::1001]'
|
nginx_ssl_stapling_resolver: 1.1.1.1 1.0.0.1 [2606:4700:4700::1111] [2606:4700:4700::1001]
|
||||||
|
|
||||||
# HTTP Strict-Transport-Security header, recommended by Google to be ~1 year
|
# HTTP Strict-Transport-Security header, recommended by Google to be ~1 year
|
||||||
# in seconds, see: https://hstspreload.org/
|
# in seconds, see: https://hstspreload.org/
|
||||||
@@ -37,8 +37,8 @@ letsencrypt_root: /etc/ssl
|
|||||||
letsencrypt_acme_script_temp: /root/acme.sh
|
letsencrypt_acme_script_temp: /root/acme.sh
|
||||||
letsencrypt_acme_home: /root/.acme.sh
|
letsencrypt_acme_home: /root/.acme.sh
|
||||||
|
|
||||||
# stable is 1.20.x
|
# stable is 1.26.x
|
||||||
# mainline is 1.21.x
|
# mainline is 1.27.x
|
||||||
nginx_version: mainline
|
nginx_version: mainline
|
||||||
|
|
||||||
# vim: set ts=2 sw=2:
|
# vim: set ts=2 sw=2:
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
---
|
---
|
||||||
- name: reload nginx
|
- name: Reload nginx
|
||||||
ansible.builtin.systemd: name=nginx state=reloaded
|
ansible.builtin.systemd_service:
|
||||||
|
name: nginx
|
||||||
|
state: reloaded
|
||||||
|
|
||||||
# vim: set ts=2 sw=2:
|
# vim: set ts=2 sw=2:
|
||||||
|
|||||||
@@ -1,91 +1,91 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
# Use acme.sh instead of certbot because they only support installation via
|
# Use acme.sh instead of certbot because they only support installation via
|
||||||
# snap now.
|
# snap now.
|
||||||
- block:
|
- name: Install and configure Let's Encrypt
|
||||||
- name: Remove certbot
|
|
||||||
ansible.builtin.apt:
|
|
||||||
name: certbot
|
|
||||||
state: absent
|
|
||||||
|
|
||||||
- name: Remove old certbot post and pre hooks for nginx
|
|
||||||
ansible.builtin.file:
|
|
||||||
dest: "{{ item }}"
|
|
||||||
state: absent
|
|
||||||
with_items:
|
|
||||||
- /etc/letsencrypt/renewal-hooks/pre/stop-nginx.sh
|
|
||||||
- /etc/letsencrypt/renewal-hooks/post/start-nginx.sh
|
|
||||||
|
|
||||||
- name: Check if acme.sh is installed
|
|
||||||
ansible.builtin.stat:
|
|
||||||
path: "{{ letsencrypt_acme_home }}"
|
|
||||||
register: acme_home
|
|
||||||
|
|
||||||
- name: Download acme.sh
|
|
||||||
ansible.builtin.get_url:
|
|
||||||
url: https://raw.githubusercontent.com/acmesh-official/acme.sh/master/acme.sh
|
|
||||||
dest: "{{ letsencrypt_acme_script_temp }}"
|
|
||||||
mode: 0700
|
|
||||||
register: acme_download
|
|
||||||
when: not acme_home.stat.exists
|
|
||||||
|
|
||||||
# Run the "install" for acme.sh so it creates the .acme.sh dir (currently I
|
|
||||||
# have to chdir to the /root directory where the script exists or else it
|
|
||||||
# fails. Ansible runs it, but the script can't find itself...).
|
|
||||||
- name: Install acme.sh
|
|
||||||
ansible.builtin.command:
|
|
||||||
cmd: "{{ letsencrypt_acme_script_temp }} --install --no-profile --no-cron"
|
|
||||||
creates: "{{ letsencrypt_acme_home }}/acme.sh"
|
|
||||||
chdir: /root
|
|
||||||
register: acme_install
|
|
||||||
when: acme_download is changed
|
|
||||||
|
|
||||||
- name: Remove temporary acme.sh script
|
|
||||||
ansible.builtin.file:
|
|
||||||
dest: "{{ letsencrypt_acme_script_temp }}"
|
|
||||||
state: absent
|
|
||||||
when:
|
|
||||||
- acme_install.rc is defined
|
|
||||||
- acme_install.rc == 0
|
|
||||||
|
|
||||||
- name: Set default certificate authority for acme.sh
|
|
||||||
ansible.builtin.command:
|
|
||||||
cmd: "{{ letsencrypt_acme_home }}/acme.sh --set-default-ca --server letsencrypt"
|
|
||||||
|
|
||||||
- name: Prepare Let's Encrypt well-known directory
|
|
||||||
ansible.builtin.file:
|
|
||||||
state: directory
|
|
||||||
path: /var/lib/letsencrypt/.well-known
|
|
||||||
owner: root
|
|
||||||
group: nginx
|
|
||||||
mode: g+s
|
|
||||||
|
|
||||||
- name: Copy systemd service to renew Let's Encrypt certs
|
|
||||||
ansible.builtin.template:
|
|
||||||
src: renew-letsencrypt.service.j2
|
|
||||||
dest: /etc/systemd/system/renew-letsencrypt.service
|
|
||||||
mode: 0644
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
|
|
||||||
- name: Copy systemd timer to renew Let's Encrypt certs
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: renew-letsencrypt.timer
|
|
||||||
dest: /etc/systemd/system/renew-letsencrypt.timer
|
|
||||||
mode: 0644
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
|
|
||||||
# always issues daemon-reload just in case the service/timer changed
|
|
||||||
- name: Start and enable systemd timer to renew Let's Encrypt certs
|
|
||||||
ansible.builtin.systemd:
|
|
||||||
name: renew-letsencrypt.timer
|
|
||||||
state: started
|
|
||||||
enabled: true
|
|
||||||
daemon_reload: true
|
|
||||||
|
|
||||||
when: (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('20.04', '=='))
|
|
||||||
or (ansible_distribution == 'Debian' and ansible_distribution_version is version('11', '=='))
|
|
||||||
tags: letsencrypt
|
tags: letsencrypt
|
||||||
|
when:
|
||||||
|
- ansible_facts["distribution"] == 'Debian'
|
||||||
|
- ansible_facts["distribution_version"] is version('11', '>=')
|
||||||
|
block:
|
||||||
|
- name: Remove certbot
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: certbot
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Remove old certbot post and pre hooks for nginx
|
||||||
|
ansible.builtin.file:
|
||||||
|
dest: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
with_items:
|
||||||
|
- /etc/letsencrypt/renewal-hooks/pre/stop-nginx.sh
|
||||||
|
- /etc/letsencrypt/renewal-hooks/post/start-nginx.sh
|
||||||
|
|
||||||
|
- name: Check if acme.sh is installed
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "{{ letsencrypt_acme_home }}"
|
||||||
|
register: acme_home
|
||||||
|
|
||||||
|
- name: Download acme.sh
|
||||||
|
when: not acme_home.stat.exists
|
||||||
|
ansible.builtin.get_url:
|
||||||
|
url: https://raw.githubusercontent.com/acmesh-official/acme.sh/master/acme.sh
|
||||||
|
dest: "{{ letsencrypt_acme_script_temp }}"
|
||||||
|
mode: "0700"
|
||||||
|
register: acme_download
|
||||||
|
|
||||||
|
# Run the "install" for acme.sh so it creates the .acme.sh dir (currently I
|
||||||
|
# have to chdir to the /root directory where the script exists or else it
|
||||||
|
# fails. Ansible runs it, but the script can't find itself...).
|
||||||
|
- name: Install acme.sh
|
||||||
|
when: acme_download is changed
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: "{{ letsencrypt_acme_script_temp }} --install --no-profile --no-cron"
|
||||||
|
creates: "{{ letsencrypt_acme_home }}/acme.sh"
|
||||||
|
chdir: /root
|
||||||
|
register: acme_install
|
||||||
|
|
||||||
|
- name: Remove temporary acme.sh script
|
||||||
|
when:
|
||||||
|
- acme_install.rc is defined
|
||||||
|
- acme_install.rc == 0
|
||||||
|
ansible.builtin.file:
|
||||||
|
dest: "{{ letsencrypt_acme_script_temp }}"
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Set default certificate authority for acme.sh
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: "{{ letsencrypt_acme_home }}/acme.sh --set-default-ca --server letsencrypt"
|
||||||
|
|
||||||
|
- name: Prepare Let's Encrypt well-known directory
|
||||||
|
ansible.builtin.file:
|
||||||
|
state: directory
|
||||||
|
path: /var/lib/letsencrypt/.well-known
|
||||||
|
owner: root
|
||||||
|
group: nginx
|
||||||
|
mode: g+s
|
||||||
|
|
||||||
|
- name: Copy systemd service to renew Let's Encrypt certs
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: renew-letsencrypt.service.j2
|
||||||
|
dest: /etc/systemd/system/renew-letsencrypt.service
|
||||||
|
mode: "0644"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
|
||||||
|
- name: Copy systemd timer to renew Let's Encrypt certs
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: renew-letsencrypt.timer
|
||||||
|
dest: /etc/systemd/system/renew-letsencrypt.timer
|
||||||
|
mode: "0644"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
|
||||||
|
# always issues daemon-reload just in case the service/timer changed
|
||||||
|
- name: Start and enable systemd timer to renew Let's Encrypt certs
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: renew-letsencrypt.timer
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
daemon_reload: true
|
||||||
|
|
||||||
# vim: set ts=2 sw=2:
|
# vim: set ts=2 sw=2:
|
||||||
|
|||||||
@@ -1,29 +1,13 @@
|
|||||||
---
|
---
|
||||||
- name: Remove nginx apt signing key from apt-key
|
|
||||||
ansible.builtin.apt_key:
|
|
||||||
id: 0x573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
|
|
||||||
state: absent
|
|
||||||
tags:
|
|
||||||
- packages
|
|
||||||
- nginx
|
|
||||||
|
|
||||||
- name: Check nginx apt signing key
|
|
||||||
ansible.builtin.stat:
|
|
||||||
path: /usr/share/keyrings/nginx_signing.key
|
|
||||||
register: nginx_signing_key_stat
|
|
||||||
tags:
|
|
||||||
- packages
|
|
||||||
- nginx
|
|
||||||
|
|
||||||
- name: Download nginx apt signing key
|
- name: Download nginx apt signing key
|
||||||
ansible.builtin.get_url:
|
ansible.builtin.get_url:
|
||||||
url: https://nginx.org/keys/nginx_signing.key
|
url: https://nginx.org/keys/nginx_signing.key
|
||||||
dest: /usr/share/keyrings/nginx_signing.key
|
dest: /usr/share/keyrings/nginx_signing.key
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: "0644"
|
||||||
|
checksum: sha256:55385da31d198fa6a5012d40ae98ecb272a6c4e8fffffba94719ffd3e87de37a
|
||||||
register: download_nginx_signing_key
|
register: download_nginx_signing_key
|
||||||
when: not nginx_signing_key_stat.stat.exists
|
|
||||||
tags:
|
tags:
|
||||||
- packages
|
- packages
|
||||||
- nginx
|
- nginx
|
||||||
@@ -34,18 +18,16 @@
|
|||||||
dest: /etc/apt/sources.list.d/nginx_org_sources.list
|
dest: /etc/apt/sources.list.d/nginx_org_sources.list
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: "0644"
|
||||||
register: add_nginx_apt_repository
|
register: add_nginx_apt_repository
|
||||||
tags:
|
tags:
|
||||||
- nginx
|
- nginx
|
||||||
- packages
|
- packages
|
||||||
|
|
||||||
- name: Update apt cache
|
- name: Update apt cache
|
||||||
|
when: (download_nginx_signing_key.status_code is defined and download_nginx_signing_key.status_code == 200) or add_nginx_apt_repository is changed
|
||||||
ansible.builtin.apt: # noqa no-handler
|
ansible.builtin.apt: # noqa no-handler
|
||||||
update_cache: true
|
update_cache: true
|
||||||
when:
|
|
||||||
(download_nginx_signing_key.status_code is defined and download_nginx_signing_key.status_code == 200) or
|
|
||||||
add_nginx_apt_repository is changed
|
|
||||||
|
|
||||||
- name: Install nginx
|
- name: Install nginx
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
@@ -60,25 +42,25 @@
|
|||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: nginx.conf.j2
|
src: nginx.conf.j2
|
||||||
dest: /etc/nginx/nginx.conf
|
dest: /etc/nginx/nginx.conf
|
||||||
mode: 0644
|
mode: "0644"
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
notify:
|
notify:
|
||||||
- reload nginx
|
- Reload nginx
|
||||||
tags: nginx
|
tags: nginx
|
||||||
|
|
||||||
- name: Copy extra nginx configs
|
- name: Copy extra nginx configs
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: "{{ item }}"
|
src: "{{ item }}"
|
||||||
dest: "/etc/nginx/{{ item }}"
|
dest: /etc/nginx/{{ item }}
|
||||||
mode: 0644
|
mode: "0644"
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
loop:
|
loop:
|
||||||
- extra-security.conf
|
- extra-security.conf
|
||||||
- fastcgi_cache
|
- fastcgi_cache
|
||||||
notify:
|
notify:
|
||||||
- reload nginx
|
- Reload nginx
|
||||||
tags: nginx
|
tags: nginx
|
||||||
|
|
||||||
- name: Remove default nginx vhost
|
- name: Remove default nginx vhost
|
||||||
@@ -93,43 +75,43 @@
|
|||||||
state: directory
|
state: directory
|
||||||
owner: nginx
|
owner: nginx
|
||||||
group: nginx
|
group: nginx
|
||||||
mode: 0755
|
mode: "0755"
|
||||||
tags: nginx
|
tags: nginx
|
||||||
|
|
||||||
- name: Configure nginx virtual hosts
|
- name: Configure nginx virtual hosts
|
||||||
ansible.builtin.include_tasks: vhosts.yml
|
|
||||||
when: nginx_vhosts is defined
|
when: nginx_vhosts is defined
|
||||||
|
ansible.builtin.include_tasks: vhosts.yml
|
||||||
tags: nginx
|
tags: nginx
|
||||||
|
|
||||||
- name: Configure WordPress
|
- name: Configure WordPress
|
||||||
ansible.builtin.include_tasks: wordpress.yml
|
|
||||||
when: nginx_vhosts is defined
|
when: nginx_vhosts is defined
|
||||||
|
ansible.builtin.include_tasks: wordpress.yml
|
||||||
tags: wordpress
|
tags: wordpress
|
||||||
|
|
||||||
- name: Configure blank nginx vhost
|
- name: Configure blank nginx vhost
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: blank-vhost.conf.j2
|
src: blank-vhost.conf.j2
|
||||||
dest: "{{ nginx_confd_path }}/blank-vhost.conf"
|
dest: "{{ nginx_confd_path }}/blank-vhost.conf"
|
||||||
mode: 0644
|
mode: "0644"
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
notify:
|
notify:
|
||||||
- reload nginx
|
- Reload nginx
|
||||||
tags: nginx
|
tags: nginx
|
||||||
|
|
||||||
- name: Configure munin vhost
|
- name: Configure munin vhost
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: munin.conf
|
src: munin.conf
|
||||||
dest: /etc/nginx/conf.d/munin.conf
|
dest: /etc/nginx/conf.d/munin.conf
|
||||||
mode: 0644
|
mode: "0644"
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
notify:
|
notify:
|
||||||
- reload nginx
|
- Reload nginx
|
||||||
tags: nginx
|
tags: nginx
|
||||||
|
|
||||||
- name: Start and enable nginx service
|
- name: Start and enable nginx service
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd_service:
|
||||||
name: nginx
|
name: nginx
|
||||||
state: started
|
state: started
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|||||||
@@ -1,29 +1,40 @@
|
|||||||
---
|
---
|
||||||
|
- name: Configure https vhosts
|
||||||
- block:
|
|
||||||
- name: Configure https vhosts
|
|
||||||
ansible.builtin.template: src=vhost.conf.j2 dest={{ nginx_confd_path }}/{{ item.domain_name }}.conf mode=0644 owner=root group=root
|
|
||||||
loop: "{{ nginx_vhosts }}"
|
|
||||||
notify:
|
|
||||||
- reload nginx
|
|
||||||
|
|
||||||
- name: Generate self-signed TLS cert
|
|
||||||
ansible.builtin.command: openssl req -x509 -nodes -sha256 -days 365 -subj "/C=SO/ST=SO/L=snakeoil/O=snakeoil/CN=snakeoil" -newkey rsa:2048 -keyout /etc/ssl/private/nginx-snakeoil.key -out /etc/ssl/certs/nginx-snakeoil.crt -extensions v3_ca creates=/etc/ssl/certs/nginx-snakeoil.crt
|
|
||||||
notify:
|
|
||||||
- reload nginx
|
|
||||||
|
|
||||||
- name: Download 4096-bit RFC 7919 dhparams
|
|
||||||
ansible.builtin.get_url:
|
|
||||||
url: https://raw.githubusercontent.com/internetstandards/dhe_groups/master/ffdhe4096.pem
|
|
||||||
checksum: sha256:64852d6890ff9e62eecd1ee89c72af9af244dfef5b853bcedea3dfd7aade22b3
|
|
||||||
dest: "{{ nginx_ssl_dhparam }}"
|
|
||||||
notify:
|
|
||||||
- reload nginx
|
|
||||||
|
|
||||||
# TODO: this could break because we can override the document root in host vars
|
|
||||||
- name: Create vhost document roots
|
|
||||||
ansible.builtin.file: path={{ nginx_root_prefix }}/{{ item.domain_name }} state=directory mode=0755 owner=nginx group=nginx
|
|
||||||
loop: "{{ nginx_vhosts }}"
|
|
||||||
tags: nginx
|
tags: nginx
|
||||||
|
block:
|
||||||
|
- name: Configure https vhosts
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: vhost.conf.j2
|
||||||
|
dest: "{{ nginx_confd_path }}/{{ item.domain_name }}.conf"
|
||||||
|
mode: "0644"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
loop: "{{ nginx_vhosts }}"
|
||||||
|
notify:
|
||||||
|
- Reload nginx
|
||||||
|
|
||||||
|
- name: Generate self-signed TLS cert
|
||||||
|
ansible.builtin.command: openssl req -x509 -nodes -sha256 -days 365 -subj "/C=SO/ST=SO/L=snakeoil/O=snakeoil/CN=snakeoil" -newkey rsa:2048 -keyout /etc/ssl/private/nginx-snakeoil.key
|
||||||
|
-out /etc/ssl/certs/nginx-snakeoil.crt -extensions v3_ca creates=/etc/ssl/certs/nginx-snakeoil.crt
|
||||||
|
notify:
|
||||||
|
- Reload nginx
|
||||||
|
|
||||||
|
- name: Download 4096-bit RFC 7919 dhparams
|
||||||
|
ansible.builtin.get_url:
|
||||||
|
url: https://raw.githubusercontent.com/internetstandards/dhe_groups/master/ffdhe4096.pem
|
||||||
|
checksum: sha256:64852d6890ff9e62eecd1ee89c72af9af244dfef5b853bcedea3dfd7aade22b3
|
||||||
|
dest: "{{ nginx_ssl_dhparam }}"
|
||||||
|
notify:
|
||||||
|
- Reload nginx
|
||||||
|
|
||||||
|
# TODO: this could break because we can override the document root in host vars
|
||||||
|
- name: Create vhost document roots
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ nginx_root_prefix }}/{{ item.domain_name }}"
|
||||||
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
owner: nginx
|
||||||
|
group: nginx
|
||||||
|
loop: "{{ nginx_vhosts }}"
|
||||||
|
|
||||||
# vim: set ts=2 sw=2:
|
# vim: set ts=2 sw=2:
|
||||||
|
|||||||
@@ -1,19 +1,31 @@
|
|||||||
---
|
---
|
||||||
|
- name: Install and configure WordPress
|
||||||
- block:
|
|
||||||
- name: Install WordPress
|
|
||||||
ansible.builtin.git: repo=https://github.com/WordPress/WordPress.git dest={{ nginx_root_prefix }}/{{ item.domain_name }}/wordpress version={{ item.wordpress_version }} depth=1 force=true
|
|
||||||
when:
|
|
||||||
- item.has_wordpress is defined
|
|
||||||
- item.has_wordpress
|
|
||||||
loop: "{{ nginx_vhosts }}"
|
|
||||||
|
|
||||||
- name: Fix WordPress directory permissions
|
|
||||||
ansible.builtin.file: path={{ nginx_root_prefix }}/{{ item.domain_name }} state=directory owner=nginx group=nginx recurse=true
|
|
||||||
when:
|
|
||||||
- item.has_wordpress is defined
|
|
||||||
- item.has_wordpress
|
|
||||||
loop: "{{ nginx_vhosts }}"
|
|
||||||
tags: wordpress
|
tags: wordpress
|
||||||
|
block:
|
||||||
|
- name: Install WordPress
|
||||||
|
when:
|
||||||
|
- item.has_wordpress is defined
|
||||||
|
- item.has_wordpress
|
||||||
|
ansible.builtin.git:
|
||||||
|
repo: https://github.com/WordPress/WordPress.git
|
||||||
|
dest: "{{ nginx_root_prefix }}/{{ item.domain_name }}/wordpress"
|
||||||
|
version: "{{ item.wordpress_version }}"
|
||||||
|
depth: 1
|
||||||
|
force: true
|
||||||
|
loop: "{{ nginx_vhosts }}"
|
||||||
|
become: true
|
||||||
|
become_user: nginx
|
||||||
|
|
||||||
|
- name: Fix WordPress directory permissions
|
||||||
|
when:
|
||||||
|
- item.has_wordpress is defined
|
||||||
|
- item.has_wordpress
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ nginx_root_prefix }}/{{ item.domain_name }}"
|
||||||
|
state: directory
|
||||||
|
owner: nginx
|
||||||
|
group: nginx
|
||||||
|
recurse: true
|
||||||
|
loop: "{{ nginx_vhosts }}"
|
||||||
|
|
||||||
# vim: set ts=2 sw=2:
|
# vim: set ts=2 sw=2:
|
||||||
|
|||||||
@@ -11,9 +11,11 @@ server {
|
|||||||
|
|
||||||
return 444;
|
return 444;
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 443 ssl http2 default_server;
|
listen 443 ssl default_server;
|
||||||
listen [::]:443 ssl http2 default_server;
|
listen [::]:443 ssl default_server;
|
||||||
|
http2 on;
|
||||||
server_name _;
|
server_name _;
|
||||||
|
|
||||||
# self-signed "snakeoil" certificate
|
# self-signed "snakeoil" certificate
|
||||||
|
|||||||
@@ -27,8 +27,9 @@
|
|||||||
|
|
||||||
ssl_dhparam {{ nginx_ssl_dhparam }};
|
ssl_dhparam {{ nginx_ssl_dhparam }};
|
||||||
ssl_protocols {{ nginx_ssl_protocols }};
|
ssl_protocols {{ nginx_ssl_protocols }};
|
||||||
|
ssl_ecdh_curve {{ nginx_ssl_ecdh_curve }};
|
||||||
ssl_ciphers "{{ tls_cipher_suite }}";
|
ssl_ciphers "{{ tls_cipher_suite }}";
|
||||||
ssl_prefer_server_ciphers on;
|
ssl_prefer_server_ciphers off;
|
||||||
|
|
||||||
{# OSCP stapling only works with real certs #}
|
{# OSCP stapling only works with real certs #}
|
||||||
{% if use_letsencrypt == true or item.tls_certificate_path %}
|
{% if use_letsencrypt == true or item.tls_certificate_path %}
|
||||||
@@ -38,15 +39,6 @@
|
|||||||
resolver {{ nginx_ssl_stapling_resolver }};
|
resolver {{ nginx_ssl_stapling_resolver }};
|
||||||
{% endif %} {# end: use_letsencrypt #}
|
{% endif %} {# end: use_letsencrypt #}
|
||||||
|
|
||||||
# nginx does not auto-rotate session ticket keys: only a HUP / restart will do so and
|
|
||||||
# when a restart is performed the previous key is lost, which resets all previous
|
|
||||||
# sessions. The fix for this is to setup a manual rotation mechanism:
|
|
||||||
# http://trac.nginx.org/nginx/changeset/1356a3b9692441e163b4e78be4e9f5a46c7479e9/nginx
|
|
||||||
#
|
|
||||||
# Note that you'll have to define and rotate the keys securely by yourself. In absence
|
|
||||||
# of such infrastructure, consider turning off session tickets:
|
|
||||||
ssl_session_tickets off;
|
|
||||||
|
|
||||||
{% if enable_hsts == true %}
|
{% if enable_hsts == true %}
|
||||||
# Enable this if you want HSTS (recommended, but be careful)
|
# Enable this if you want HSTS (recommended, but be careful)
|
||||||
# Include all subdomains and indicate to Google that we want this pre-loaded in Chrome's HSTS store
|
# Include all subdomains and indicate to Google that we want this pre-loaded in Chrome's HSTS store
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ error_log /var/log/nginx/error.log warn;
|
|||||||
# The file storing the process ID of the main process
|
# The file storing the process ID of the main process
|
||||||
pid /var/run/nginx.pid;
|
pid /var/run/nginx.pid;
|
||||||
|
|
||||||
|
|
||||||
events {
|
events {
|
||||||
# If you need more connections than this, you start optimizing your OS.
|
# If you need more connections than this, you start optimizing your OS.
|
||||||
# That's probably the point at which you hire people who are smarter than you as this is *a lot* of requests.
|
# That's probably the point at which you hire people who are smarter than you as this is *a lot* of requests.
|
||||||
@@ -23,6 +22,7 @@ events {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
http {
|
http {
|
||||||
include /etc/nginx/mime.types;
|
include /etc/nginx/mime.types;
|
||||||
default_type application/octet-stream;
|
default_type application/octet-stream;
|
||||||
|
|||||||
@@ -1,19 +1,7 @@
|
|||||||
{{ ansible_managed | comment }}
|
{{ ansible_managed | comment }}
|
||||||
|
|
||||||
{% if ansible_distribution == 'Ubuntu' %}
|
|
||||||
|
|
||||||
{% if nginx_version == "stable" %}
|
{% if nginx_version == "stable" %}
|
||||||
deb [arch=amd64 signed-by=/usr/share/keyrings/nginx_signing.key] https://nginx.org/packages/ubuntu/ {{ ansible_distribution_release }} nginx
|
deb [arch=amd64 signed-by=/usr/share/keyrings/nginx_signing.key] https://nginx.org/packages/debian/ {{ ansible_facts["distribution_release"] }} nginx
|
||||||
{% elif nginx_version == "mainline" %}
|
{% elif nginx_version == "mainline" %}
|
||||||
deb [arch=amd64 signed-by=/usr/share/keyrings/nginx_signing.key] https://nginx.org/packages/mainline/ubuntu/ {{ ansible_distribution_release }} nginx
|
deb [arch=amd64 signed-by=/usr/share/keyrings/nginx_signing.key] https://nginx.org/packages/mainline/debian/ {{ ansible_facts["distribution_release"] }} nginx
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% elif ansible_distribution == 'Debian' %}
|
|
||||||
|
|
||||||
{% if nginx_version == "stable" %}
|
|
||||||
deb [arch=amd64 signed-by=/usr/share/keyrings/nginx_signing.key] https://nginx.org/packages/debian/ {{ ansible_distribution_release }} nginx
|
|
||||||
{% elif nginx_version == "mainline" %}
|
|
||||||
deb [arch=amd64 signed-by=/usr/share/keyrings/nginx_signing.key] https://nginx.org/packages/mainline/debian/ {{ ansible_distribution_release }} nginx
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -8,6 +8,12 @@
|
|||||||
{% set has_wordpress = item.has_wordpress | default(false) %}
|
{% set has_wordpress = item.has_wordpress | default(false) %}
|
||||||
{% set needs_php = item.needs_php | default(false) %}
|
{% set needs_php = item.needs_php | default(false) %}
|
||||||
{% set has_gitea = item.has_gitea | default(false) %}
|
{% set has_gitea = item.has_gitea | default(false) %}
|
||||||
|
{# Allow sites to override the document root #}
|
||||||
|
{% if item.document_root is defined %}
|
||||||
|
{% set document_root = item.document_root %}
|
||||||
|
{% else %}
|
||||||
|
{% set document_root = (nginx_root_prefix, domain_name) | ansible.builtin.path_join %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
# http -> https vhost
|
# http -> https vhost
|
||||||
server {
|
server {
|
||||||
@@ -26,15 +32,11 @@ server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 443 ssl http2;
|
listen 443 ssl;
|
||||||
listen [::]:443 ssl http2;
|
listen [::]:443 ssl;
|
||||||
|
http2 on;
|
||||||
|
|
||||||
{# Allow sites to override the nginx document root #}
|
root {{ document_root }};
|
||||||
{% if item.document_root is defined %}
|
|
||||||
root {{ item.document_root }};
|
|
||||||
{% else %}
|
|
||||||
root {{ nginx_root_prefix }}/{{ domain_name }};
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{# will only work if the TLS cert covers the domain + aliases, like example.com and www.example.com #}
|
{# will only work if the TLS cert covers the domain + aliases, like example.com and www.example.com #}
|
||||||
server_name {{ domain_name }} {{ domain_aliases }};
|
server_name {{ domain_name }} {{ domain_aliases }};
|
||||||
@@ -75,10 +77,8 @@ server {
|
|||||||
# See: https://httpoxy.org/
|
# See: https://httpoxy.org/
|
||||||
fastcgi_param HTTP_PROXY "";
|
fastcgi_param HTTP_PROXY "";
|
||||||
|
|
||||||
{% if (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('20.04', '==')) or (ansible_distribution == 'Debian' and ansible_distribution_major_version is version('11', '==')) %}
|
{% if ansible_facts["distribution_major_version"] is version('12', '==') %}
|
||||||
fastcgi_pass unix:/run/php/php7.4-fpm-{{ domain_name }}.sock;
|
fastcgi_pass unix:/run/php/php8.2-fpm-{{ domain_name }}.sock;
|
||||||
{% else %}
|
|
||||||
fastcgi_pass unix:/var/run/php5-fpm-{{ domain_name }}.sock;
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
fastcgi_index index.php;
|
fastcgi_index index.php;
|
||||||
# set script path relative to document root in server block
|
# set script path relative to document root in server block
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
# For Ubuntu 20.04 and Debian 11
|
|
||||||
- name: reload php7.4-fpm
|
|
||||||
ansible.builtin.systemd: name=php7.4-fpm state=reloaded
|
|
||||||
|
|
||||||
# vim: set ts=2 sw=2:
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
- block:
|
|
||||||
- name: Set php-fpm packages
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
php_fpm_packages:
|
|
||||||
- php7.4-fpm
|
|
||||||
# for WordPress
|
|
||||||
- php7.4-mysql
|
|
||||||
- php7.4-gd
|
|
||||||
- php7.4-curl
|
|
||||||
- php7.4-xml
|
|
||||||
|
|
||||||
- name: Install php-fpm and deps
|
|
||||||
ansible.builtin.apt: name={{ php_fpm_packages }} state=present update_cache=true
|
|
||||||
|
|
||||||
# only copy php-fpm config for vhosts that need WordPress or PHP
|
|
||||||
- name: Copy php-fpm pool config
|
|
||||||
ansible.builtin.template: src=php7.4-pool.conf.j2 dest=/etc/php/7.4/fpm/pool.d/{{ item.domain_name }}.conf owner=root group=root mode=0644
|
|
||||||
loop: "{{ nginx_vhosts }}"
|
|
||||||
when: (item.has_wordpress is defined and item.has_wordpress) or (item.needs_php is defined and item.needs_php)
|
|
||||||
notify: reload php7.4-fpm
|
|
||||||
|
|
||||||
- name: Remove default www pool
|
|
||||||
ansible.builtin.file: path=/etc/php/7.4/fpm/pool.d/www.conf state=absent
|
|
||||||
notify: reload php7.4-fpm
|
|
||||||
|
|
||||||
# re-configure php.ini
|
|
||||||
- name: Update php.ini
|
|
||||||
ansible.builtin.template: src=php7.4-php.ini.j2 dest=/etc/php/7.4/fpm/php.ini owner=root group=root mode=0644
|
|
||||||
notify: reload php7.4-fpm
|
|
||||||
|
|
||||||
tags: php-fpm
|
|
||||||
when: install_php
|
|
||||||
|
|
||||||
# vim: set ts=2 sw=2:
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
---
|
|
||||||
# Ubuntu 20.04 uses PHP 7.4
|
|
||||||
# Debian 11 uses PHP 7.4
|
|
||||||
|
|
||||||
# If any of the vhosts on this host need WordPress then we need to install PHP.
|
|
||||||
# This uses selectattr to filter the list of dicts in nginx_vhosts, selecting
|
|
||||||
# any that have has_wordpress defined, and has_wordpress set to true.
|
|
||||||
#
|
|
||||||
# See: https://stackoverflow.com/a/31896249
|
|
||||||
- name: Check if any vhost needs WordPress
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
install_php: true
|
|
||||||
when: "nginx_vhosts | selectattr('has_wordpress', 'defined') | selectattr('has_wordpress', 'equalto', true) | list | length > 0"
|
|
||||||
|
|
||||||
# Legacy, was only for Piwik, but leaving for now.
|
|
||||||
- name: Check if any vhost needs PHP
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
install_php: true
|
|
||||||
when: "nginx_vhosts | selectattr('needs_php', 'defined') | selectattr('needs_php', 'equalto', true) | list | length > 0"
|
|
||||||
|
|
||||||
# If install_php has not been set, then we assume no vhosts need PHP. This is
|
|
||||||
# a bit hacky, but it's the closest we come to an if/then/else.
|
|
||||||
- name: Set install_php to false
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
install_php: false
|
|
||||||
when: install_php is not defined
|
|
||||||
|
|
||||||
- name: Configure php-fpm on Ubuntu 20.04
|
|
||||||
ansible.builtin.include_tasks: Ubuntu_20.04.yml
|
|
||||||
when:
|
|
||||||
- ansible_distribution == 'Ubuntu'
|
|
||||||
- ansible_distribution_version is version('20.04', '==')
|
|
||||||
- install_php == true
|
|
||||||
tags: php-fpm
|
|
||||||
|
|
||||||
- name: Configure php-fpm on Debian 11
|
|
||||||
ansible.builtin.include_tasks: Ubuntu_20.04.yml
|
|
||||||
when:
|
|
||||||
- ansible_distribution == 'Debian'
|
|
||||||
- ansible_distribution_major_version is version('11', '==')
|
|
||||||
- install_php == true
|
|
||||||
tags: php-fpm
|
|
||||||
|
|
||||||
# vim: set ts=2 sw=2:
|
|
||||||
14
roles/php_fpm/handlers/main.yml
Normal file
14
roles/php_fpm/handlers/main.yml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
# For Debian 12
|
||||||
|
- name: Reload php8.2-fpm
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: php8.2-fpm
|
||||||
|
state: reloaded
|
||||||
|
|
||||||
|
# For Debian 13
|
||||||
|
- name: Reload php8.4-fpm
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: php8.4-fpm
|
||||||
|
state: reloaded
|
||||||
|
|
||||||
|
# vim: set ts=2 sw=2:
|
||||||
90
roles/php_fpm/tasks/main.yml
Normal file
90
roles/php_fpm/tasks/main.yml
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
---
|
||||||
|
# Debian 12 uses PHP 8.2
|
||||||
|
# Debian 13 uses PHP 8.4
|
||||||
|
|
||||||
|
# If any of the vhosts on this host need WordPress then we need to install PHP.
|
||||||
|
# This uses selectattr to filter the list of dicts in nginx_vhosts, selecting
|
||||||
|
# any that have has_wordpress defined, and has_wordpress set to true.
|
||||||
|
#
|
||||||
|
# See: https://stackoverflow.com/a/31896249
|
||||||
|
- name: Check if any vhost needs WordPress
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
install_php: true
|
||||||
|
when: nginx_vhosts | selectattr('has_wordpress', 'defined') | selectattr('has_wordpress', 'equalto', true) | list | length > 0
|
||||||
|
|
||||||
|
# Legacy, was only for Piwik, but leaving for now.
|
||||||
|
- name: Check if any vhost needs PHP
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
install_php: true
|
||||||
|
when: nginx_vhosts | selectattr('needs_php', 'defined') | selectattr('needs_php', 'equalto', true) | list | length > 0
|
||||||
|
|
||||||
|
# If install_php has not been set, then we assume no vhosts need PHP. This is
|
||||||
|
# a bit hacky, but it's the closest we come to an if/then/else.
|
||||||
|
- name: Set install_php to false
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
install_php: false
|
||||||
|
when: install_php is not defined
|
||||||
|
|
||||||
|
- name: Install and configure php-fpm
|
||||||
|
tags: php-fpm
|
||||||
|
when: install_php
|
||||||
|
block:
|
||||||
|
- name: Set php-fpm packages
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
php_fpm_packages:
|
||||||
|
- php-fpm
|
||||||
|
# for WordPress
|
||||||
|
- php-mysql
|
||||||
|
- php-gd
|
||||||
|
- php-curl
|
||||||
|
- php-xml
|
||||||
|
|
||||||
|
- name: Install php-fpm and deps
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: "{{ php_fpm_packages }}"
|
||||||
|
state: present
|
||||||
|
update_cache: true
|
||||||
|
|
||||||
|
- name: Set PHP version for Debian 12
|
||||||
|
when:
|
||||||
|
- ansible_facts["distribution"] == 'Debian'
|
||||||
|
- ansible_facts["distribution_major_version"] is version('12', '==')
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
php_version: 8.2
|
||||||
|
|
||||||
|
- name: Set PHP version for Debian 13
|
||||||
|
when:
|
||||||
|
- ansible_facts["distribution"] == 'Debian'
|
||||||
|
- ansible_facts["distribution_major_version"] is version('13', '==')
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
php_version: 8.4
|
||||||
|
|
||||||
|
# only copy php-fpm config for vhosts that need WordPress or PHP
|
||||||
|
- name: Copy php-fpm pool config
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: php{{ php_version }}-pool.conf.j2
|
||||||
|
dest: /etc/php/{{ php_version }}/fpm/pool.d/{{ item.domain_name }}.conf
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
loop: "{{ nginx_vhosts }}"
|
||||||
|
when: (item.has_wordpress is defined and item.has_wordpress) or (item.needs_php is defined and item.needs_php)
|
||||||
|
notify: Reload php{{ php_version }}-fpm
|
||||||
|
|
||||||
|
- name: Remove default www pool
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/php/{{ php_version }}/fpm/pool.d/www.conf
|
||||||
|
state: absent
|
||||||
|
notify: Reload php{{ php_version }}-fpm
|
||||||
|
|
||||||
|
# re-configure php.ini
|
||||||
|
- name: Update php.ini
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: php{{ php_version }}-php.ini.j2
|
||||||
|
dest: /etc/php/{{ php_version }}/fpm/php.ini
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
notify: Reload php{{ php_version }}-fpm
|
||||||
|
|
||||||
|
# vim: set ts=2 sw=2:
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -19,11 +19,16 @@
|
|||||||
; Default Value: none
|
; Default Value: none
|
||||||
;prefix = /path/to/pools/$pool
|
;prefix = /path/to/pools/$pool
|
||||||
|
|
||||||
; Unix user/group of processes
|
; Unix user/group of the child processes. This can be used only if the master
|
||||||
; Note: The user is mandatory. If the group is not set, the default user's group
|
; process running user is root. It is set after the child process is created.
|
||||||
; will be used.
|
; The user and group can be specified either by their name or by their numeric
|
||||||
user = nginx
|
; IDs.
|
||||||
group = nginx
|
; Note: If the user is root, the executable needs to be started with
|
||||||
|
; --allow-to-run-as-root option to work.
|
||||||
|
; Default Values: The user is set to master process running user by default.
|
||||||
|
; If the group is not set, the user's group is used.
|
||||||
|
user = {{ webserver }}
|
||||||
|
group = {{ webserver }}
|
||||||
|
|
||||||
; The address on which to accept FastCGI requests.
|
; The address on which to accept FastCGI requests.
|
||||||
; Valid syntaxes are:
|
; Valid syntaxes are:
|
||||||
@@ -35,20 +40,22 @@ group = nginx
|
|||||||
; (IPv6 and IPv4-mapped) on a specific port;
|
; (IPv6 and IPv4-mapped) on a specific port;
|
||||||
; '/path/to/unix/socket' - to listen on a unix socket.
|
; '/path/to/unix/socket' - to listen on a unix socket.
|
||||||
; Note: This value is mandatory.
|
; Note: This value is mandatory.
|
||||||
listen = /run/php/php7.4-fpm-{{ domain_name }}.sock
|
listen = /run/php/php8.2-fpm-{{ domain_name }}.sock
|
||||||
|
|
||||||
; Set listen(2) backlog.
|
; Set listen(2) backlog.
|
||||||
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
|
; Default Value: 511 (-1 on Linux, FreeBSD and OpenBSD)
|
||||||
;listen.backlog = 511
|
;listen.backlog = 511
|
||||||
|
|
||||||
; Set permissions for unix socket, if one is used. In Linux, read/write
|
; Set permissions for unix socket, if one is used. In Linux, read/write
|
||||||
; permissions must be set in order to allow connections from a web server. Many
|
; permissions must be set in order to allow connections from a web server. Many
|
||||||
; BSD-derived systems allow connections regardless of permissions.
|
; BSD-derived systems allow connections regardless of permissions. The owner
|
||||||
; Default Values: user and group are set as the running user
|
; and group can be specified either by name or by their numeric IDs.
|
||||||
; mode is set to 0660
|
; Default Values: Owner is set to the master process running user. If the group
|
||||||
listen.owner = nginx
|
; is not set, the owner's group is used. Mode is set to 0660.
|
||||||
listen.group = nginx
|
listen.owner = {{ webserver }}
|
||||||
|
listen.group = {{ webserver }}
|
||||||
;listen.mode = 0660
|
;listen.mode = 0660
|
||||||
|
|
||||||
; When POSIX Access Control Lists are supported you can set them using
|
; When POSIX Access Control Lists are supported you can set them using
|
||||||
; these options, value is a comma separated list of user/group names.
|
; these options, value is a comma separated list of user/group names.
|
||||||
; When set, listen.owner and listen.group are ignored
|
; When set, listen.owner and listen.group are ignored
|
||||||
@@ -63,6 +70,10 @@ listen.group = nginx
|
|||||||
; Default Value: any
|
; Default Value: any
|
||||||
;listen.allowed_clients = 127.0.0.1
|
;listen.allowed_clients = 127.0.0.1
|
||||||
|
|
||||||
|
; Set the associated the route table (FIB). FreeBSD only
|
||||||
|
; Default Value: -1
|
||||||
|
;listen.setfib = 1
|
||||||
|
|
||||||
; Specify the nice(2) priority to apply to the pool processes (only if set)
|
; Specify the nice(2) priority to apply to the pool processes (only if set)
|
||||||
; The value can vary from -19 (highest priority) to 20 (lower priority)
|
; The value can vary from -19 (highest priority) to 20 (lower priority)
|
||||||
; Note: - It will only work if the FPM master process is launched as root
|
; Note: - It will only work if the FPM master process is launched as root
|
||||||
@@ -71,8 +82,9 @@ listen.group = nginx
|
|||||||
; Default Value: no set
|
; Default Value: no set
|
||||||
; process.priority = -19
|
; process.priority = -19
|
||||||
|
|
||||||
; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user
|
; Set the process dumpable flag (PR_SET_DUMPABLE prctl for Linux or
|
||||||
; or group is differrent than the master process user. It allows to create process
|
; PROC_TRACE_CTL procctl for FreeBSD) even if the process user
|
||||||
|
; or group is different than the master process user. It allows to create process
|
||||||
; core dump and ptrace the process for the pool user.
|
; core dump and ptrace the process for the pool user.
|
||||||
; Default Value: no
|
; Default Value: no
|
||||||
; process.dumpable = yes
|
; process.dumpable = yes
|
||||||
@@ -94,6 +106,8 @@ listen.group = nginx
|
|||||||
; state (waiting to process). If the number
|
; state (waiting to process). If the number
|
||||||
; of 'idle' processes is greater than this
|
; of 'idle' processes is greater than this
|
||||||
; number then some children will be killed.
|
; number then some children will be killed.
|
||||||
|
; pm.max_spawn_rate - the maximum number of rate to spawn child
|
||||||
|
; processes at once.
|
||||||
; ondemand - no children are created at startup. Children will be forked when
|
; ondemand - no children are created at startup. Children will be forked when
|
||||||
; new requests will connect. The following parameter are used:
|
; new requests will connect. The following parameter are used:
|
||||||
; pm.max_children - the maximum number of children that
|
; pm.max_children - the maximum number of children that
|
||||||
@@ -129,6 +143,12 @@ pm.min_spare_servers = 1
|
|||||||
; Note: Mandatory when pm is set to 'dynamic'
|
; Note: Mandatory when pm is set to 'dynamic'
|
||||||
pm.max_spare_servers = 3
|
pm.max_spare_servers = 3
|
||||||
|
|
||||||
|
; The number of rate to spawn child processes at once.
|
||||||
|
; Note: Used only when pm is set to 'dynamic'
|
||||||
|
; Note: Mandatory when pm is set to 'dynamic'
|
||||||
|
; Default Value: 32
|
||||||
|
;pm.max_spawn_rate = 32
|
||||||
|
|
||||||
; The number of seconds after which an idle process will be killed.
|
; The number of seconds after which an idle process will be killed.
|
||||||
; Note: Used only when pm is set to 'ondemand'
|
; Note: Used only when pm is set to 'ondemand'
|
||||||
; Default Value: 10s
|
; Default Value: 10s
|
||||||
@@ -141,7 +161,7 @@ pm.max_spare_servers = 3
|
|||||||
;pm.max_requests = 500
|
;pm.max_requests = 500
|
||||||
|
|
||||||
; The URI to view the FPM status page. If this value is not set, no URI will be
|
; The URI to view the FPM status page. If this value is not set, no URI will be
|
||||||
; recognized as a status page. It shows the following informations:
|
; recognized as a status page. It shows the following information:
|
||||||
; pool - the name of the pool;
|
; pool - the name of the pool;
|
||||||
; process manager - static, dynamic or ondemand;
|
; process manager - static, dynamic or ondemand;
|
||||||
; start time - the date and time FPM has started;
|
; start time - the date and time FPM has started;
|
||||||
@@ -231,7 +251,7 @@ pm.max_spare_servers = 3
|
|||||||
; last request memory: 0
|
; last request memory: 0
|
||||||
;
|
;
|
||||||
; Note: There is a real-time FPM status monitoring sample web page available
|
; Note: There is a real-time FPM status monitoring sample web page available
|
||||||
; It's available in: /usr/share/php/7.4/fpm/status.html
|
; It's available in: /usr/share/php/8.2/fpm/status.html
|
||||||
;
|
;
|
||||||
; Note: The value must start with a leading slash (/). The value can be
|
; Note: The value must start with a leading slash (/). The value can be
|
||||||
; anything, but it may not be a good idea to use the .php extension or it
|
; anything, but it may not be a good idea to use the .php extension or it
|
||||||
@@ -239,6 +259,22 @@ pm.max_spare_servers = 3
|
|||||||
; Default Value: not set
|
; Default Value: not set
|
||||||
;pm.status_path = /status
|
;pm.status_path = /status
|
||||||
|
|
||||||
|
; The address on which to accept FastCGI status request. This creates a new
|
||||||
|
; invisible pool that can handle requests independently. This is useful
|
||||||
|
; if the main pool is busy with long running requests because it is still possible
|
||||||
|
; to get the status before finishing the long running requests.
|
||||||
|
;
|
||||||
|
; Valid syntaxes are:
|
||||||
|
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
|
||||||
|
; a specific port;
|
||||||
|
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
|
||||||
|
; a specific port;
|
||||||
|
; 'port' - to listen on a TCP socket to all addresses
|
||||||
|
; (IPv6 and IPv4-mapped) on a specific port;
|
||||||
|
; '/path/to/unix/socket' - to listen on a unix socket.
|
||||||
|
; Default Value: value of the listen option
|
||||||
|
;pm.status_listen = 127.0.0.1:9001
|
||||||
|
|
||||||
; The ping URI to call the monitoring page of FPM. If this value is not set, no
|
; The ping URI to call the monitoring page of FPM. If this value is not set, no
|
||||||
; URI will be recognized as a ping page. This could be used to test from outside
|
; URI will be recognized as a ping page. This could be used to test from outside
|
||||||
; that FPM is alive and responding, or to
|
; that FPM is alive and responding, or to
|
||||||
@@ -271,13 +307,13 @@ pm.max_spare_servers = 3
|
|||||||
; %d: time taken to serve the request
|
; %d: time taken to serve the request
|
||||||
; it can accept the following format:
|
; it can accept the following format:
|
||||||
; - %{seconds}d (default)
|
; - %{seconds}d (default)
|
||||||
; - %{miliseconds}d
|
; - %{milliseconds}d
|
||||||
; - %{mili}d
|
; - %{milli}d
|
||||||
; - %{microseconds}d
|
; - %{microseconds}d
|
||||||
; - %{micro}d
|
; - %{micro}d
|
||||||
; %e: an environment variable (same as $_ENV or $_SERVER)
|
; %e: an environment variable (same as $_ENV or $_SERVER)
|
||||||
; it must be associated with embraces to specify the name of the env
|
; it must be associated with embraces to specify the name of the env
|
||||||
; variable. Some exemples:
|
; variable. Some examples:
|
||||||
; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
|
; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
|
||||||
; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
|
; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
|
||||||
; %f: script filename
|
; %f: script filename
|
||||||
@@ -306,14 +342,30 @@ pm.max_spare_servers = 3
|
|||||||
; %s: status (response code)
|
; %s: status (response code)
|
||||||
; %t: server time the request was received
|
; %t: server time the request was received
|
||||||
; it can accept a strftime(3) format:
|
; it can accept a strftime(3) format:
|
||||||
; The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag
|
; The strftime(3) format must be encapsulated in a %{<strftime_format>}t tag
|
||||||
; %T: time the log has been written (the request has finished)
|
; %T: time the log has been written (the request has finished)
|
||||||
; it can accept a strftime(3) format:
|
; it can accept a strftime(3) format:
|
||||||
; The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag
|
; The strftime(3) format must be encapsulated in a %{<strftime_format>}t tag
|
||||||
; %u: remote user
|
; %u: remote user
|
||||||
;
|
;
|
||||||
; Default: "%R - %u %t \"%m %r\" %s"
|
; Default: "%R - %u %t \"%m %r\" %s"
|
||||||
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
|
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{milli}d %{kilo}M %C%%"
|
||||||
|
|
||||||
|
; A list of request_uri values which should be filtered from the access log.
|
||||||
|
;
|
||||||
|
; As a security precuation, this setting will be ignored if:
|
||||||
|
; - the request method is not GET or HEAD; or
|
||||||
|
; - there is a request body; or
|
||||||
|
; - there are query parameters; or
|
||||||
|
; - the response code is outwith the successful range of 200 to 299
|
||||||
|
;
|
||||||
|
; Note: The paths are matched against the output of the access.format tag "%r".
|
||||||
|
; On common configurations, this may look more like SCRIPT_NAME than the
|
||||||
|
; expected pre-rewrite URI.
|
||||||
|
;
|
||||||
|
; Default Value: not set
|
||||||
|
;access.suppress_path[] = /ping
|
||||||
|
;access.suppress_path[] = /health_check.php
|
||||||
|
|
||||||
; The log file for slow requests
|
; The log file for slow requests
|
||||||
; Default Value: not set
|
; Default Value: not set
|
||||||
@@ -372,7 +424,7 @@ pm.max_spare_servers = 3
|
|||||||
|
|
||||||
; Redirect worker stdout and stderr into main error log. If not set, stdout and
|
; Redirect worker stdout and stderr into main error log. If not set, stdout and
|
||||||
; stderr will be redirected to /dev/null according to FastCGI specs.
|
; stderr will be redirected to /dev/null according to FastCGI specs.
|
||||||
; Note: on highloaded environement, this can cause some delay in the page
|
; Note: on highloaded environment, this can cause some delay in the page
|
||||||
; process time (several ms).
|
; process time (several ms).
|
||||||
; Default Value: no
|
; Default Value: no
|
||||||
;catch_workers_output = yes
|
;catch_workers_output = yes
|
||||||
1857
roles/php_fpm/templates/php8.4-php.ini.j2
Normal file
1857
roles/php_fpm/templates/php8.4-php.ini.j2
Normal file
File diff suppressed because it is too large
Load Diff
488
roles/php_fpm/templates/php8.4-pool.conf.j2
Normal file
488
roles/php_fpm/templates/php8.4-pool.conf.j2
Normal file
@@ -0,0 +1,488 @@
|
|||||||
|
{% set domain_name = item.domain_name %}
|
||||||
|
|
||||||
|
; Start a new pool named '{{ domain_name }}'.
|
||||||
|
; the variable $pool can be used in any directive and will be replaced by the
|
||||||
|
; pool name ('{{ domain_name }}' here)
|
||||||
|
[{{ domain_name }}]
|
||||||
|
|
||||||
|
; Per pool prefix
|
||||||
|
; It only applies on the following directives:
|
||||||
|
; - 'access.log'
|
||||||
|
; - 'slowlog'
|
||||||
|
; - 'listen' (unixsocket)
|
||||||
|
; - 'chroot'
|
||||||
|
; - 'chdir'
|
||||||
|
; - 'php_values'
|
||||||
|
; - 'php_admin_values'
|
||||||
|
; When not set, the global prefix (or /usr) applies instead.
|
||||||
|
; Note: This directive can also be relative to the global prefix.
|
||||||
|
; Default Value: none
|
||||||
|
;prefix = /path/to/pools/$pool
|
||||||
|
|
||||||
|
; Unix user/group of the child processes. This can be used only if the master
|
||||||
|
; process running user is root. It is set after the child process is created.
|
||||||
|
; The user and group can be specified either by their name or by their numeric
|
||||||
|
; IDs.
|
||||||
|
; Note: If the user is root, the executable needs to be started with
|
||||||
|
; --allow-to-run-as-root option to work.
|
||||||
|
; Default Values: The user is set to master process running user by default.
|
||||||
|
; If the group is not set, the user's group is used.
|
||||||
|
user = {{ webserver }}
|
||||||
|
group = {{ webserver }}
|
||||||
|
|
||||||
|
; The address on which to accept FastCGI requests.
|
||||||
|
; Valid syntaxes are:
|
||||||
|
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
|
||||||
|
; a specific port;
|
||||||
|
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
|
||||||
|
; a specific port;
|
||||||
|
; 'port' - to listen on a TCP socket to all addresses
|
||||||
|
; (IPv6 and IPv4-mapped) on a specific port;
|
||||||
|
; '/path/to/unix/socket' - to listen on a unix socket.
|
||||||
|
; Note: This value is mandatory.
|
||||||
|
listen = /run/php/php8.2-fpm-{{ domain_name }}.sock
|
||||||
|
|
||||||
|
; Set listen(2) backlog.
|
||||||
|
; Default Value: 511 (-1 on Linux, FreeBSD and OpenBSD)
|
||||||
|
;listen.backlog = 511
|
||||||
|
|
||||||
|
; Set permissions for unix socket, if one is used. In Linux, read/write
|
||||||
|
; permissions must be set in order to allow connections from a web server. Many
|
||||||
|
; BSD-derived systems allow connections regardless of permissions. The owner
|
||||||
|
; and group can be specified either by name or by their numeric IDs.
|
||||||
|
; Default Values: Owner is set to the master process running user. If the group
|
||||||
|
; is not set, the owner's group is used. Mode is set to 0660.
|
||||||
|
listen.owner = {{ webserver }}
|
||||||
|
listen.group = {{ webserver }}
|
||||||
|
;listen.mode = 0660
|
||||||
|
|
||||||
|
; When POSIX Access Control Lists are supported you can set them using
|
||||||
|
; these options, value is a comma separated list of user/group names.
|
||||||
|
; When set, listen.owner and listen.group are ignored
|
||||||
|
;listen.acl_users =
|
||||||
|
;listen.acl_groups =
|
||||||
|
|
||||||
|
; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
|
||||||
|
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
|
||||||
|
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
|
||||||
|
; must be separated by a comma. If this value is left blank, connections will be
|
||||||
|
; accepted from any ip address.
|
||||||
|
; Default Value: any
|
||||||
|
;listen.allowed_clients = 127.0.0.1
|
||||||
|
|
||||||
|
; Set the associated the route table (FIB). FreeBSD only
|
||||||
|
; Default Value: -1
|
||||||
|
;listen.setfib = 1
|
||||||
|
|
||||||
|
; Specify the nice(2) priority to apply to the pool processes (only if set)
|
||||||
|
; The value can vary from -19 (highest priority) to 20 (lower priority)
|
||||||
|
; Note: - It will only work if the FPM master process is launched as root
|
||||||
|
; - The pool processes will inherit the master process priority
|
||||||
|
; unless it specified otherwise
|
||||||
|
; Default Value: no set
|
||||||
|
; process.priority = -19
|
||||||
|
|
||||||
|
; Set the process dumpable flag (PR_SET_DUMPABLE prctl for Linux or
|
||||||
|
; PROC_TRACE_CTL procctl for FreeBSD) even if the process user
|
||||||
|
; or group is different than the master process user. It allows to create process
|
||||||
|
; core dump and ptrace the process for the pool user.
|
||||||
|
; Default Value: no
|
||||||
|
; process.dumpable = yes
|
||||||
|
|
||||||
|
; Choose how the process manager will control the number of child processes.
|
||||||
|
; Possible Values:
|
||||||
|
; static - a fixed number (pm.max_children) of child processes;
|
||||||
|
; dynamic - the number of child processes are set dynamically based on the
|
||||||
|
; following directives. With this process management, there will be
|
||||||
|
; always at least 1 children.
|
||||||
|
; pm.max_children - the maximum number of children that can
|
||||||
|
; be alive at the same time.
|
||||||
|
; pm.start_servers - the number of children created on startup.
|
||||||
|
; pm.min_spare_servers - the minimum number of children in 'idle'
|
||||||
|
; state (waiting to process). If the number
|
||||||
|
; of 'idle' processes is less than this
|
||||||
|
; number then some children will be created.
|
||||||
|
; pm.max_spare_servers - the maximum number of children in 'idle'
|
||||||
|
; state (waiting to process). If the number
|
||||||
|
; of 'idle' processes is greater than this
|
||||||
|
; number then some children will be killed.
|
||||||
|
; pm.max_spawn_rate - the maximum number of rate to spawn child
|
||||||
|
; processes at once.
|
||||||
|
; ondemand - no children are created at startup. Children will be forked when
|
||||||
|
; new requests will connect. The following parameter are used:
|
||||||
|
; pm.max_children - the maximum number of children that
|
||||||
|
; can be alive at the same time.
|
||||||
|
; pm.process_idle_timeout - The number of seconds after which
|
||||||
|
; an idle process will be killed.
|
||||||
|
; Note: This value is mandatory.
|
||||||
|
pm = dynamic
|
||||||
|
|
||||||
|
; The number of child processes to be created when pm is set to 'static' and the
|
||||||
|
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
|
||||||
|
; This value sets the limit on the number of simultaneous requests that will be
|
||||||
|
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
|
||||||
|
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
|
||||||
|
; CGI. The below defaults are based on a server without much resources. Don't
|
||||||
|
; forget to tweak pm.* to fit your needs.
|
||||||
|
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
|
||||||
|
; Note: This value is mandatory.
|
||||||
|
pm.max_children = 5
|
||||||
|
|
||||||
|
; The number of child processes created on startup.
|
||||||
|
; Note: Used only when pm is set to 'dynamic'
|
||||||
|
; Default Value: (min_spare_servers + max_spare_servers) / 2
|
||||||
|
pm.start_servers = 2
|
||||||
|
|
||||||
|
; The desired minimum number of idle server processes.
|
||||||
|
; Note: Used only when pm is set to 'dynamic'
|
||||||
|
; Note: Mandatory when pm is set to 'dynamic'
|
||||||
|
pm.min_spare_servers = 1
|
||||||
|
|
||||||
|
; The desired maximum number of idle server processes.
|
||||||
|
; Note: Used only when pm is set to 'dynamic'
|
||||||
|
; Note: Mandatory when pm is set to 'dynamic'
|
||||||
|
pm.max_spare_servers = 3
|
||||||
|
|
||||||
|
; The number of rate to spawn child processes at once.
|
||||||
|
; Note: Used only when pm is set to 'dynamic'
|
||||||
|
; Note: Mandatory when pm is set to 'dynamic'
|
||||||
|
; Default Value: 32
|
||||||
|
;pm.max_spawn_rate = 32
|
||||||
|
|
||||||
|
; The number of seconds after which an idle process will be killed.
|
||||||
|
; Note: Used only when pm is set to 'ondemand'
|
||||||
|
; Default Value: 10s
|
||||||
|
;pm.process_idle_timeout = 10s;
|
||||||
|
|
||||||
|
; The number of requests each child process should execute before respawning.
|
||||||
|
; This can be useful to work around memory leaks in 3rd party libraries. For
|
||||||
|
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
|
||||||
|
; Default Value: 0
|
||||||
|
;pm.max_requests = 500
|
||||||
|
|
||||||
|
; The URI to view the FPM status page. If this value is not set, no URI will be
|
||||||
|
; recognized as a status page. It shows the following information:
|
||||||
|
; pool - the name of the pool;
|
||||||
|
; process manager - static, dynamic or ondemand;
|
||||||
|
; start time - the date and time FPM has started;
|
||||||
|
; start since - number of seconds since FPM has started;
|
||||||
|
; accepted conn - the number of request accepted by the pool;
|
||||||
|
; listen queue - the number of request in the queue of pending
|
||||||
|
; connections (see backlog in listen(2));
|
||||||
|
; max listen queue - the maximum number of requests in the queue
|
||||||
|
; of pending connections since FPM has started;
|
||||||
|
; listen queue len - the size of the socket queue of pending connections;
|
||||||
|
; idle processes - the number of idle processes;
|
||||||
|
; active processes - the number of active processes;
|
||||||
|
; total processes - the number of idle + active processes;
|
||||||
|
; max active processes - the maximum number of active processes since FPM
|
||||||
|
; has started;
|
||||||
|
; max children reached - number of times, the process limit has been reached,
|
||||||
|
; when pm tries to start more children (works only for
|
||||||
|
; pm 'dynamic' and 'ondemand');
|
||||||
|
; Value are updated in real time.
|
||||||
|
; Example output:
|
||||||
|
; pool: www
|
||||||
|
; process manager: static
|
||||||
|
; start time: 01/Jul/2011:17:53:49 +0200
|
||||||
|
; start since: 62636
|
||||||
|
; accepted conn: 190460
|
||||||
|
; listen queue: 0
|
||||||
|
; max listen queue: 1
|
||||||
|
; listen queue len: 42
|
||||||
|
; idle processes: 4
|
||||||
|
; active processes: 11
|
||||||
|
; total processes: 15
|
||||||
|
; max active processes: 12
|
||||||
|
; max children reached: 0
|
||||||
|
;
|
||||||
|
; By default the status page output is formatted as text/plain. Passing either
|
||||||
|
; 'html', 'xml' or 'json' in the query string will return the corresponding
|
||||||
|
; output syntax. Example:
|
||||||
|
; http://www.foo.bar/status
|
||||||
|
; http://www.foo.bar/status?json
|
||||||
|
; http://www.foo.bar/status?html
|
||||||
|
; http://www.foo.bar/status?xml
|
||||||
|
;
|
||||||
|
; By default the status page only outputs short status. Passing 'full' in the
|
||||||
|
; query string will also return status for each pool process.
|
||||||
|
; Example:
|
||||||
|
; http://www.foo.bar/status?full
|
||||||
|
; http://www.foo.bar/status?json&full
|
||||||
|
; http://www.foo.bar/status?html&full
|
||||||
|
; http://www.foo.bar/status?xml&full
|
||||||
|
; The Full status returns for each process:
|
||||||
|
; pid - the PID of the process;
|
||||||
|
; state - the state of the process (Idle, Running, ...);
|
||||||
|
; start time - the date and time the process has started;
|
||||||
|
; start since - the number of seconds since the process has started;
|
||||||
|
; requests - the number of requests the process has served;
|
||||||
|
; request duration - the duration in µs of the requests;
|
||||||
|
; request method - the request method (GET, POST, ...);
|
||||||
|
; request URI - the request URI with the query string;
|
||||||
|
; content length - the content length of the request (only with POST);
|
||||||
|
; user - the user (PHP_AUTH_USER) (or '-' if not set);
|
||||||
|
; script - the main script called (or '-' if not set);
|
||||||
|
; last request cpu - the %cpu the last request consumed
|
||||||
|
; it's always 0 if the process is not in Idle state
|
||||||
|
; because CPU calculation is done when the request
|
||||||
|
; processing has terminated;
|
||||||
|
; last request memory - the max amount of memory the last request consumed
|
||||||
|
; it's always 0 if the process is not in Idle state
|
||||||
|
; because memory calculation is done when the request
|
||||||
|
; processing has terminated;
|
||||||
|
; If the process is in Idle state, then information is related to the
|
||||||
|
; last request the process has served. Otherwise information is related to
|
||||||
|
; the current request being served.
|
||||||
|
; Example output:
|
||||||
|
; ************************
|
||||||
|
; pid: 31330
|
||||||
|
; state: Running
|
||||||
|
; start time: 01/Jul/2011:17:53:49 +0200
|
||||||
|
; start since: 63087
|
||||||
|
; requests: 12808
|
||||||
|
; request duration: 1250261
|
||||||
|
; request method: GET
|
||||||
|
; request URI: /test_mem.php?N=10000
|
||||||
|
; content length: 0
|
||||||
|
; user: -
|
||||||
|
; script: /home/fat/web/docs/php/test_mem.php
|
||||||
|
; last request cpu: 0.00
|
||||||
|
; last request memory: 0
|
||||||
|
;
|
||||||
|
; Note: There is a real-time FPM status monitoring sample web page available
|
||||||
|
; It's available in: /usr/share/php/8.4/fpm/status.html
|
||||||
|
;
|
||||||
|
; Note: The value must start with a leading slash (/). The value can be
|
||||||
|
; anything, but it may not be a good idea to use the .php extension or it
|
||||||
|
; may conflict with a real PHP file.
|
||||||
|
; Default Value: not set
|
||||||
|
;pm.status_path = /status
|
||||||
|
|
||||||
|
; The address on which to accept FastCGI status request. This creates a new
|
||||||
|
; invisible pool that can handle requests independently. This is useful
|
||||||
|
; if the main pool is busy with long running requests because it is still possible
|
||||||
|
; to get the status before finishing the long running requests.
|
||||||
|
;
|
||||||
|
; Valid syntaxes are:
|
||||||
|
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
|
||||||
|
; a specific port;
|
||||||
|
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
|
||||||
|
; a specific port;
|
||||||
|
; 'port' - to listen on a TCP socket to all addresses
|
||||||
|
; (IPv6 and IPv4-mapped) on a specific port;
|
||||||
|
; '/path/to/unix/socket' - to listen on a unix socket.
|
||||||
|
; Default Value: value of the listen option
|
||||||
|
;pm.status_listen = 127.0.0.1:9001
|
||||||
|
|
||||||
|
; The ping URI to call the monitoring page of FPM. If this value is not set, no
|
||||||
|
; URI will be recognized as a ping page. This could be used to test from outside
|
||||||
|
; that FPM is alive and responding, or to
|
||||||
|
; - create a graph of FPM availability (rrd or such);
|
||||||
|
; - remove a server from a group if it is not responding (load balancing);
|
||||||
|
; - trigger alerts for the operating team (24/7).
|
||||||
|
; Note: The value must start with a leading slash (/). The value can be
|
||||||
|
; anything, but it may not be a good idea to use the .php extension or it
|
||||||
|
; may conflict with a real PHP file.
|
||||||
|
; Default Value: not set
|
||||||
|
;ping.path = /ping
|
||||||
|
|
||||||
|
; This directive may be used to customize the response of a ping request. The
|
||||||
|
; response is formatted as text/plain with a 200 response code.
|
||||||
|
; Default Value: pong
|
||||||
|
;ping.response = pong
|
||||||
|
|
||||||
|
; The access log file
|
||||||
|
; Default: not set
|
||||||
|
;access.log = log/$pool.access.log
|
||||||
|
|
||||||
|
; The access log format.
|
||||||
|
; The following syntax is allowed
|
||||||
|
; %%: the '%' character
|
||||||
|
; %C: %CPU used by the request
|
||||||
|
; it can accept the following format:
|
||||||
|
; - %{user}C for user CPU only
|
||||||
|
; - %{system}C for system CPU only
|
||||||
|
; - %{total}C for user + system CPU (default)
|
||||||
|
; %d: time taken to serve the request
|
||||||
|
; it can accept the following format:
|
||||||
|
; - %{seconds}d (default)
|
||||||
|
; - %{milliseconds}d
|
||||||
|
; - %{milli}d
|
||||||
|
; - %{microseconds}d
|
||||||
|
; - %{micro}d
|
||||||
|
; %e: an environment variable (same as $_ENV or $_SERVER)
|
||||||
|
; it must be associated with embraces to specify the name of the env
|
||||||
|
; variable. Some examples:
|
||||||
|
; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
|
||||||
|
; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
|
||||||
|
; %f: script filename
|
||||||
|
; %l: content-length of the request (for POST request only)
|
||||||
|
; %m: request method
|
||||||
|
; %M: peak of memory allocated by PHP
|
||||||
|
; it can accept the following format:
|
||||||
|
; - %{bytes}M (default)
|
||||||
|
; - %{kilobytes}M
|
||||||
|
; - %{kilo}M
|
||||||
|
; - %{megabytes}M
|
||||||
|
; - %{mega}M
|
||||||
|
; %n: pool name
|
||||||
|
; %o: output header
|
||||||
|
; it must be associated with embraces to specify the name of the header:
|
||||||
|
; - %{Content-Type}o
|
||||||
|
; - %{X-Powered-By}o
|
||||||
|
; - %{Transfert-Encoding}o
|
||||||
|
; - ....
|
||||||
|
; %p: PID of the child that serviced the request
|
||||||
|
; %P: PID of the parent of the child that serviced the request
|
||||||
|
; %q: the query string
|
||||||
|
; %Q: the '?' character if query string exists
|
||||||
|
; %r: the request URI (without the query string, see %q and %Q)
|
||||||
|
; %R: remote IP address
|
||||||
|
; %s: status (response code)
|
||||||
|
; %t: server time the request was received
|
||||||
|
; it can accept a strftime(3) format:
|
||||||
|
; The strftime(3) format must be encapsulated in a %{<strftime_format>}t tag
|
||||||
|
; %T: time the log has been written (the request has finished)
|
||||||
|
; it can accept a strftime(3) format:
|
||||||
|
; The strftime(3) format must be encapsulated in a %{<strftime_format>}t tag
|
||||||
|
; %u: basic auth user if specified in Authorization header
|
||||||
|
;
|
||||||
|
; Default: "%R - %u %t \"%m %r\" %s"
|
||||||
|
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{milli}d %{kilo}M %C%%"
|
||||||
|
|
||||||
|
; A list of request_uri values which should be filtered from the access log.
|
||||||
|
;
|
||||||
|
; As a security precaution, this setting will be ignored if:
|
||||||
|
; - the request method is not GET or HEAD; or
|
||||||
|
; - there is a request body; or
|
||||||
|
; - there are query parameters; or
|
||||||
|
; - the response code is outwith the successful range of 200 to 299
|
||||||
|
;
|
||||||
|
; Note: The paths are matched against the output of the access.format tag "%r".
|
||||||
|
; On common configurations, this may look more like SCRIPT_NAME than the
|
||||||
|
; expected pre-rewrite URI.
|
||||||
|
;
|
||||||
|
; Default Value: not set
|
||||||
|
;access.suppress_path[] = /ping
|
||||||
|
;access.suppress_path[] = /health_check.php
|
||||||
|
|
||||||
|
; The log file for slow requests
|
||||||
|
; Default Value: not set
|
||||||
|
; Note: slowlog is mandatory if request_slowlog_timeout is set
|
||||||
|
;slowlog = log/$pool.log.slow
|
||||||
|
|
||||||
|
; The timeout for serving a single request after which a PHP backtrace will be
|
||||||
|
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
|
||||||
|
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
|
||||||
|
; Default Value: 0
|
||||||
|
;request_slowlog_timeout = 0
|
||||||
|
|
||||||
|
; Depth of slow log stack trace.
|
||||||
|
; Default Value: 20
|
||||||
|
;request_slowlog_trace_depth = 20
|
||||||
|
|
||||||
|
; The timeout for serving a single request after which the worker process will
|
||||||
|
; be killed. This option should be used when the 'max_execution_time' ini option
|
||||||
|
; does not stop script execution for some reason. A value of '0' means 'off'.
|
||||||
|
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
|
||||||
|
; Default Value: 0
|
||||||
|
;request_terminate_timeout = 0
|
||||||
|
|
||||||
|
; The timeout set by 'request_terminate_timeout' ini option is not engaged after
|
||||||
|
; application calls 'fastcgi_finish_request' or when application has finished and
|
||||||
|
; shutdown functions are being called (registered via register_shutdown_function).
|
||||||
|
; This option will enable timeout limit to be applied unconditionally
|
||||||
|
; even in such cases.
|
||||||
|
; Default Value: no
|
||||||
|
;request_terminate_timeout_track_finished = no
|
||||||
|
|
||||||
|
; Set open file descriptor rlimit.
|
||||||
|
; Default Value: system defined value
|
||||||
|
;rlimit_files = 1024
|
||||||
|
|
||||||
|
; Set max core size rlimit.
|
||||||
|
; Possible Values: 'unlimited' or an integer greater or equal to 0
|
||||||
|
; Default Value: system defined value
|
||||||
|
;rlimit_core = 0
|
||||||
|
|
||||||
|
; Chroot to this directory at the start. This value must be defined as an
|
||||||
|
; absolute path. When this value is not set, chroot is not used.
|
||||||
|
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
|
||||||
|
; of its subdirectories. If the pool prefix is not set, the global prefix
|
||||||
|
; will be used instead.
|
||||||
|
; Note: chrooting is a great security feature and should be used whenever
|
||||||
|
; possible. However, all PHP paths will be relative to the chroot
|
||||||
|
; (error_log, sessions.save_path, ...).
|
||||||
|
; Default Value: not set
|
||||||
|
;chroot =
|
||||||
|
|
||||||
|
; Chdir to this directory at the start.
|
||||||
|
; Note: relative path can be used.
|
||||||
|
; Default Value: current directory or / when chroot
|
||||||
|
;chdir = /var/www
|
||||||
|
|
||||||
|
; Redirect worker stdout and stderr into main error log. If not set, stdout and
|
||||||
|
; stderr will be redirected to /dev/null according to FastCGI specs.
|
||||||
|
; Note: on highloaded environment, this can cause some delay in the page
|
||||||
|
; process time (several ms).
|
||||||
|
; Default Value: no
|
||||||
|
;catch_workers_output = yes
|
||||||
|
|
||||||
|
; Decorate worker output with prefix and suffix containing information about
|
||||||
|
; the child that writes to the log and if stdout or stderr is used as well as
|
||||||
|
; log level and time. This options is used only if catch_workers_output is yes.
|
||||||
|
; Settings to "no" will output data as written to the stdout or stderr.
|
||||||
|
; Default value: yes
|
||||||
|
;decorate_workers_output = no
|
||||||
|
|
||||||
|
; Clear environment in FPM workers
|
||||||
|
; Prevents arbitrary environment variables from reaching FPM worker processes
|
||||||
|
; by clearing the environment in workers before env vars specified in this
|
||||||
|
; pool configuration are added.
|
||||||
|
; Setting to "no" will make all environment variables available to PHP code
|
||||||
|
; via getenv(), $_ENV and $_SERVER.
|
||||||
|
; Default Value: yes
|
||||||
|
;clear_env = no
|
||||||
|
|
||||||
|
; Limits the extensions of the main script FPM will allow to parse. This can
|
||||||
|
; prevent configuration mistakes on the web server side. You should only limit
|
||||||
|
; FPM to .php extensions to prevent malicious users to use other extensions to
|
||||||
|
; execute php code.
|
||||||
|
; Note: set an empty value to allow all extensions.
|
||||||
|
; Default Value: .php
|
||||||
|
;security.limit_extensions = .php .php3 .php4 .php5 .php7
|
||||||
|
|
||||||
|
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
|
||||||
|
; the current environment.
|
||||||
|
; Default Value: clean env
|
||||||
|
;env[HOSTNAME] = $HOSTNAME
|
||||||
|
;env[PATH] = /usr/local/bin:/usr/bin:/bin
|
||||||
|
;env[TMP] = /tmp
|
||||||
|
;env[TMPDIR] = /tmp
|
||||||
|
;env[TEMP] = /tmp
|
||||||
|
|
||||||
|
; Additional php.ini defines, specific to this pool of workers. These settings
|
||||||
|
; overwrite the values previously defined in the php.ini. The directives are the
|
||||||
|
; same as the PHP SAPI:
|
||||||
|
; php_value/php_flag - you can set classic ini defines which can
|
||||||
|
; be overwritten from PHP call 'ini_set'.
|
||||||
|
; php_admin_value/php_admin_flag - these directives won't be overwritten by
|
||||||
|
; PHP call 'ini_set'
|
||||||
|
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
|
||||||
|
|
||||||
|
; Defining 'extension' will load the corresponding shared extension from
|
||||||
|
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
|
||||||
|
; overwrite previously defined php.ini values, but will append the new value
|
||||||
|
; instead.
|
||||||
|
|
||||||
|
; Note: path INI options can be relative and will be expanded with the prefix
|
||||||
|
; (pool, global or /usr)
|
||||||
|
|
||||||
|
; Default Value: nothing is defined by default except the values in php.ini and
|
||||||
|
; specified at startup with the -d argument
|
||||||
|
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
|
||||||
|
;php_flag[display_errors] = off
|
||||||
|
;php_admin_value[error_log] = /var/log/fpm-php.www.log
|
||||||
|
;php_admin_flag[log_errors] = on
|
||||||
|
;php_admin_value[memory_limit] = 32M
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
# sshd service name is `ssh` on Debian/Ubuntu, but it's
|
|
||||||
# `sshd` on CentOS
|
|
||||||
sshd_service_name: ssh
|
|
||||||
|
|
||||||
# provisioning user vars
|
|
||||||
provisioning_user: { name: 'provisioning', home: '/home/provisioning' }
|
|
||||||
|
|
||||||
# vim: set ts=2 sw=2:
|
|
||||||
2
web.yml
2
web.yml
@@ -9,7 +9,7 @@
|
|||||||
- { role: mariadb, when: mariadb_databases is defined}
|
- { role: mariadb, when: mariadb_databases is defined}
|
||||||
- { role: nginx, when: webserver is defined and webserver == 'nginx' }
|
- { role: nginx, when: webserver is defined and webserver == 'nginx' }
|
||||||
- { role: caddy, when: webserver is defined and webserver == 'caddy' }
|
- { role: caddy, when: webserver is defined and webserver == 'caddy' }
|
||||||
- php-fpm
|
- php_fpm
|
||||||
- munin
|
- munin
|
||||||
vars_files:
|
vars_files:
|
||||||
- vars/ipsets.yml
|
- vars/ipsets.yml
|
||||||
|
|||||||
Reference in New Issue
Block a user