Compare commits
83 Commits
41fbc73dd1
...
debian13
| Author | SHA1 | Date | |
|---|---|---|---|
|
d51f8fefaa
|
|||
|
9ff6e19135
|
|||
|
4680999680
|
|||
|
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
|
2
Pipfile
2
Pipfile
@@ -10,4 +10,4 @@ ansible = "*"
|
|||||||
ansible-lint = "*"
|
ansible-lint = "*"
|
||||||
|
|
||||||
[requires]
|
[requires]
|
||||||
python_version = "3.11"
|
python_version = "3.13"
|
||||||
|
|||||||
1099
Pipfile.lock
generated
1099
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
|
|
||||||
277
host_vars/web22
277
host_vars/web22
@@ -1,138 +1,141 @@
|
|||||||
$ANSIBLE_VAULT;1.1;AES256
|
$ANSIBLE_VAULT;1.1;AES256
|
||||||
65343136316335383839326463313466616564633339336561333461363664643437353934333766
|
38353762626535363837346634333565643931386536313339336365663162656533363636383931
|
||||||
6434613431626537643266623333633633393031353333340a316664323433653235343433366631
|
3737373161623364396366323338613062386466313539640a653334643937326338386262623261
|
||||||
38356463643933623637656165316333663432306336353332353539396565336537343961383563
|
65643635373532636439396235373964303537646334343633633531633435323037313433346636
|
||||||
3730393237376165390a323537303738383863393061626633623165653335333164613364343462
|
3866306363303338360a356166353265386130616163616662623764313536616666656237636563
|
||||||
30316530353036633531663961623463626464316131623437333134666561373065633034333736
|
30323036353635303438363234646234656530373365396530666539393132643831653039666562
|
||||||
37653735343131613735353136383232616539663831633739326631633538393834303664396564
|
65383962306465363862333131383263353736623264616465336139313638343462653361333239
|
||||||
34343739333166333731326434366131383337313035646363613035633038393963313732636432
|
64363562653366396664623662376433663335313231653935626237663430303734326433333739
|
||||||
31363032623533323338353436383039663430343836373633626334376363616130353737323761
|
62616265373732316530366331323664373637386661353664626464646264356465346466663539
|
||||||
64323739613036303834303236646238633335396534623761336661663936643166356665663634
|
31613435366362343564313732616639376664613630316236373333653634386130663463626231
|
||||||
61323235373262653163663832626133306263653530366463636563386263333665646264646161
|
31396631623466666364316237313363366439326231653035316437616134643035393138383364
|
||||||
32383766393632633061626233333464353132366132303232613465666633313064363361636131
|
35313738373562353632366637663232393638396330626165323535343538633264353366663738
|
||||||
62353462343231373366643765326364313834343966363837393130616138613538326635396562
|
30663135646162396331623837343661613333313437313434313365623664316135626239636230
|
||||||
32663335633935643633366437333235353531623135393331336237356536396630353438303030
|
65376137303439323166346536353831653537326662356330393362666430633831323537623830
|
||||||
39663762366463316131313162313264316134616634303963303163656562303235356131373365
|
65326164663136383339353138663936306166633662346363353063663435323266653137666630
|
||||||
62393435303731666263333161646437383131633663386564653732353166373562396466633766
|
61353263653735626236373233313436343466653238376634623366356431333439323932343938
|
||||||
62323731623637326230306534336465396165643564343064303565343030666238643036646339
|
33303432613063383135633261653837633961643737623462626439373335613430356532353031
|
||||||
65383830613761623935356438643032333565393665653262333931316139356535323033633465
|
31626666663963643736323731613735376239663530373166626365666339346435323761333637
|
||||||
62353063326630363666323832383865653761343732313361353935376236366632383934366336
|
35383464626437646665653931653932653033376464386132383038633734373138313830303466
|
||||||
37666461623166306230373735353233386432626632363037643166363465303938343037666266
|
39313532333866303565353161636435646231313461646639316566386639323561363633636139
|
||||||
62373831636338386139643231333639623561653664646438396439353139396435303334376538
|
37613661626162306431313266383964323434343039386533333535646565373933396565613565
|
||||||
36393833306138363765656431313161393762646665656632633065393131396631613464626334
|
34666136633265663035306261623531333665636336303665613635333232316331643935353461
|
||||||
30373266326264366335353838356530626532646532303263366139393566343866653166313832
|
32643735623532313363663530656630653531666335323565353063316537396334383230386462
|
||||||
64323331376565326263313464356265323561373562666666653465353139303063383736613662
|
33333565616634356537376466373332356663376363353166656139623336396130653564333739
|
||||||
32343963663161356265303132343534323333633639303461336331343536333430303738383661
|
39303733303939313838363331356437646632386631343466383332313037616430313566396335
|
||||||
65313832343062373931373765323338313239653861346263343866396563616463383461306262
|
31363038373437643266656463373662653966653832613935303462303031653761336165646162
|
||||||
32323862363064633166343531616135323839333637376638366162653133626266326231383064
|
31646631373335336435383638666562373236656231613662646161613533376237366463383630
|
||||||
36633963623136646136376663643138613432643039653637633535373763666235323732326539
|
36393532316336303531353032303937353963306164663162386137393664353962323865616532
|
||||||
65616265653931323330623764316466343332333666373363633634386135613764346531653661
|
63326462626130386234643639363762323863326134623063343731366433306431303763363233
|
||||||
38376637663734343863366339313431633134303432323336613263316335616364376566353631
|
36366334386266616261616266386439623665326339653562373836306165353137353137376337
|
||||||
62383437353939663834306265636565326233353262343532633363383336663531646239646139
|
37316363653935623736613138356333653936363866356665303737363032363564643532303234
|
||||||
63653632316365666662653561626135646464316263316134643530393233646636383066326533
|
37656432656363336564393263353430373437303337303461613763346461646565646535366638
|
||||||
64656337343231616537333533373962383466643761643337646565616462326235353236323162
|
34366337343033666134383966646563356533626665373337646231313431346239303635353261
|
||||||
63376631386261343066623330626532303461663934613361643437383937623038356432666131
|
62313939383762303235373537643531623465353062303939383666323139396630346461626136
|
||||||
36643262396433623633303961393239613839306465656335643831613963326262636561656330
|
38656632373637616532666433626564376338363239326234656561636239653536366331633234
|
||||||
37653836383737373738373639653235613230376464323062313336383764633438646238393430
|
65366139623238336234363564616430646435666562616636303064663437663731303839313365
|
||||||
32303131376363353333313262323338653461623835376562393736333263656536373435613132
|
38636438386162623862363865646233346336636439663833343136316165343564393339653565
|
||||||
32656139363431386163346262636562333037346632656436313464356431623562373139643531
|
38346166346434386338303032303430303535373635336562663030336566666435623537363137
|
||||||
62366466323332633530353333616630343734306263613231303538633061383739663761363230
|
61373161343138656365376531633830313561336632633330323035346431643837383062343537
|
||||||
37353565633963373235373366363535646661396331333638333533636537336666656465373864
|
66663961306666333535656432393134363565656635333633363732626665656365356138623164
|
||||||
37313935346561633030383737353062316337623233636130376333653364386632313738346637
|
65303936633666643034313636663262616661313739663135653335366261613133643630343362
|
||||||
39656234376535373361333866313163333166363632633138363337383163356263343063666534
|
66343033363835613031626635336538303362393561313032336136306465316231366137373736
|
||||||
66626661636330653233376239303334346563346433393135316231616130343232376430346162
|
62303335393333306132326135393562666431303631306538326433613362306131316139386361
|
||||||
32303031626666323930333366306531343161323437626361323632643439353935646336346132
|
31383665386466653066613038633335636233396335383764336462636138333034383836386365
|
||||||
63356264363566303262653565653837363035663564303135653966333466386262306437646638
|
38323739346630643532346161383336646165333336393961663930623531303434366265313861
|
||||||
30306537346564306633653735303835313434396439353730313030363431353733366337336533
|
39613231373335373338656434636134663036636234393534353033613133383034343437626434
|
||||||
65373030613565343265663566363066643135353961393638646539326635663763626332373534
|
31646339613430343265333833303231333739666266646436336161363330396264313636616461
|
||||||
66653230316332663165613937316531643065383730313739313730653931613930376263363539
|
61396332363537636162316261363030393466356263353938343236323932306366316535366533
|
||||||
38356330303333323438396561396530363537323865366238353964303331653330626539613933
|
38633165393339356339383939666161336461653438353632653530326639313238323761386461
|
||||||
32316661323039666661323963383738356435396135363032616536356532353630656536613161
|
63653765313532646166306237386435663432633934343039666637323362626338313135623034
|
||||||
61353737323135353062653365366330386532656363643533316163616437336131376365633633
|
30356438633635363738383932393861376235353962303663313963313964383530306530316363
|
||||||
66656137333463373330646334623531356361373335316538656239366239333165316637643439
|
64656638363436326562323234303961396333323931666365656433663865616439336138656232
|
||||||
62373562303839383036646661656635646139643962303237313330356165353936623834646230
|
66653964383034343837663936306632336562373637346132333063663263306237303461333732
|
||||||
34343265356464356330663038343033356138366134616331643031666633356432633337653930
|
65363661623064643663623661393563353739373535373764356163666639376236313839336438
|
||||||
36663733643064376232633265326137643965366438343336383735313638393338656139393033
|
35386265646331313663653761353864663934663261313037396135373938343265353934353361
|
||||||
31343835663837376430666638323165353763316564396630666336666163313533666431626566
|
30343564623631316366343838656135393364353836613330393536623662383637333039383133
|
||||||
61636165333831393962663731346665353736303630613932333165366563303933326633306236
|
37653733626662646631616563306638366263323634303636616331323964393962643061646361
|
||||||
37643166353065633530326238643236313631333630613663393062623537306235373332373230
|
39363562396634656637626630653533396236613334343332326439656165306537326464613436
|
||||||
64363266613366613932363836633530386630643564646365613465613863356132383639383930
|
37333632663731316165613432353339356561316431623038303365303663326666303666646363
|
||||||
38376538623665653437323539353562613163333234383331366236626339656463646162326434
|
66656630396661353765666131393737636630366666373136313837373165303437316233656261
|
||||||
30616236383237616139313064363664313561323166613334386339346538356165653231373065
|
38346463303964343132393162663762346163363739383733326635643264616166393264633934
|
||||||
63613435333734666335396337653437643034353266623635356261326135336130383633383033
|
64333137373532343032303431316633613836323631613231346133366635616435366436316239
|
||||||
66623735623162326365626130376564326365646636666464373737636664336136363162396636
|
64353633366431386664623239353735623037623364346431633733336563303430653233313637
|
||||||
33373366636132346336643065383431666263356265336532393335666365653864636165656334
|
35353138616164643834343339653739373038633531303039333632663566323565383637646561
|
||||||
63336437613733396430386337656433643038666662386166666437326537353739613735386261
|
31383965396365653364343761363161656432656665383963656463613637633938376234353532
|
||||||
30393362363461353132386630376463316665383138363939613634373637346136396234396461
|
33653837613266666661613165376665626432643439363637623333336234313836373232333736
|
||||||
64663064656565313730646666353132663965363731666537616266383934653165636436363062
|
65313232373233613763376463663161643636663162643864363962376232326462643936383131
|
||||||
64386638623936303061356335333266366335653235313166633063306636343531313038616335
|
39366164323038376633376238363663313238336166386663616261306532633331643537376631
|
||||||
62626363643537643030643761306230383034666232373538633065613136613932633064656535
|
31376663393036363566653061353636326565376636346466656263663266326332656461336437
|
||||||
33653466613565376137613732393361336232353435633634366235343138383038303462623532
|
32646162313932646632663738646532663439313630393038383530653562313439336631663535
|
||||||
62336439303561393030366135343164363165323436383262333935383035316534653439663437
|
36396265353231373435353137303164356633653938373166363663616632303764633738333439
|
||||||
63343166326364613835333239316139653836666634383535616433363539323464363732663039
|
62626533346561333565626163643235393164353861636662636531333834623965323034363735
|
||||||
62396532393863633739663061613762313865323465363562326231393638313235376161363131
|
33336138356663303462393864343434636364346432383665313931653062363138623261326438
|
||||||
64636266616462633334316236393262373461643266633131383831306539633735383839643665
|
31616533643163363261386635653732343939633965363362643536626264323537656238633539
|
||||||
63343738343535303365656630623066393365656362306363373730303839383034323166616662
|
62393935386433313366656133633532353131343237623466376632623434626362363062326531
|
||||||
36663438636665663235333364373538343763323335353530636635373935333535383663613966
|
33346165643164363365626432333631393664316266613731663162313764386336333231396632
|
||||||
62626361383536306464626134313432623038356336343538393439323231643266626263343761
|
36666536336333623063346166306164376138343566353063343866316432333266366337623866
|
||||||
62363665386139326634343264663737353063306234666437323139386563313839376364343637
|
61313039663661643863663434343732313139653037373065333463383635393061323938643162
|
||||||
62653765356132343430623464333161316436306238303134346638663763323932306663326433
|
61383064303461366162636439343438376266313931323934313563623435346634663739666565
|
||||||
62326336626366633565373732303032663138626430346239633834393761346232356134356534
|
62333035346634303139626432313262383262633437663436323763313361633235393037343665
|
||||||
31323261336266373533623538383234333235656133666232323862383031346266366438393065
|
62316564376464333133343134333230383765303834613233613232626131343631326433373062
|
||||||
61366238653737636135303134396132373565633561643137613737353234393739333762626564
|
36343466396430313534336332636233623337613134333861646334326633396434353765636163
|
||||||
62386535626331303562623535643461646434396335383436353939666135343933323266363938
|
37343638363234313030363661306337393361333332306331396164346633336130336366396430
|
||||||
39326432333839393934653936303964316261326132323030663235363430303735633965626562
|
62306539656332313162626239303066656664383639353730633738643132386662643733393761
|
||||||
65633266353338303030363862376261323232366262656165373161303734663335386639363865
|
62666339346130626163656237623730363066343838303036613038613763356263363365366238
|
||||||
64363238623964376439383032393831396130643263626131383162386565643263623439326431
|
62623435303838623630333231663137393362323234383533393763623235376164626461373736
|
||||||
66376561666134653738636538653462373537353863336265353733356461623261343766636338
|
36343761353362623433663936623433353439646463613233363732613435373564616239626564
|
||||||
33646666373337666463626333343963643865613566396235373935346436353034616237666331
|
61313066333939326435656535333963313831316231356232346534633531613963353130333432
|
||||||
36643936633732373631303235316230633334656530363761643862343466613636666462393939
|
37656163663230626632393939363532356366643764323330366630656334623261656334633865
|
||||||
39633961346537613634623061353437363464626237643730303334616464633535346632343463
|
61303066333566363061626437643132353664383061383364333338666230313034373535613063
|
||||||
36613164366533346465653435613165613436656661613537613430353730336265393330316432
|
63386237383638333263323337313336373830303865303466363965303839316162663431656538
|
||||||
65356232356538383933356536383563363732616465356532386336616633646363643165623234
|
33376332643335366537306133613761613132643232316438623939356331656263633933613935
|
||||||
33663137623433363463333435373435613337306561393536623965626662646463616664646464
|
65653465383434386561323462626362623566663330656439386361616562353430303938636436
|
||||||
35343363336365393937303265386464623562366232353434613632613934313133376466626639
|
66636531343063633561363330663436383930613438323764356562383536393933646264323135
|
||||||
33386634346466353238313936353534356534316436326664616536316164323563613961643061
|
64633764356166343965346362323466306636363633656466653934313230326435336536306230
|
||||||
33343162643037316438666161306664316635666335333036333861323134343638333465626335
|
38353432323537393131313239373861386237313530366139313338313330326632313536353837
|
||||||
34333262303161643534666261363032643065393832343864656237663439623230633766353633
|
63386161336335363834356437326630353031373435316462613634633039336132646134653236
|
||||||
36353862663239656333383561633830343932343361613365343461653735346164343434646137
|
31346664353932323339366464356161333637313761666138386164313163333531626235663338
|
||||||
37343638316464333932626463633433323261636436666134633365383962366138306563636461
|
62386333303264306363646136646463393134373939346438383465393439343337643336633039
|
||||||
37363339646665393534383735383338376661343264303036306230333030626133383231633332
|
62316464663038326439656334373331303165346534346466663538313632633561393335333931
|
||||||
30346133393863613133353165346439623534626361643534396339303865336239383834373432
|
65363964363335616639643462393463343437626539363838626439386164303464316666633663
|
||||||
39626463396632346164363734386337316164333338623832616538353631396535653961626665
|
63656639626133653266306266306531646331386366343936316136363935323662336335326338
|
||||||
64333134363539646266343134366432306166643561396436316364333939373431383662656237
|
30666130316265666631306635646565363039306138313462376662626161313134383633653834
|
||||||
34663665616266626261616163363831383534323161353361363634373764616233323364396638
|
32376163383763306165323466306264616366343332636564636162666434333732643635336163
|
||||||
38653335386466643233663133633339323965343661633033636165363936376631333537613035
|
61626162626331613438373464336465303739316130343965633532336531313661613961313164
|
||||||
64653533353533323865643066646263376539623463636664383866303733306462383265666534
|
39636165316638616338653965373833333732396363393463383433383930353361636166346232
|
||||||
65633665383664306432346264666532306138326630376436396434643033643336653562346330
|
61323935663536306533336137356566383130393564623938666231393431626136396137633066
|
||||||
39636138643733343262653761333430623333643664663763313734396634366462303763616139
|
36633133313861353338616561373838363833353531633465363731336237663561383561326635
|
||||||
35656237306637346133303839313137663137353236373465343539363664383861663831656137
|
62306338643965613635353536613335363934666362366466663461646135346436336164346536
|
||||||
63633635643038663464333863643731333263326137623662366362323934323366616166313739
|
62666631303638386137356233303235613636346661303834613335616161396238663530643165
|
||||||
37373461306636663761313235316436653862373238313630396635316261326665366631346566
|
65366364336139303766303938643038303461656335303438396565346330313665636165626432
|
||||||
38303738616236303639333833373762366138653836306461633738663234623361656233653630
|
64326666313562646239356231663834326566313331303363343064346539626636346438313266
|
||||||
62663939626332646163333261323032373134363631383162653863316330396339343534353766
|
65643364656164336166353435343730376266333633666230316464356439336463316464653137
|
||||||
62326334346565343034313766386338633831343739613931366433613239646239313533666163
|
66303865613961373732323439326535373933393537656462303831333432636261613564636330
|
||||||
61393366386434353734316334623635613466653736633932383634313233346438313565383738
|
63323361366332386331376437666234346661373233653432343733346363306130383665626437
|
||||||
35643461316536363534326338396131333734383561313036366131663932623066366365343864
|
33313330336365633464643563643465393935653132376135663163393161616462353838336664
|
||||||
36316265633432633361326635663262643962346433633537383761623663373435303362623464
|
35393833656135643733623765626639386561333336623930303465323963613164666531396632
|
||||||
30396461666535363339666536306566366661656135633137643161663539373365326463343535
|
35326365386566353966383635643132316230383363393539653335633934646239316131653536
|
||||||
63373764383966653735663530376230346437613230656232666165343734376563616434613563
|
66656161653030343462346337653434313062343663633665363838393865336536626532623132
|
||||||
61356334386238383861643363376638626366336134373838376633323639306537343037376630
|
66643636656134353363636433636538623930396262663864343332303066333566653063336464
|
||||||
61333635343132646664366235376332613365613238303531353964316438396564383262303564
|
32303030396137346636636164323133396364623532643332363638643761323938616530353836
|
||||||
39626365623464363432333364373635313064623334333839336533306131656166333464343131
|
65366331633561623331393231323534343239323565333330636136383836616230343034633036
|
||||||
37663335633139656330616662636439313361306232326634366436323436363936663566636662
|
38373530616532653166653932643665396434373465376530313663646236336238656266616261
|
||||||
38666363623738313462313566643864613435393530643731653638613566666531373337656134
|
33396463303963646633373038336662623161643135656136326533646337316562323932613833
|
||||||
66636530393433613061303366353564376533623334386463343332323232663462383036636361
|
65616434316239353531666131383335383733333830613934393465663138353662613063323537
|
||||||
39613231306333646662303236323963663363643262636432393932396564353361616237636261
|
31393337343737646537666430323666366338303731623339323063393636353132636233343436
|
||||||
36366264626632396133356530616633326435626436353839616134323037636534633464313536
|
61653862333837623666343061633531396235633565313631663937393337303764316466613130
|
||||||
62653564306163366430373066653030363938626139353633623162356666326531666333373936
|
33653732373034613639326338353438643664653461616133646235393864386564353765313932
|
||||||
65316338343535373835333334386630326463323739366533623830376661666335663434626535
|
36613165323465333937626165316632313334313364353463366239356630653530313761373261
|
||||||
35656132633164636435356335366663646239656461633138656166366630653364616235663336
|
35326331313438656238646535643131656634396238363734626431633734336238616538383636
|
||||||
32386533306561343161623739346563376633343734643161626237666337623462633165633733
|
32303331666531653331306263303534613332653535643833303062653566393632333030383263
|
||||||
34346533653938653234613433333536343465653339633263326363386137373931306132636265
|
63393636643264656439373165383861323534333462353763343931363065393738323433323839
|
||||||
31363036633664313131343939383434343763653664623466386465353666313464323036383937
|
33333530323434363662633939303261636465356663326565633238663333656131376130396561
|
||||||
63323333663063303332323134386338666461656165623464303034306666396239353637366665
|
63363636613161383465323233626630613265346162386439353665393832383961616564636538
|
||||||
39636366356465666135336437303161333261666638346130343235396534313163333564306263
|
65333635336638646436623033343831356339656638333231666439643337306636313931643466
|
||||||
33656336656664636533346434653433633436386566653163366236653539623634663165316131
|
32393765303361323735646130613035346564356562656631373435653832663165313131336236
|
||||||
30366161316639343230633966666137356266383935306435373332376638386532343130633762
|
31636634663466366234386262623234626161663461386661656435656133616339383633386230
|
||||||
3034
|
34313065396335636630333066633339646432313632373131306235333164336534363630313939
|
||||||
|
32623062393230633732323130613338363833356533306662616637326337343330303635343532
|
||||||
|
38396665633938313932656130303263396631343761616631616637633831666139343130313236
|
||||||
|
62356630346264376432
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,7 @@
|
|||||||
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
|
||||||
|
|||||||
@@ -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_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,27 +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:
|
ansible.builtin.systemd_service:
|
||||||
name: "{{ sshd_service_name }}"
|
name: "{{ sshd_service_name }}"
|
||||||
state: reloaded
|
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:
|
ansible.builtin.systemd_service:
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
|
|
||||||
- name: restart nftables
|
- name: Restart nftables
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd_service:
|
||||||
name: nftables
|
name: nftables
|
||||||
state: restarted
|
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:
|
ansible.builtin.systemd_service:
|
||||||
name: fail2ban
|
name: fail2ban
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
---
|
---
|
||||||
- name: Configure cron-apt (config)
|
- name: Remove cron-apt
|
||||||
ansible.builtin.copy: src={{ item.src }} dest={{ item.dest }} mode={{ item.mode }} owner={{ item.owner }} group={{ item.group }}
|
ansible.builtin.apt:
|
||||||
loop:
|
name: cron-apt
|
||||||
- { src: etc/cron-apt/config, dest: /etc/cron-apt/config, mode: "0644", owner: root, group: root }
|
state: absent
|
||||||
- { src: etc/cron-apt/3-download, dest: /etc/cron-apt/action.d/3-download, mode: "0644", owner: root, group: root }
|
cache_valid_time: 3600
|
||||||
|
|
||||||
- name: Configure cron-apt (security)
|
- name: Remove cron-apt configs
|
||||||
ansible.builtin.template: src=security.sources.list.j2 dest=/etc/apt/security.sources.list mode=0644 owner=root group=root
|
ansible.builtin.file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
loop:
|
||||||
|
- /etc/cron-apt/config
|
||||||
|
- /etc/cron-apt/action.d/3-download
|
||||||
|
- /etc/apt/security.sources.list
|
||||||
|
|
||||||
# vim: set ts=2 sw=2:
|
# vim: set ts=2 sw=2:
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
---
|
---
|
||||||
- name: Install fail2ban
|
- name: Install fail2ban
|
||||||
when:
|
when: ansible_distribution_version is version('11', '>=')
|
||||||
- ansible_distribution_major_version is version('11', '>=')
|
ansible.builtin.apt:
|
||||||
ansible.builtin.package:
|
|
||||||
name:
|
name:
|
||||||
- fail2ban
|
- fail2ban
|
||||||
- python3-systemd
|
- python3-systemd
|
||||||
@@ -15,7 +14,7 @@
|
|||||||
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:
|
||||||
@@ -27,7 +26,7 @@
|
|||||||
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:
|
||||||
@@ -44,11 +43,11 @@
|
|||||||
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_distribution_version is version('11', '>=')
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: nftables
|
||||||
|
state: present
|
||||||
|
cache_valid_time: 3600
|
||||||
|
|
||||||
|
- name: Remove iptables on newer Debian
|
||||||
|
when: ansible_distribution_version is version('11', '>=')
|
||||||
|
ansible.builtin.apt:
|
||||||
|
pkg: iptables
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Configure nftables
|
||||||
|
when: ansible_distribution_version is version('11', '>=')
|
||||||
|
ansible.builtin.include_tasks: nftables.yml
|
||||||
|
|
||||||
|
- name: Configure fail2ban
|
||||||
|
when: ansible_distribution_version is version('9', '>=')
|
||||||
|
ansible.builtin.include_tasks: fail2ban.yml
|
||||||
|
|
||||||
|
# vim: set sw=2 ts=2:
|
||||||
@@ -1,115 +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:
|
|
||||||
- libnet-ip-perl # for aggregate-cidr-addresses.pl
|
|
||||||
- nftables
|
|
||||||
- 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
|
|
||||||
when: ansible_distribution_version is version('20.04', '>=')
|
|
||||||
ansible.builtin.package:
|
|
||||||
name:
|
|
||||||
- libnet-ip-perl # for aggregate-cidr-addresses.pl
|
|
||||||
- nftables
|
|
||||||
- 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:
|
|
||||||
@@ -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
|
||||||
@@ -34,13 +22,23 @@
|
|||||||
# 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_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_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
|
||||||
|
|||||||
96
roles/common/tasks/nftables.yml
Normal file
96
roles/common/tasks/nftables.yml
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
---
|
||||||
|
# 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
|
||||||
|
- Restart fail2ban
|
||||||
|
|
||||||
|
- 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: "{{ item.src }}"
|
||||||
|
dest: /etc/nftables/{{ item.src }}
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
force: "{{ item.force }}"
|
||||||
|
loop:
|
||||||
|
- { src: firehol_level1-ipv4.nft, force: false }
|
||||||
|
notify:
|
||||||
|
- Restart nftables
|
||||||
|
- Restart fail2ban
|
||||||
|
|
||||||
|
- 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: Remove deprecated data and scripts
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
loop:
|
||||||
|
- /etc/nftables/spamhaus-ipv4.nft
|
||||||
|
- /etc/nftables/spamhaus-ipv6.nft
|
||||||
|
- /etc/nftables/abuseipdb-ipv4.nft
|
||||||
|
- /etc/nftables/abuseipdb-ipv6.nft
|
||||||
|
- /etc/nftables/abusech-ipv4.nft
|
||||||
|
- /usr/local/bin/update-abusech-nftables.sh
|
||||||
|
- /usr/local/bin/update-spamhaus-nftables.sh
|
||||||
|
- /etc/systemd/system/update-abusech-nftables.service
|
||||||
|
- /etc/systemd/system/update-abusech-nftables.timer
|
||||||
|
- /etc/systemd/system/update-spamhaus-nftables.service
|
||||||
|
- /etc/systemd/system/update-spamhaus-nftables.timer
|
||||||
|
- /usr/local/bin/aggregate-cidr-addresses.pl
|
||||||
|
notify:
|
||||||
|
- Restart nftables
|
||||||
|
- Restart fail2ban
|
||||||
|
|
||||||
|
- 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: "{{ item }}"
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
loop:
|
||||||
|
- update-firehol-nftables.timer
|
||||||
|
|
||||||
|
- 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_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 (ansible_distribution == 'Debian' and ansible_distribution_version
|
when: ansible_distribution_version is version('11', '>=')
|
||||||
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_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_service_mgr == 'systemd'
|
||||||
|
- ansible_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,19 +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:
|
||||||
@@ -21,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_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:
|
||||||
@@ -35,7 +28,6 @@
|
|||||||
- iotop
|
- iotop
|
||||||
- htop
|
- htop
|
||||||
- strace
|
- strace
|
||||||
- cron-apt
|
|
||||||
- safe-rm
|
- safe-rm
|
||||||
- debian-goodies
|
- debian-goodies
|
||||||
- mosh
|
- mosh
|
||||||
@@ -47,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,105 +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 @@
|
|||||||
---
|
---
|
||||||
# SSH configs don't change in Debian minor versions
|
# Only override the system sshd configuration on older Debian.
|
||||||
- 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
|
when: ansible_distribution_version is version('12', '<=')
|
||||||
mode=0600
|
ansible.builtin.template:
|
||||||
when: ansible_distribution == 'Debian'
|
src: "sshd_config_{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.j2"
|
||||||
notify: reload sshd
|
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_distribution_version is version('13', '>=')
|
||||||
when: ansible_distribution == 'Ubuntu'
|
ansible.builtin.template:
|
||||||
notify: reload sshd
|
src: etc/ssh/sshd_config.d/01-{{ ansible_distribution }}-{{ ansible_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:
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
register: tarsnap_signing_key_stat
|
register: tarsnap_signing_key_stat
|
||||||
|
|
||||||
- name: Download tarsnap apt signing key
|
- name: Download tarsnap apt signing key
|
||||||
|
when: not tarsnap_signing_key_stat.stat.exists
|
||||||
ansible.builtin.get_url:
|
ansible.builtin.get_url:
|
||||||
url: https://pkg.tarsnap.com/tarsnap-deb-packaging-key.asc
|
url: https://pkg.tarsnap.com/tarsnap-deb-packaging-key.asc
|
||||||
dest: /etc/apt/keyrings/tarsnap-deb-packaging-key.asc
|
dest: /etc/apt/keyrings/tarsnap-deb-packaging-key.asc
|
||||||
@@ -12,9 +13,9 @@
|
|||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
register: download_tarsnap_signing_key
|
register: download_tarsnap_signing_key
|
||||||
when: not tarsnap_signing_key_stat.stat.exists
|
|
||||||
|
|
||||||
- name: Add tarsnap.org repo
|
- name: Add tarsnap.org repo
|
||||||
|
when: ansible_architecture != 'armv7l'
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: tarsnap_sources.list.j2
|
src: tarsnap_sources.list.j2
|
||||||
dest: /etc/apt/sources.list.d/tarsnap.list
|
dest: /etc/apt/sources.list.d/tarsnap.list
|
||||||
@@ -22,12 +23,11 @@
|
|||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
register: add_tarsnap_apt_repository
|
register: add_tarsnap_apt_repository
|
||||||
when: ansible_architecture != 'armv7l'
|
|
||||||
|
|
||||||
- name: Update apt cache
|
- name: Update apt cache
|
||||||
|
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
|
ansible.builtin.apt: # noqa no-handler
|
||||||
update_cache: true
|
update_cache: true
|
||||||
when: (download_tarsnap_signing_key.status_code is defined and download_tarsnap_signing_key.status_code == 200) or add_tarsnap_apt_repository is changed
|
|
||||||
|
|
||||||
- name: Install tarsnap
|
- name: Install tarsnap
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
|
|||||||
@@ -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_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_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 %}
|
|
||||||
@@ -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
|
|
||||||
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,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:
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
- mariadb
|
- mariadb
|
||||||
|
|
||||||
- name: Download MariaDB package signing key
|
- name: Download MariaDB package signing key
|
||||||
|
when: not mariadb_signing_key_stat.stat.exists
|
||||||
ansible.builtin.get_url:
|
ansible.builtin.get_url:
|
||||||
url: https://mariadb.org/mariadb_release_signing_key.asc
|
url: https://mariadb.org/mariadb_release_signing_key.asc
|
||||||
dest: /etc/apt/keyrings/mariadb_release_signing_key.asc
|
dest: /etc/apt/keyrings/mariadb_release_signing_key.asc
|
||||||
@@ -23,7 +24,6 @@
|
|||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
register: download_mariadb_signing_key
|
register: download_mariadb_signing_key
|
||||||
when: not mariadb_signing_key_stat.stat.exists
|
|
||||||
tags:
|
tags:
|
||||||
- packages
|
- packages
|
||||||
- mariadb
|
- mariadb
|
||||||
@@ -40,9 +40,9 @@
|
|||||||
- mariadb
|
- mariadb
|
||||||
|
|
||||||
- name: Update apt cache
|
- name: Update apt cache
|
||||||
|
when: (download_mariadb_signing_key.status_code is defined and download_mariadb_signing_key.status_code == 200) or add_mariadb_apt_repository is changed
|
||||||
ansible.builtin.apt: # noqa no-handler
|
ansible.builtin.apt: # noqa no-handler
|
||||||
update_cache: true
|
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:
|
tags:
|
||||||
- packages
|
- packages
|
||||||
- mariadb
|
- mariadb
|
||||||
@@ -87,16 +87,17 @@
|
|||||||
|
|
||||||
# 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 }}"
|
||||||
@@ -105,7 +106,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:
|
||||||
|
|||||||
@@ -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,16 +5,16 @@
|
|||||||
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
|
||||||
@@ -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,7 +1,12 @@
|
|||||||
---
|
---
|
||||||
# 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
|
||||||
|
tags: letsencrypt
|
||||||
|
when:
|
||||||
|
- ansible_distribution == 'Debian'
|
||||||
|
- ansible_distribution_version is version('11', '>='))
|
||||||
|
block:
|
||||||
- name: Remove certbot
|
- name: Remove certbot
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name: certbot
|
name: certbot
|
||||||
@@ -21,31 +26,31 @@
|
|||||||
register: acme_home
|
register: acme_home
|
||||||
|
|
||||||
- name: Download acme.sh
|
- name: Download acme.sh
|
||||||
|
when: not acme_home.stat.exists
|
||||||
ansible.builtin.get_url:
|
ansible.builtin.get_url:
|
||||||
url: https://raw.githubusercontent.com/acmesh-official/acme.sh/master/acme.sh
|
url: https://raw.githubusercontent.com/acmesh-official/acme.sh/master/acme.sh
|
||||||
dest: "{{ letsencrypt_acme_script_temp }}"
|
dest: "{{ letsencrypt_acme_script_temp }}"
|
||||||
mode: "0700"
|
mode: "0700"
|
||||||
register: acme_download
|
register: acme_download
|
||||||
when: not acme_home.stat.exists
|
|
||||||
|
|
||||||
# Run the "install" for acme.sh so it creates the .acme.sh dir (currently I
|
# 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
|
# 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...).
|
# fails. Ansible runs it, but the script can't find itself...).
|
||||||
- name: Install acme.sh
|
- name: Install acme.sh
|
||||||
|
when: acme_download is changed
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
cmd: "{{ letsencrypt_acme_script_temp }} --install --no-profile --no-cron"
|
cmd: "{{ letsencrypt_acme_script_temp }} --install --no-profile --no-cron"
|
||||||
creates: "{{ letsencrypt_acme_home }}/acme.sh"
|
creates: "{{ letsencrypt_acme_home }}/acme.sh"
|
||||||
chdir: /root
|
chdir: /root
|
||||||
register: acme_install
|
register: acme_install
|
||||||
when: acme_download is changed
|
|
||||||
|
|
||||||
- name: Remove temporary acme.sh script
|
- name: Remove temporary acme.sh script
|
||||||
ansible.builtin.file:
|
|
||||||
dest: "{{ letsencrypt_acme_script_temp }}"
|
|
||||||
state: absent
|
|
||||||
when:
|
when:
|
||||||
- acme_install.rc is defined
|
- acme_install.rc is defined
|
||||||
- acme_install.rc == 0
|
- acme_install.rc == 0
|
||||||
|
ansible.builtin.file:
|
||||||
|
dest: "{{ letsencrypt_acme_script_temp }}"
|
||||||
|
state: absent
|
||||||
|
|
||||||
- name: Set default certificate authority for acme.sh
|
- name: Set default certificate authority for acme.sh
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
@@ -77,14 +82,10 @@
|
|||||||
|
|
||||||
# always issues daemon-reload just in case the service/timer changed
|
# always issues daemon-reload just in case the service/timer changed
|
||||||
- name: Start and enable systemd timer to renew Let's Encrypt certs
|
- name: Start and enable systemd timer to renew Let's Encrypt certs
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd_service:
|
||||||
name: renew-letsencrypt.timer
|
name: renew-letsencrypt.timer
|
||||||
state: started
|
state: started
|
||||||
enabled: true
|
enabled: true
|
||||||
daemon_reload: 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
|
|
||||||
|
|
||||||
# vim: set ts=2 sw=2:
|
# vim: set ts=2 sw=2:
|
||||||
|
|||||||
@@ -7,14 +7,6 @@
|
|||||||
- packages
|
- packages
|
||||||
- nginx
|
- 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
|
||||||
@@ -22,8 +14,8 @@
|
|||||||
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
|
||||||
@@ -41,9 +33,9 @@
|
|||||||
- 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:
|
||||||
@@ -62,7 +54,7 @@
|
|||||||
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
|
||||||
@@ -76,7 +68,7 @@
|
|||||||
- 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
|
||||||
@@ -95,13 +87,13 @@
|
|||||||
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
|
||||||
@@ -112,7 +104,7 @@
|
|||||||
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
|
||||||
@@ -123,11 +115,11 @@
|
|||||||
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,16 +1,23 @@
|
|||||||
---
|
---
|
||||||
- block:
|
- name: Configure https vhosts
|
||||||
|
tags: nginx
|
||||||
|
block:
|
||||||
- name: Configure https vhosts
|
- 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
|
ansible.builtin.template:
|
||||||
|
src: vhost.conf.j2
|
||||||
|
dest: "{{ nginx_confd_path }}/{{ item.domain_name }}.conf"
|
||||||
|
mode: "0644"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
loop: "{{ nginx_vhosts }}"
|
loop: "{{ nginx_vhosts }}"
|
||||||
notify:
|
notify:
|
||||||
- reload nginx
|
- Reload nginx
|
||||||
|
|
||||||
- name: Generate self-signed TLS cert
|
- 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
|
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
|
-out /etc/ssl/certs/nginx-snakeoil.crt -extensions v3_ca creates=/etc/ssl/certs/nginx-snakeoil.crt
|
||||||
notify:
|
notify:
|
||||||
- reload nginx
|
- Reload nginx
|
||||||
|
|
||||||
- name: Download 4096-bit RFC 7919 dhparams
|
- name: Download 4096-bit RFC 7919 dhparams
|
||||||
ansible.builtin.get_url:
|
ansible.builtin.get_url:
|
||||||
@@ -18,12 +25,16 @@
|
|||||||
checksum: sha256:64852d6890ff9e62eecd1ee89c72af9af244dfef5b853bcedea3dfd7aade22b3
|
checksum: sha256:64852d6890ff9e62eecd1ee89c72af9af244dfef5b853bcedea3dfd7aade22b3
|
||||||
dest: "{{ nginx_ssl_dhparam }}"
|
dest: "{{ nginx_ssl_dhparam }}"
|
||||||
notify:
|
notify:
|
||||||
- reload nginx
|
- Reload nginx
|
||||||
|
|
||||||
# TODO: this could break because we can override the document root in host vars
|
# TODO: this could break because we can override the document root in host vars
|
||||||
- name: Create vhost document roots
|
- name: Create vhost document roots
|
||||||
ansible.builtin.file: path={{ nginx_root_prefix }}/{{ item.domain_name }} state=directory mode=0755 owner=nginx group=nginx
|
ansible.builtin.file:
|
||||||
|
path: "{{ nginx_root_prefix }}/{{ item.domain_name }}"
|
||||||
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
owner: nginx
|
||||||
|
group: nginx
|
||||||
loop: "{{ nginx_vhosts }}"
|
loop: "{{ nginx_vhosts }}"
|
||||||
tags: nginx
|
|
||||||
|
|
||||||
# vim: set ts=2 sw=2:
|
# vim: set ts=2 sw=2:
|
||||||
|
|||||||
@@ -1,19 +1,29 @@
|
|||||||
---
|
---
|
||||||
- block:
|
- name: Install and configure WordPress
|
||||||
|
tags: wordpress
|
||||||
|
block:
|
||||||
- name: Install WordPress
|
- 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:
|
when:
|
||||||
- item.has_wordpress is defined
|
- item.has_wordpress is defined
|
||||||
- item.has_wordpress
|
- 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 }}"
|
loop: "{{ nginx_vhosts }}"
|
||||||
|
|
||||||
- name: Fix WordPress directory permissions
|
- name: Fix WordPress directory permissions
|
||||||
ansible.builtin.file: path={{ nginx_root_prefix }}/{{ item.domain_name }} state=directory owner=nginx group=nginx recurse=true
|
|
||||||
when:
|
when:
|
||||||
- item.has_wordpress is defined
|
- item.has_wordpress is defined
|
||||||
- item.has_wordpress
|
- item.has_wordpress
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ nginx_root_prefix }}/{{ item.domain_name }}"
|
||||||
|
state: directory
|
||||||
|
owner: nginx
|
||||||
|
group: nginx
|
||||||
|
recurse: true
|
||||||
loop: "{{ nginx_vhosts }}"
|
loop: "{{ nginx_vhosts }}"
|
||||||
tags: wordpress
|
|
||||||
|
|
||||||
# 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
|
||||||
|
|||||||
@@ -1,19 +1,7 @@
|
|||||||
{{ ansible_managed | comment }}
|
{{ ansible_managed | comment }}
|
||||||
|
|
||||||
{% if ansible_distribution == 'Ubuntu' %}
|
|
||||||
|
|
||||||
{% if nginx_version == "stable" %}
|
|
||||||
deb [arch=amd64 signed-by=/usr/share/keyrings/nginx_signing.key] https://nginx.org/packages/ubuntu/ {{ ansible_distribution_release }} nginx
|
|
||||||
{% 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
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% elif ansible_distribution == 'Debian' %}
|
|
||||||
|
|
||||||
{% if nginx_version == "stable" %}
|
{% if nginx_version == "stable" %}
|
||||||
deb [arch=amd64 signed-by=/usr/share/keyrings/nginx_signing.key] https://nginx.org/packages/debian/ {{ ansible_distribution_release }} nginx
|
deb [arch=amd64 signed-by=/usr/share/keyrings/nginx_signing.key] https://nginx.org/packages/debian/ {{ ansible_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/debian/ {{ ansible_distribution_release }} nginx
|
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,12 +77,8 @@ server {
|
|||||||
# See: https://httpoxy.org/
|
# See: https://httpoxy.org/
|
||||||
fastcgi_param HTTP_PROXY "";
|
fastcgi_param HTTP_PROXY "";
|
||||||
|
|
||||||
{% if ansible_distribution == 'Debian' and ansible_distribution_major_version is version('12', '==') %}
|
{% if ansible_distribution_major_version is version('12', '==') %}
|
||||||
fastcgi_pass unix:/run/php/php8.2-fpm-{{ domain_name }}.sock;
|
fastcgi_pass unix:/run/php/php8.2-fpm-{{ domain_name }}.sock;
|
||||||
{% elif (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('20.04', '==')) or (ansible_distribution == 'Debian' and ansible_distribution_major_version is version('11', '==')) %}
|
|
||||||
fastcgi_pass unix:/run/php/php7.4-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,12 +0,0 @@
|
|||||||
---
|
|
||||||
# For Ubuntu 20.04 and Debian 11
|
|
||||||
- name: reload php7.4-fpm
|
|
||||||
ansible.builtin.systemd: name=php7.4-fpm state=reloaded
|
|
||||||
|
|
||||||
# For Debian 12
|
|
||||||
- name: reload php8.2-fpm
|
|
||||||
ansible.builtin.systemd:
|
|
||||||
name: php8.2-fpm
|
|
||||||
state: reloaded
|
|
||||||
|
|
||||||
# vim: set ts=2 sw=2:
|
|
||||||
@@ -1,35 +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:
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,436 +0,0 @@
|
|||||||
{% 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 processes
|
|
||||||
; Note: The user is mandatory. If the group is not set, the default user's group
|
|
||||||
; will be used.
|
|
||||||
user = nginx
|
|
||||||
group = nginx
|
|
||||||
|
|
||||||
; 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/php7.4-fpm-{{ domain_name }}.sock
|
|
||||||
|
|
||||||
; Set listen(2) backlog.
|
|
||||||
; Default Value: 511 (-1 on 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.
|
|
||||||
; Default Values: user and group are set as the running user
|
|
||||||
; mode is set to 0660
|
|
||||||
listen.owner = nginx
|
|
||||||
listen.group = nginx
|
|
||||||
;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
|
|
||||||
|
|
||||||
; 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) even if the process user
|
|
||||||
; or group is differrent 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.
|
|
||||||
; 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 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 informations:
|
|
||||||
; 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 informations are related to the
|
|
||||||
; last request the process has served. Otherwise informations are 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/7.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 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)
|
|
||||||
; - %{miliseconds}d
|
|
||||||
; - %{mili}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 exemples:
|
|
||||||
; - 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 encapsuled 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 encapsuled in a %{<strftime_format>}t tag
|
|
||||||
; %u: remote user
|
|
||||||
;
|
|
||||||
; Default: "%R - %u %t \"%m %r\" %s"
|
|
||||||
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
|
|
||||||
|
|
||||||
; 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 environement, 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
|
|
||||||
8
roles/php_fpm/handlers/main.yml
Normal file
8
roles/php_fpm/handlers/main.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
# For Debian 12
|
||||||
|
- name: Reload php8.2-fpm
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: php8.2-fpm
|
||||||
|
state: reloaded
|
||||||
|
|
||||||
|
# vim: set ts=2 sw=2:
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
---
|
---
|
||||||
- block:
|
- name: Install and configure php-fpm
|
||||||
|
tags: php-fpm
|
||||||
|
when: install_php
|
||||||
|
block:
|
||||||
- name: Set php-fpm packages
|
- name: Set php-fpm packages
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
php_fpm_packages:
|
php_fpm_packages:
|
||||||
@@ -26,13 +29,13 @@
|
|||||||
mode: "0644"
|
mode: "0644"
|
||||||
loop: "{{ nginx_vhosts }}"
|
loop: "{{ nginx_vhosts }}"
|
||||||
when: (item.has_wordpress is defined and item.has_wordpress) or (item.needs_php is defined and item.needs_php)
|
when: (item.has_wordpress is defined and item.has_wordpress) or (item.needs_php is defined and item.needs_php)
|
||||||
notify: reload php8.2-fpm
|
notify: Reload php8.2-fpm
|
||||||
|
|
||||||
- name: Remove default www pool
|
- name: Remove default www pool
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: /etc/php/8.2/fpm/pool.d/www.conf
|
path: /etc/php/8.2/fpm/pool.d/www.conf
|
||||||
state: absent
|
state: absent
|
||||||
notify: reload php8.2-fpm
|
notify: Reload php8.2-fpm
|
||||||
|
|
||||||
# re-configure php.ini
|
# re-configure php.ini
|
||||||
- name: Update php.ini
|
- name: Update php.ini
|
||||||
@@ -42,9 +45,6 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
notify: reload php8.2-fpm
|
notify: Reload php8.2-fpm
|
||||||
|
|
||||||
tags: php-fpm
|
|
||||||
when: install_php
|
|
||||||
|
|
||||||
# vim: set ts=2 sw=2:
|
# vim: set ts=2 sw=2:
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
---
|
---
|
||||||
# Ubuntu 20.04 uses PHP 7.4
|
|
||||||
# Debian 11 uses PHP 7.4
|
|
||||||
# Debian 12 uses PHP 8.2
|
# Debian 12 uses PHP 8.2
|
||||||
|
|
||||||
# If any of the vhosts on this host need WordPress then we need to install PHP.
|
# If any of the vhosts on this host need WordPress then we need to install PHP.
|
||||||
@@ -26,22 +24,6 @@
|
|||||||
install_php: false
|
install_php: false
|
||||||
when: install_php is not defined
|
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
|
|
||||||
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
|
|
||||||
tags: php-fpm
|
|
||||||
|
|
||||||
- name: Configure php-fpm on Debian 12
|
- name: Configure php-fpm on Debian 12
|
||||||
ansible.builtin.include_tasks: Debian_12.yml
|
ansible.builtin.include_tasks: Debian_12.yml
|
||||||
when:
|
when:
|
||||||
@@ -27,8 +27,8 @@
|
|||||||
; --allow-to-run-as-root option to work.
|
; --allow-to-run-as-root option to work.
|
||||||
; Default Values: The user is set to master process running user by default.
|
; 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.
|
; If the group is not set, the user's group is used.
|
||||||
user = nginx
|
user = {{ webserver }}
|
||||||
group = nginx
|
group = {{ webserver }}
|
||||||
|
|
||||||
; The address on which to accept FastCGI requests.
|
; The address on which to accept FastCGI requests.
|
||||||
; Valid syntaxes are:
|
; Valid syntaxes are:
|
||||||
@@ -52,8 +52,8 @@ listen = /run/php/php8.2-fpm-{{ domain_name }}.sock
|
|||||||
; and group can be specified either by name or by their numeric IDs.
|
; 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
|
; 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.
|
; is not set, the owner's group is used. Mode is set to 0660.
|
||||||
listen.owner = nginx
|
listen.owner = {{ webserver }}
|
||||||
listen.group = nginx
|
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
|
||||||
@@ -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