Compare commits
63 Commits
d77718edae
...
master
Author | SHA1 | Date | |
---|---|---|---|
00558c7dea
|
|||
c927186837
|
|||
690774c862
|
|||
cc021bd14a
|
|||
73fd06fe3a
|
|||
88cb3a370e
|
|||
027a43ddbe
|
|||
bb30c3be20
|
|||
d8d9790d21
|
|||
9a500ebc0d
|
|||
4bae942585
|
|||
99866c0c90
|
|||
0afb8a4493
|
|||
506695da31
|
|||
f67ed7762c
|
|||
014f4d9502
|
|||
22c16e1ed3
|
|||
5aa6a33e51
|
|||
7f9b06af9c
|
|||
84db337fea
|
|||
7b23f5f94f
|
|||
9830338be3
|
|||
e3eed26765
|
|||
8b31c7e148
|
|||
3ff8043aaf
|
|||
cb79f7ef70
|
|||
bb14f05d2a
|
|||
5b1530fa91
|
|||
5312dc6bd5
|
|||
d6e060d3af
|
|||
b873af004a
|
|||
7ea3ab46f8
|
|||
0561bd5b52
|
|||
d62572f02c
|
|||
2ffe5e87d9
|
|||
38d4f1a303
|
|||
ed8cb88038
|
|||
c31e447861
|
|||
545684467c
|
|||
24ae5eaab1
|
|||
dac23f1427
|
|||
41fbc73dd1
|
|||
fee794bcf0
|
|||
8bce1d8b1b
|
|||
6dc2ea36b6
|
|||
af71a9b5f8
|
|||
4dd57803e2
|
|||
18d4245fc0
|
|||
1bddf3cccd
|
|||
20dbe61fe1
|
|||
899e87321b
|
|||
06416a3b64
|
|||
7a9a24ef5d
|
|||
067adcd9f5
|
|||
84d210cfab
|
|||
17736a4f14
|
|||
b9e91c4a3d
|
|||
51c95e5d4c
|
|||
8dbec29d2a
|
|||
d3bf3dab04
|
|||
8f50b7756b
|
|||
e86ccc9979
|
|||
cea8529f49
|
2
Pipfile
2
Pipfile
@ -10,4 +10,4 @@ ansible = "*"
|
||||
ansible-lint = "*"
|
||||
|
||||
[requires]
|
||||
python_version = "3.10"
|
||||
python_version = "3.13"
|
||||
|
1112
Pipfile.lock
generated
1112
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
|
||||
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)
|
||||
- You have a user account with password-less SSH access to the machine
|
||||
- You have sudo privileges on the remote host
|
||||
|
@ -8,4 +8,7 @@ webserver: nginx
|
||||
extra_fail2ban_filters:
|
||||
- nginx
|
||||
|
||||
# root prefix for all web servers
|
||||
web_root_prefix: /var/www
|
||||
|
||||
# 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
|
||||
66313265366237376433303333656461613537646264666463333662333137313437643762653330
|
||||
3934313661393263663639343731363230643234646364630a336566623738363562326134623530
|
||||
39393064666634356435626431313661313363343863663635393236313636633563373163326364
|
||||
6466393334633361380a633663633238636666653432343330626632323362626435613161333137
|
||||
35383036386234346438656566666337616337663735623735636533386136333039353863323864
|
||||
39336265383762383831323338643630666563656166613335653538376132646339323335666565
|
||||
32363866663432363839633964366664633138626138396561643764333565636433613562616638
|
||||
61626634306264346531313939396533653963353230343839366333393631663265666532373031
|
||||
64663536336537333664386232633038653030373132646463303532346366666634633536383730
|
||||
39393837356136356231333364373037346238643064666535633334643162396466306234393534
|
||||
37376636636463633636663664663865373265323739313136326535376337366133313234386335
|
||||
32323334656638396630666431336166336161313733316133633764656233636631613439616131
|
||||
33346638366230313966386639616562373331626634623637363139363165316639373962313838
|
||||
33326535383537343137326562373066373530653433396365653461633930353433316439646463
|
||||
61383364626137333234333966653930313435396662386230366131623436353930373533393632
|
||||
33326338336138613136646538663037653531383066636535303336353236316133336565333737
|
||||
39366166343531643138383237613464616230643633336433343166623336633935306433656665
|
||||
66653238636565326263343635643134353235643861373366353762386334613134643761643734
|
||||
62303236316561663538333938613034666662336330303131633939353862616334663963643263
|
||||
33353236303265623862643664333166656365623461386465323462316231396130623565346565
|
||||
30396438396363353938323033666566333364663634663739396531356262616431313537306666
|
||||
62643336353832616235313933613936666339316161633530656338356231333331623531653938
|
||||
32623138626661623435663963383561306233313065343737613636653866643662343338346530
|
||||
34333961393032616337393431633366633836386438613862333362383832366262343362633632
|
||||
31343430356339656330323661366164313766363763666335393138336635306130663861366130
|
||||
37613030373331343231663532363335633063346631666161326338623631396236316632623635
|
||||
39396135633762366534303037613461326634623635663535613833306133336162383335333235
|
||||
33336466633963316339393161396665626435626338373136623364353430323765636164363231
|
||||
33316263303437353963656431376130623336363265656239306631653339313230616462346461
|
||||
38653831373737303738323939383732663764383837333335363738323630653030386139653433
|
||||
31363166393166386234623732383961303538653136316333353663323732653861326161333962
|
||||
61633061376332323662643537323833376666643830613362636662323535383538663839643163
|
||||
32643132633232336337333130313832303135313738323237316239646236336135303765663134
|
||||
33633638333238616531643031656362653365303235313433663037353830313861626237616165
|
||||
31623435346663666664373464656436373962363064663735366137313334666135393332346161
|
||||
66343838353062353761333039326466623931623934383533636339363362306330623762343162
|
||||
30626138303038633938626430396132363939623866373266616437623066353137343634356366
|
||||
39646539323531343033633761303363623264383739356339336238356233616435373864666161
|
||||
35633238303135306332343066356466616135323165343932663832306533373730356266646434
|
||||
30643138633066653561306361323731666638383862616332653838313161656636323563346435
|
||||
39363735663566653731613132373266333032333630343361396138306338323830346137343563
|
||||
64386131353034363136623732643330626664333431383463356464613862623862626161396464
|
||||
61633033653163623262653034646465633264613433396334326162643536376238626136313263
|
||||
38636135666463613630303465633137623630663339613238316433656337373730306231333834
|
||||
64306362353337636438623234383833636237336438663435343035386562353436303961316561
|
||||
35376437336131353465633837366263383061366536376462323961366237336337656135396333
|
||||
33656134323161383335616466643134613237663433353363346162333334616636383038323036
|
||||
37343633653265373833333238663533626231626335316336396130663330353366366165333261
|
||||
35346534626639626532376266613035356462363534396166373264643137373731653336356635
|
||||
64396533666235336330666561396535376434303862326437623263393138623830616137343431
|
||||
66386335343763646534363864363535303536373562356462363963313731356361383832666232
|
||||
35653761343033646161386537316531373638643163366134343038353132393861343231333466
|
||||
31646439393632303837323835323138353166366332303934616535303237643861353134613035
|
||||
39633432636133663939323534373861326331653738353364613230363039306662383535343562
|
||||
63353662663864356132383934343661663631643330393863623835353730663233346662376133
|
||||
37653132336566636334383735353630653161313564316538353039633963393531333762613065
|
||||
39616266333166363031643164636465363432623731383339663766306261366135363330366236
|
||||
61636131343165343434646366356437343533356439653434663130666533656362323066373934
|
||||
34616437663865366134616566343939633036373934636339316362313939386162323936633038
|
||||
65363665616338303564663237306538663461646133396535653733393438663635373132346232
|
||||
37333437623733336637393432306231643430353636666538333461646331653432626433616531
|
||||
34323733393361373039356362383362343864376437613862353665393764653530303434656663
|
||||
64663361356235616231306433653635653262323532633733333133386638623035393564633565
|
||||
34626463663764363336323439373362643830353763353665393435653862643963633636613362
|
||||
66333661373934396666623939646131343337643639343032353462383830343065326431393934
|
||||
65613564323463653262653539303638643534623666303432623336366532303366313763396663
|
||||
38653463623264633833343833336434313732366361356638393033323766623031373138383365
|
||||
65613531666238636237333135646632393236306131326265366631663261613730383037303137
|
||||
32363039313635633535383834636436326430306535333464313765326563393530373139363663
|
||||
38623735316538343032323438623730616635346238666138663163383861336435616362343064
|
||||
36393837633561373336313935306236316530306361636561666666646161343662313139633031
|
||||
32636230336430616461333030393961656436633031623835643466613635353532303434373337
|
||||
61646564393230326135356337316233336231333933633930343863333939396538393232333431
|
||||
37313266643962373436303337306563633738643933653035666661386461316235333035373538
|
||||
64613032643830336130663664656563326132626130373431663939313038313530653466623562
|
||||
34396136376432346265386561333461663935643333366566653466306335313065303365323239
|
||||
33383535323735613438383438656334333139626239336162363230353539346466303066613539
|
||||
36636534313165303533313632346135636632396231636436343639653664323962343833646636
|
||||
32366132336238386235636662363430343136313064646532333534313836343033303936643834
|
||||
65373034353031366435396233346433343036643734366138383536356661303161626665366261
|
||||
39303639653761386563373030663633376134363136303438366139396437306536613838363737
|
||||
30373466363261333431393533323538326137623133313932643766383564643130653736313938
|
||||
35643665643730383236613136343736343230393234663462333632656638313239333234306331
|
||||
63616536633464656235623764653938386632393663626130383532316533643635386133646362
|
||||
39313631326231613966376532656138623565386365316536616639626139313264646333356364
|
||||
39386631653931386365613064373365633834366633383533343034356537623935373532343831
|
||||
36376135666165343332666232623632346434326537303732343439663835323463303934663361
|
||||
64653566663962356566303837396637383365653466636230306564353864326663336262393830
|
||||
37626638333137303962326134323435663862386336393162353363366439303531303230656365
|
||||
34343032386239353665313964626664376364303038366532363631653166353536356130353938
|
||||
32353266303638343230333730633364323136373732646162626365643234313336356565383732
|
||||
39336434326231373364656237303235656537626532353062666339363132313062393866343238
|
||||
36303739636331306365306635306335646234663134613632316532636436333537623261373664
|
||||
39353666353936353236346639653536333965623439633430313736303833376531353261353465
|
||||
33353166666363323233383836353936346536633862383961383432643661393636663565383139
|
||||
36366436326132383036333664336637343034376138613561346639303432303635383933356533
|
||||
36656231383464356631323964376536623063336133623737323238343839356164666434383361
|
||||
62376663383164323739316161646337363634346534326338663734613939376638303436333866
|
||||
39336466653464323961303932363333383566326237366334353064626162666136623730363039
|
||||
66353130333837333433636430336138343239643633356666333437306161393464343836616532
|
||||
63656132306136376262306439636231626639313438383038346563353637393664356162323266
|
||||
37323932323563633339396665323831393237656335363563386132346264333034323732643961
|
||||
65376130353961393262396361623733653562306135373764313531383261633961633833333836
|
||||
38323462643733393962633436653433666665386366373234323062653261393332306130363662
|
||||
37346638643430363064326638396261303131383033646465623630613833313837333134376332
|
||||
36343437656466313535356166343331396238333636663835343565613139343436316334356563
|
||||
62323565303066613864653432366231363164336663366661316561666463396163303037306331
|
||||
62643034613536383533636638643432636530353134303365643464396333376637636239373064
|
||||
31643736646632646433393966396434353039386132376139646630666432306439313635613233
|
||||
32383332313131613230616131666230386563356230653133363632653763333030626431333031
|
||||
31656135353934333236633639353034333539366165373837303936653561353063613538633233
|
||||
31656238656434353631636266323535343465613639666437376162303430323163646364346232
|
||||
39653635363364366266396461653834393731333963656537323064383630363638386139613862
|
||||
62613439373136656130303530386466396536656132616538613037333964613864313862653432
|
||||
61326531363166336530666137353030393639323363313662663930346137663862646331376166
|
||||
35613563313863386533653662333231636437353537643932613063633131316535326638373035
|
||||
62626466356364363766343762626131323330626237323733626665656234643562363735643364
|
||||
38643939356531383064316432663264373738646638383430336363373038323462313230323930
|
||||
34663533666238346634356230363437323763626531643366393630393432373765646165343633
|
||||
31623363613534383465393233383532363932643332633236643833633430366362303733323161
|
||||
62333932666361316334363563393438396466626265363061303331383932656533623836323233
|
||||
36323965633631383039373765313934356362393634356464643766623464636237303439646263
|
||||
32313137323237336166316361396633653061353264646439313963343361313631626232616536
|
||||
63313866653432366630616633346435393861356436646665383339393935663761316138616361
|
||||
37333732363766633434306438336339333138373763393065626365363633646533333161633336
|
||||
35623863653231323264636439633033663031393633643730356564653662323839326566393265
|
||||
30353238306664393261353233393063383564353264343539653037613262613564613730633762
|
||||
38383635393135373833386133366665613439316537383631336166343661313031306366653662
|
||||
32313562353930633564346337366333303564613766396161623332323465323235393530643361
|
||||
64333564616662656231313737353534393335646533666364346535633063323638313135643833
|
||||
61303534366334623431373433356434383736343738323863633164626337313532306430333131
|
||||
31666538323739363935333165303636353665326537666538316361626632343635333233303536
|
||||
32616561303862626266323862326266316164386564366439393234356132373537643764643636
|
||||
37353835653662346530303039306664383333636261616232343533633834666661373937383563
|
||||
36626537616539323164343135376639653039613163346534386665333532333337623361393934
|
||||
63316461373032363035383532616563323837353430396134336561386663653130373438646466
|
||||
6265
|
||||
61623539626162633765633037643066613863623631336534396535353439376238646263306463
|
||||
3762323765316137356636623430333662386564626536350a333334393630653733353864636162
|
||||
64623562623462373337363339343832336439363832653666316335313633343663396438346365
|
||||
6531343731363736340a373839663837396138366237303636326363663366656564306663663934
|
||||
34333862643232383566306335363462653035313039353764643261663165613861623333663136
|
||||
31333131303630356239636334346466643433356661383234383132653865326634643138613666
|
||||
35386430646239643535373264386535316135623633303863646564313538323532333739653636
|
||||
37393833363564323533333963376334326536666535626530383165613938353232356539633732
|
||||
30633761336638636265353764643063316538353065376431616165343936323834303733326433
|
||||
62626233643630643835323834343461333365333232373236376234376532636431396232633034
|
||||
34303538313331383332643731653634313736383261393563393232643466386339363836623466
|
||||
33383633353239623930363765326638643066373332653264633437323536366233383030346135
|
||||
61353636353239376564396336353538616135663237613137366263353730366263643961373461
|
||||
36646132646563646133373563653034646330653931396562643832666634383439313764646535
|
||||
35643161356263316638363662626662346232633230363731633263333566376262396236363161
|
||||
38636138306366666163663861346639323630663039353863346161613336363730633738386635
|
||||
31356638623938353964346436353565363431636238326266373863316464396563336461336162
|
||||
37323962343637626634386539643062343565313431386265323166623437346639363630343739
|
||||
63613738656465346261653538643932666235356635346564356234613265353761393263373965
|
||||
37326438346432306165616538363334653732643138643864633731363936626433303961373465
|
||||
38383535396665643037363665623739346230666539643835343862646464303436303561313035
|
||||
31356462656230326137616531363461316365333432326230373632356632313765333464313164
|
||||
65393537656364656464343237646137396331643165343639643330353264333066633432363066
|
||||
31336132373162393033363636386632313938333039393533313038623633613362646134363162
|
||||
36346532306166346335643636353439323732663763396432613537316234376366616262626638
|
||||
38613936626237343464373937383464356439383934353264643632386239353666396133656635
|
||||
37666534383461663433653139383732383062643939653066656231646532666262386239616433
|
||||
34386335363663313933663465623534633163316635353439616532386565613234373039653364
|
||||
62376565613863656232643631343634636366643034386466323963643837653831653635333865
|
||||
37383834626362613235623264613234653236323236383632356666643465313561626137343330
|
||||
61643963306363366638306335653364616264613766346539316337623466666537616535333363
|
||||
35306665383339643834616463396362663538303031386639343932346537363866663536373634
|
||||
32623738363234326361336436626330363962316163653733663663316139393134666632633438
|
||||
32303463343363383663636165643730653138356538326137613730383863373635646533373066
|
||||
38323361373665376435313266373439636533646634326533626135313462303739313430383730
|
||||
32333636633737376566623663323234376235623039313865663232323761616532666466306264
|
||||
39623434333638323065623830656535353331326435643464333035326338366136666136663337
|
||||
34336366333539333232653263396231633234313935396366646639383465326333653236383362
|
||||
36656563653465346439653230333534656530373766653733373765623234336466663631323765
|
||||
38636262373831393633343262356538393736666134633264353037383033343436346333306565
|
||||
38663637333062653565666163616330393637616434666634633839373966373666323831353338
|
||||
33666235646162343234343336356563663430643035306333623136323461636135386238396137
|
||||
63323830316634653666333735663533336262303931653666356531343464656132326134313831
|
||||
30666466373833313331316330353539646534333135373364343066643536636335633264306334
|
||||
63396133626234323734666162343835613436393763303836383839323338323339313261383033
|
||||
33616430376436663966626230343436643032353636363765303032333637396531623265393064
|
||||
62336330396533346462313638613262363435306330366561303336316239313731623562316366
|
||||
36373864373763383236663163363335373435636431613562373334396432323633373063346564
|
||||
38616637316162396638356234323436383765663036366363323964613264373638656161393661
|
||||
38623234356137383936303738306263376632393533613739613636613561333262333537616336
|
||||
35393739636533373865343533633961316137626337363336316333616162643538343362613634
|
||||
34376334393134643963383634646432643763316232656135663031373361346332636662653266
|
||||
38663931663239666462626664373064666366613834623033346133306335333462623931646535
|
||||
65343966313966386632333133363965623436313237343331366565323133343833623232326337
|
||||
38363234336137633035333362383164656238326434366330336662653435343639663438613062
|
||||
30346336353964346362393832653835303730383934316563333538376333353830376661313065
|
||||
31353837333563363561663931386264346263323665616231383538353937393330303163306433
|
||||
64376662393464643836636162373564376664306161656539626132313232343861396537386462
|
||||
32376636333564323137623862396135313863306337346131323834396633333261633438646561
|
||||
31613734343839373735356464643865663061363338346663353932313635393138613538303463
|
||||
33373333373230383336336462636333353137303563366234363737343437323336386335633739
|
||||
61363266633065383738336537346331376663313133393761633530633932643739636238633565
|
||||
33343236633834383933336466636663383566633932643464353665643733613137633538346437
|
||||
33366361663537343931653537333737633463336135623836373261663538303532633763646432
|
||||
39343361383335636433666431616363373161646265393231353265393436633238303066613963
|
||||
39633765663339643864386334613337666138333538333762353866333464386232396530306335
|
||||
64306461363730313061633831343839613065313061326132613563666563656131383236623032
|
||||
33346234333966653732643263313138333262343461623736386334356662383536633062653832
|
||||
37626132376336643563396561626636346237393138343133656565643631646530326166613061
|
||||
31353863623430656433356636616636303961336262613063616464313832343030333937356662
|
||||
61353136633539306265386335393035313864366464303131663337383636363431636537646461
|
||||
37646431643862646262623038336635653764383165376433666639363337623035616562663561
|
||||
36613165393931336639306662656136663231316530663266666135353461613538653734316661
|
||||
36363065663261323439653733336266613539363732323230346433353363333637616635666234
|
||||
36373439343762336161313965396537363332316561303235666264653038353132633561393038
|
||||
30373366303136656661353664396261393136623436323930666430636435623362396636646161
|
||||
63613734663964656139393531316465623130666663376266616137316137616233373630396663
|
||||
32326166663731643837623262393835656532393139396535393732626164316136626239663230
|
||||
35326166346162626134626566313963333661643531353437666139396333343335306633643531
|
||||
63386437646536633430643539623164306139316364646136306366373732373065376561303431
|
||||
65363237353163656162393264316263303366633630303532623130343066636132613865363662
|
||||
63323233323064633238356236616665373933626465393032326134363434613262653165343166
|
||||
38313263376637383163336565376538326532353766626264346536353563663464623737653430
|
||||
66373866343865326331333833353261386132393234303536353864343934353039323038363630
|
||||
37373632356461633137336230353762316562353430323761623861343639393030653038313632
|
||||
66636133643566306432333038623866333531613334396432306666316439366435383661336531
|
||||
36373333623266353461383431333462343037306563616231663563353833653839313538613631
|
||||
30646130383932343865363062313836323365616639346537663461343164363934653737613466
|
||||
38326234356261343764323063613366313633313766613736663033666664613433363438646366
|
||||
64366333373164333838363934636366336430343032316562653137323634303833616363393063
|
||||
35343330663434356530333535663664336463396533393564663138623162666563323736366135
|
||||
63653662306265326238363266393864393630333064303861376432333432386262306363336135
|
||||
32333762333339383662303931376631326638666635353433636461386264633166313336636663
|
||||
36313336663730363937316539623132313937633032396462616634346630383937353034343332
|
||||
32346164363362346264353965633761306163343131323661313836636438646337396238653962
|
||||
66306666366663343731333338666463313139373033306137643631313930353932616339636337
|
||||
39363337376232616139663863303430353530643964633333376561326339373334663862383230
|
||||
37613861373836643762386339666434623931376266643361383761373235393035303137613838
|
||||
39383230393831373836396435323734316332663465376136333365393433633065666565393033
|
||||
62356661346433643532633366313132313137623134626431343532373461396462653738613030
|
||||
39323566326239383434616663626330646136386463646331616431386235633435333838363732
|
||||
33633063363065343032383736643634313034663632373237663132373561656530396661326366
|
||||
31313738633662616663646163386461336537313236313930336466346161306535373965366137
|
||||
32383934626563663033356466653162333732633639363563663464353466383233373830633361
|
||||
37326531636262313337333665626233303263633461356331343261353838396661656138323130
|
||||
39316634666432656638623733333531303662613062323430333933626264376138393665363964
|
||||
62633765313262653165393332336539363263636362383262303766373331353363363564333037
|
||||
39373164633563303461313830383632623438666333333938613066313562623233353665653631
|
||||
62313634373537356365633065333763333533313730353235363963643131316364323031643235
|
||||
64313731343735346533646430346565393365363334626563353030313663363930363966313339
|
||||
34346130626633333239663935376663393962363761663935303639346333326230363730363366
|
||||
39313230353130373733396264616530303534383466633231303661663635623266346235363163
|
||||
61383761623039666462383266666565643930303664616432393434666566636437616536626365
|
||||
33336366333139633138386366333938343630373965613865663830366333363363303565633238
|
||||
32313762303739356433383534653966376231316366396333616435343539376432633837666635
|
||||
31396137373263386365616237396232376664653266663562356533613263323131356266666264
|
||||
36636266623338323861303237623361666130373938306539343438316662326536376438306465
|
||||
62656463356364363837353738663539316163346565333431343363303564376436666631383435
|
||||
65333066383335633462613034383139336262393865383534323032323730343865303339343239
|
||||
62343962363566643566356433623133333363343535376534333938623033656334613432326533
|
||||
63666339373135353331326363303064666137383439663738373236623137383562346439356432
|
||||
62383365373063376637313437346333643637376234376434613666353734333039353463313335
|
||||
32326564343139383035313261646635313939366531323530393434303735306138633435333037
|
||||
65666533366634666665393838616533656338353938333437363939616435636538313937303631
|
||||
32663439396165333633653531353835366436323062326535366432313936323031613639633164
|
||||
66323234613139626433326130396232366231623135366462393366616365653337346261663836
|
||||
61386435636361336334333235663865343262633333633162376433383062336663396162303133
|
||||
32666437336634323132396664373930316365626131646636366632616138626366613737616131
|
||||
64386439386265373631373232626538323936383162333535383134643438336336636435613033
|
||||
31336139376434316432343139363464616136626463396534646239646633363164646330373161
|
||||
31663233393234393837356133316462346563303435663262363532333963333535373031656434
|
||||
64303262633166346534396166643365326262636431353065613236666463336238633838633636
|
||||
35356265653935663963343737616563373663376239613436663138386566393438323735393362
|
||||
32616238623538366639373762336363353638306539336263316338323666303866633935386433
|
||||
62313865303732613266393066386533313263313432356434363734626365643338646438646633
|
||||
31346463313236643862303034363737343731343934666632623130613932323137376134653265
|
||||
35326164303031623235303265613765663263663333353066333633663636323635383832373865
|
||||
35626135333634346637346537373962646236376431393266306436333634646263646266326234
|
||||
37383037363364306230646334333532613464353931376338366532326134393437303535393033
|
||||
34316232326462343662
|
||||
|
@ -2,7 +2,7 @@
|
||||
# file: roles/caddy/defaults/main.yml
|
||||
|
||||
# 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.
|
||||
# Not sure what Caddy does if this doesn't exist.
|
||||
|
@ -18,7 +18,7 @@
|
||||
dest: /etc/apt/keyrings/caddy-stable-archive-keyring.key
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
mode: "0644"
|
||||
register: download_caddy_signing_key
|
||||
when: not caddy_signing_key_stat.stat.exists
|
||||
tags:
|
||||
@ -27,7 +27,7 @@
|
||||
|
||||
- name: Add Caddy stable repo
|
||||
ansible.builtin.apt_repository:
|
||||
repo: 'deb [signed-by=/etc/apt/keyrings/caddy-stable-archive-keyring.key] https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main'
|
||||
repo: deb [signed-by=/etc/apt/keyrings/caddy-stable-archive-keyring.key] https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main
|
||||
filename: caddy-stable
|
||||
state: present
|
||||
register: add_caddy_apt_repository
|
||||
@ -38,9 +38,7 @@
|
||||
- name: Update apt cache
|
||||
ansible.builtin.apt: # noqa no-handler
|
||||
update_cache: true
|
||||
when:
|
||||
(download_caddy_signing_key.status_code is defined and download_caddy_signing_key.status_code == 200) or
|
||||
add_caddy_apt_repository is changed
|
||||
when: (download_caddy_signing_key.status_code is defined and download_caddy_signing_key.status_code == 200) or add_caddy_apt_repository is changed
|
||||
tags:
|
||||
- packages
|
||||
- caddy
|
||||
@ -59,7 +57,7 @@
|
||||
ansible.builtin.template:
|
||||
src: etc/caddy/Caddyfile.j2
|
||||
dest: /etc/caddy/Caddyfile
|
||||
mode: 0755
|
||||
mode: "0755"
|
||||
owner: root
|
||||
group: root
|
||||
notify:
|
||||
@ -70,9 +68,10 @@
|
||||
ansible.builtin.file:
|
||||
path: /etc/caddy/conf.d
|
||||
state: directory
|
||||
mode: 0755
|
||||
mode: "0755"
|
||||
owner: root
|
||||
group: root
|
||||
tags: caddy
|
||||
|
||||
# TODO: the variable is still named nginx_vhosts
|
||||
- name: Configure Caddy virtual hosts
|
||||
|
@ -1,10 +1,9 @@
|
||||
---
|
||||
|
||||
- name: Configure vhosts
|
||||
ansible.builtin.template:
|
||||
src: etc/caddy/conf.d/vhost.j2
|
||||
dest: /etc/caddy/conf.d/{{ item.domain_name }}
|
||||
mode: 0644
|
||||
mode: "0644"
|
||||
owner: root
|
||||
group: root
|
||||
loop: "{{ nginx_vhosts }}"
|
||||
|
@ -8,6 +8,12 @@
|
||||
{% set needs_php = item.needs_php | default(false) %}
|
||||
{% set has_gitea = item.has_gitea | 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 %}
|
||||
{# domain_aliases is a string, so we split on space #}
|
||||
@ -21,15 +27,20 @@
|
||||
{{ domain_name }} {
|
||||
{% if has_gitea %}
|
||||
reverse_proxy :3000
|
||||
{% endif %}
|
||||
{% elif static_site -%}
|
||||
root * {{ document_root }}
|
||||
|
||||
{% if static_site -%}
|
||||
root * {{ item.document_root }}
|
||||
|
||||
encode zstd gzip
|
||||
encode
|
||||
|
||||
file_server
|
||||
{% endif %}
|
||||
{% elif has_wordpress -%}
|
||||
root * {{ document_root }}
|
||||
encode
|
||||
{% if ansible_distribution == 'Debian' and 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
|
||||
}
|
||||
|
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,5 +1,5 @@
|
||||
#!/usr/sbin/nft -f
|
||||
|
||||
define SPAMHAUS_IPV4 = {
|
||||
define FIREHOL_LEVEL1_IPV4 = {
|
||||
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]
|
||||
Description=Update Spamhaus lists
|
||||
Description=Update FireHOL lists
|
||||
|
||||
[Timer]
|
||||
# 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
|
@ -2,19 +2,26 @@
|
||||
# ansible.builtin.file: roles/common/handlers/main.yml
|
||||
|
||||
- name: reload sshd
|
||||
ansible.builtin.systemd: name={{ sshd_service_name }} state=reloaded
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ sshd_service_name }}"
|
||||
state: reloaded
|
||||
|
||||
- name: reload sysctl
|
||||
command: sysctl -p /etc/sysctl.conf
|
||||
|
||||
- name: reload systemd
|
||||
ansible.builtin.systemd: daemon_reload=true
|
||||
ansible.builtin.systemd:
|
||||
daemon_reload: true
|
||||
|
||||
- name: restart nftables
|
||||
ansible.builtin.systemd: name=nftables state=restarted
|
||||
ansible.builtin.systemd:
|
||||
name: nftables
|
||||
state: restarted
|
||||
|
||||
# 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
|
||||
# notify statement and we must restart fail2ban after updating the firewall.
|
||||
- name: restart fail2ban
|
||||
ansible.builtin.systemd: name=fail2ban state=restarted
|
||||
ansible.builtin.systemd:
|
||||
name: fail2ban
|
||||
state: restarted
|
||||
|
@ -1,12 +1,17 @@
|
||||
---
|
||||
- name: Remove cron-apt
|
||||
ansible.builtin.apt:
|
||||
name: cron-apt
|
||||
state: absent
|
||||
cache_valid_time: 3600
|
||||
|
||||
- name: Configure cron-apt (config)
|
||||
ansible.builtin.copy: src={{ item.src }} dest={{ item.dest }} mode={{ item.mode }} owner={{ item.owner }} group={{ item.group }}
|
||||
- name: Remove cron-apt configs
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
loop:
|
||||
- { src: 'etc/cron-apt/config', dest: '/etc/cron-apt/config', mode: '0644', owner: 'root', group: 'root' }
|
||||
- { src: 'etc/cron-apt/3-download', dest: '/etc/cron-apt/action.d/3-download', mode: '0644', owner: 'root', group: 'root' }
|
||||
|
||||
- name: Configure cron-apt (security)
|
||||
ansible.builtin.template: src=security.sources.list.j2 dest=/etc/apt/security.sources.list mode=0644 owner=root group=root
|
||||
- /etc/cron-apt/config
|
||||
- /etc/cron-apt/action.d/3-download
|
||||
- /etc/apt/security.sources.list
|
||||
|
||||
# vim: set ts=2 sw=2:
|
||||
|
@ -1,21 +1,32 @@
|
||||
---
|
||||
- name: Install fail2ban
|
||||
when:
|
||||
- ansible_distribution_major_version is version('11', '>=')
|
||||
ansible.builtin.package:
|
||||
name:
|
||||
- fail2ban
|
||||
- python3-systemd
|
||||
state: present
|
||||
cache_valid_time: 3600
|
||||
|
||||
- name: Configure fail2ban sshd filter
|
||||
ansible.builtin.template:
|
||||
src: etc/fail2ban/jail.d/sshd.local.j2
|
||||
dest: /etc/fail2ban/jail.d/sshd.local
|
||||
owner: root
|
||||
mode: 0644
|
||||
mode: "0644"
|
||||
notify: restart fail2ban
|
||||
|
||||
- name: Configure fail2ban nginx filter
|
||||
when:
|
||||
- webserver is defined and webserver == 'nginx'
|
||||
- extra_fail2ban_filters is defined
|
||||
- "'nginx' in extra_fail2ban_filters"
|
||||
ansible.builtin.template:
|
||||
src: etc/fail2ban/jail.d/nginx.local.j2
|
||||
dest: /etc/fail2ban/jail.d/nginx.local
|
||||
owner: root
|
||||
mode: 0644
|
||||
mode: "0644"
|
||||
notify: restart fail2ban
|
||||
|
||||
- name: Create fail2ban service override directory
|
||||
@ -23,7 +34,7 @@
|
||||
path: /etc/systemd/system/fail2ban.service.d
|
||||
state: directory
|
||||
owner: root
|
||||
mode: 0755
|
||||
mode: "0755"
|
||||
|
||||
# See Arch Linux's example: https://wiki.archlinux.org/index.php/Fail2ban
|
||||
- name: Configure fail2ban service override
|
||||
@ -31,7 +42,7 @@
|
||||
src: etc/systemd/system/fail2ban.service.d/override.conf.j2
|
||||
dest: /etc/systemd/system/fail2ban.service.d/override.conf
|
||||
owner: root
|
||||
mode: 0644
|
||||
mode: "0644"
|
||||
notify:
|
||||
- reload systemd
|
||||
- restart fail2ban
|
||||
|
20
roles/common/tasks/firewall.yml
Normal file
20
roles/common/tasks/firewall.yml
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
- name: Configure firewall (Debian)
|
||||
when: ansible_distribution == 'Debian'
|
||||
ansible.builtin.include_tasks:
|
||||
file: firewall_Debian.yml
|
||||
apply:
|
||||
tags:
|
||||
- firewall
|
||||
tags: firewall
|
||||
|
||||
- name: Configure firewall (Ubuntu)
|
||||
when: ansible_distribution == 'Ubuntu'
|
||||
ansible.builtin.include_tasks:
|
||||
file: firewall_Ubuntu.yml
|
||||
apply:
|
||||
tags:
|
||||
- firewall
|
||||
tags: firewall
|
||||
|
||||
|
@ -1,116 +1,28 @@
|
||||
---
|
||||
# Debian 11+ will use nftables directly, with no firewalld.
|
||||
|
||||
- block:
|
||||
- name: Install Debian firewall packages
|
||||
when: ansible_distribution_major_version is version('11', '>=')
|
||||
ansible.builtin.package:
|
||||
name:
|
||||
- fail2ban
|
||||
- libnet-ip-perl # for aggregate-cidr-addresses.pl
|
||||
- nftables
|
||||
- python3-systemd
|
||||
- curl # for nftables update scripts
|
||||
state: present
|
||||
cache_valid_time: 3600
|
||||
- name: 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: 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: Configure nftables
|
||||
ansible.builtin.include_tasks: nftables.yml
|
||||
when: ansible_distribution_version is version('11', '>=')
|
||||
|
||||
- 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
|
||||
- ansible.builtin.include_tasks: fail2ban.yml
|
||||
when:
|
||||
- ansible_distribution_major_version is version('9', '>=')
|
||||
|
||||
# vim: set sw=2 ts=2:
|
||||
|
@ -1,114 +1,27 @@
|
||||
---
|
||||
# Ubuntu 20.04 will use nftables directly, with no firewalld.
|
||||
|
||||
- block:
|
||||
- name: Install Ubuntu firewall packages
|
||||
ansible.builtin.package:
|
||||
name:
|
||||
- fail2ban
|
||||
- libnet-ip-perl # for aggregate-cidr-addresses.pl
|
||||
- nftables
|
||||
- python3-systemd
|
||||
- curl # for nftables update scripts
|
||||
state: present
|
||||
cache_valid_time: 3600
|
||||
- name: 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: 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: Configure nftables
|
||||
ansible.builtin.include_tasks: nftables.yml
|
||||
when: ansible_distribution_version is version('20.04', '>=')
|
||||
|
||||
- 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
|
||||
- ansible.builtin.include_tasks: fail2ban.yml
|
||||
when:
|
||||
- ansible_distribution_version is version('16.04', '>=')
|
||||
|
||||
# vim: set sw=2 ts=2:
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
- name: Import OS-specific variables
|
||||
ansible.builtin.include_vars: "vars/{{ ansible_distribution }}.yml"
|
||||
ansible.builtin.include_vars: vars/{{ ansible_distribution }}.yml
|
||||
tags: always
|
||||
|
||||
- name: Configure network time
|
||||
@ -18,13 +18,7 @@
|
||||
tags: packages
|
||||
|
||||
- name: Configure firewall
|
||||
ansible.builtin.include_tasks: firewall_Debian.yml
|
||||
when: ansible_distribution == 'Debian'
|
||||
tags: firewall
|
||||
|
||||
- name: Configure firewall
|
||||
ansible.builtin.include_tasks: firewall_Ubuntu.yml
|
||||
when: ansible_distribution == 'Ubuntu'
|
||||
ansible.builtin.import_tasks: firewall.yml
|
||||
tags: firewall
|
||||
|
||||
- name: Configure secure shell daemon
|
||||
|
97
roles/common/tasks/nftables.yml
Normal file
97
roles/common/tasks/nftables.yml
Normal file
@ -0,0 +1,97 @@
|
||||
---
|
||||
# Common nftables tasks for Ubuntu 20.04, Ubuntu 22.04, Ubuntu 24.04, 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
|
||||
ansible.builtin.systemd: # noqa no-handler
|
||||
daemon_reload: true
|
||||
when: nftables_systemd_units is changed
|
||||
|
||||
- name: Start and enable nftables update timers
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ item }}"
|
||||
state: started
|
||||
enabled: true
|
||||
loop:
|
||||
- update-firehol-nftables.timer
|
||||
|
||||
- name: Start and enable nftables
|
||||
ansible.builtin.systemd:
|
||||
name: nftables
|
||||
state: started
|
||||
enabled: true
|
||||
|
||||
# vim: set sw=2 ts=2:
|
@ -4,16 +4,19 @@
|
||||
# client.
|
||||
|
||||
- name: Set timezone
|
||||
when: timezone is defined and ansible_service_mgr == 'systemd'
|
||||
command: /usr/bin/timedatectl set-timezone {{ timezone }}
|
||||
when:
|
||||
- timezone is defined
|
||||
- ansible_service_mgr == 'systemd'
|
||||
community.general.timezone:
|
||||
name: "{{ timezone }}"
|
||||
tags: timezone
|
||||
|
||||
# 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
|
||||
# Ubuntu 20.04 and Debian 11.
|
||||
- name: Install systemd-timesyncd
|
||||
when: (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('20.04', '==')) or
|
||||
(ansible_distribution == 'Debian' and ansible_distribution_version is version('11', '>='))
|
||||
when: (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('20.04', '==')) or (ansible_distribution == 'Debian' and ansible_distribution_version
|
||||
is version('11', '>='))
|
||||
ansible.builtin.apt: name=systemd-timesyncd state=present cache_valid_time=3600
|
||||
|
||||
- name: Start and enable systemd's NTP client
|
||||
|
@ -1,20 +1,6 @@
|
||||
---
|
||||
|
||||
- name: Configure Debian 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('12', '<')
|
||||
|
||||
# Scaleway seems to use a weird sources.list format as of Debian 12?
|
||||
- name: Check for weird Debian sources
|
||||
ansible.builtin.stat:
|
||||
@ -36,7 +22,6 @@
|
||||
- iotop
|
||||
- htop
|
||||
- strace
|
||||
- cron-apt
|
||||
- safe-rm
|
||||
- debian-goodies
|
||||
- mosh
|
||||
@ -48,11 +33,12 @@
|
||||
- zstd
|
||||
- rsync
|
||||
- lsof
|
||||
- unattended-upgrades
|
||||
|
||||
- name: Install base packages
|
||||
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
|
||||
|
||||
|
@ -1,20 +1,6 @@
|
||||
---
|
||||
|
||||
- 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'
|
||||
@ -25,59 +11,27 @@
|
||||
- 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
|
||||
- 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:
|
||||
|
@ -3,7 +3,7 @@
|
||||
ansible.builtin.file: dest={{ provisioning_user.home }}/.ssh/authorized_keys state=absent
|
||||
|
||||
- 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:
|
||||
# use descriptive names for keys, like: aorth-mzito-rsa.pub
|
||||
- ssh-pub-keys/*.pub
|
||||
|
@ -1,8 +1,8 @@
|
||||
---
|
||||
|
||||
# SSH configs don't change in Debian minor versions
|
||||
- name: Reconfigure /etc/ssh/sshd_config
|
||||
ansible.builtin.template: src=sshd_config_{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.j2 dest=/etc/ssh/sshd_config owner=root group=root mode=0600
|
||||
ansible.builtin.template: src=sshd_config_{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.j2 dest=/etc/ssh/sshd_config owner=root group=root
|
||||
mode=0600
|
||||
when: ansible_distribution == 'Debian'
|
||||
notify: reload sshd
|
||||
|
||||
|
@ -1,24 +1,45 @@
|
||||
---
|
||||
- name: Add Tarsnap apt mirror
|
||||
ansible.builtin.template: src=tarsnap_sources.list.j2 dest=/etc/apt/sources.list.d/tarsnap.list owner=root group=root mode=0644
|
||||
- name: Check tarsnap apt signing key
|
||||
ansible.builtin.stat:
|
||||
path: /etc/apt/keyrings/tarsnap-deb-packaging-key.asc
|
||||
register: tarsnap_signing_key_stat
|
||||
|
||||
- name: Download tarsnap apt signing key
|
||||
ansible.builtin.get_url:
|
||||
url: https://pkg.tarsnap.com/tarsnap-deb-packaging-key.asc
|
||||
dest: /etc/apt/keyrings/tarsnap-deb-packaging-key.asc
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
register: download_tarsnap_signing_key
|
||||
when: not tarsnap_signing_key_stat.stat.exists
|
||||
|
||||
- name: Add tarsnap.org repo
|
||||
ansible.builtin.template:
|
||||
src: tarsnap_sources.list.j2
|
||||
dest: /etc/apt/sources.list.d/tarsnap.list
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
register: add_tarsnap_apt_repository
|
||||
when: ansible_architecture != 'armv7l'
|
||||
|
||||
- name: Add GPG key for Tarsnap
|
||||
ansible.builtin.apt_key: id=0xF608BA1BFB5CE8F8CAB088359F084BEE7F938A76 url=https://pkg.tarsnap.com/tarsnap-deb-packaging-key.asc state=present
|
||||
register: add_tarsnap_apt_key
|
||||
|
||||
- name: Update apt cache
|
||||
ansible.builtin.apt:
|
||||
ansible.builtin.apt: # noqa no-handler
|
||||
update_cache: true
|
||||
when:
|
||||
add_tarsnap_apt_key is changed or
|
||||
add_tarsnap_apt_repository is changed
|
||||
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
|
||||
ansible.builtin.apt: pkg=tarsnap cache_valid_time=3600
|
||||
ansible.builtin.apt:
|
||||
pkg: tarsnap
|
||||
cache_valid_time: 3600
|
||||
|
||||
- name: Copy tarsnaprc
|
||||
ansible.builtin.copy: src=tarsnaprc dest=/root/.tarsnaprc owner=root group=root mode=0600
|
||||
ansible.builtin.copy:
|
||||
src: tarsnaprc
|
||||
dest: /root/.tarsnaprc
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0600"
|
||||
|
||||
# vim: set sw=2 ts=2:
|
||||
|
@ -1,3 +1,7 @@
|
||||
[Unit]
|
||||
# If nftables is stopped or restarted, propagate to fail2ban as well
|
||||
PartOf=nftables.service
|
||||
|
||||
[Service]
|
||||
PrivateDevices=yes
|
||||
PrivateTmp=yes
|
||||
|
@ -5,47 +5,18 @@
|
||||
|
||||
flush ruleset
|
||||
|
||||
# Lists updated daily by update-spamhaus-nftables.sh
|
||||
include "/etc/nftables/spamhaus-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"
|
||||
# List updated daily by update-firehol-nftables.sh
|
||||
include "/etc/nftables/firehol_level1-ipv4.nft"
|
||||
|
||||
# Notes:
|
||||
# - tables hold chains, chains hold rules
|
||||
# - inet is for both ipv4 and ipv6
|
||||
table inet filter {
|
||||
set spamhaus-ipv4 {
|
||||
set firehol_level1-ipv4 {
|
||||
type ipv4_addr
|
||||
# if the set contains prefixes we need to use the interval flag
|
||||
flags interval
|
||||
elements = $SPAMHAUS_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
|
||||
elements = $FIREHOL_LEVEL1_IPV4
|
||||
}
|
||||
|
||||
chain input {
|
||||
@ -55,13 +26,7 @@ table inet filter {
|
||||
|
||||
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"
|
||||
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"
|
||||
ip saddr @firehol_level1-ipv4 counter drop comment "Early drop of incoming packets matching firehol_level1-ipv4 list"
|
||||
|
||||
iifname lo accept comment "Allow from loopback"
|
||||
|
||||
@ -105,12 +70,6 @@ table inet filter {
|
||||
chain output {
|
||||
type filter hook output priority 0;
|
||||
|
||||
ip daddr @spamhaus-ipv4 counter drop comment "Drop outgoing packets matching spamhaus-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"
|
||||
ip daddr @firehol_level1-ipv4 counter drop comment "Drop outgoing packets matching firehol_level1-ipv4 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 +1 @@
|
||||
deb [arch=amd64] https://pkg.tarsnap.com/deb/{{ ansible_distribution_release }} ./
|
||||
deb [arch=amd64 signed-by=/etc/apt/keyrings/tarsnap-deb-packaging-key.asc] https://pkg.tarsnap.com/deb/{{ ansible_distribution_release }} ./
|
||||
|
65
roles/common/templates/update-firehol-nftables.sh.j2
Executable file
65
roles/common/templates/update-firehol-nftables.sh.j2
Executable file
@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# update-firehol-nftables.sh v0.0.1
|
||||
#
|
||||
# Download FireHOL lists and load them into nftables sets.
|
||||
#
|
||||
# See: https://iplists.firehol.org/
|
||||
#
|
||||
# Copyright (C) 2025 Alan Orth
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
# Exit on first error
|
||||
set -o errexit
|
||||
|
||||
firehol_level1_ipv4_set_path=/etc/nftables/firehol_level1-ipv4.nft
|
||||
|
||||
function download() {
|
||||
echo "Downloading $1"
|
||||
wget -q -O - "https://iplists.firehol.org/files/$1" > "$1"
|
||||
}
|
||||
|
||||
download firehol_level1.netset
|
||||
|
||||
if [[ -f "firehol_level1.netset" ]]; then
|
||||
echo "Processing FireHOL Level 1 list"
|
||||
|
||||
firehol_level1_ipv4_list_temp=$(mktemp)
|
||||
firehol_level1_ipv4_set_temp=$(mktemp)
|
||||
|
||||
# Filter blank lines, comments, and bogons we use inside the LAN, DMZ, and
|
||||
# for local services like systemd-resolved and others on localhost. Ideally
|
||||
# these are blocked already at the WAN side by network administrators.
|
||||
cat firehol_level1.netset \
|
||||
| sed \
|
||||
-e '/^$/d' \
|
||||
-e '/^#.*/d' \
|
||||
-e '/^127\.0\.0\.0\/8/d' \
|
||||
> "$firehol_level1_ipv4_list_temp"
|
||||
|
||||
echo "Building firehol_level1-ipv4 set"
|
||||
cat << NFT_HEAD > "$firehol_level1_ipv4_set_temp"
|
||||
#!/usr/sbin/nft -f
|
||||
|
||||
define FIREHOL_LEVEL1_IPV4 = {
|
||||
NFT_HEAD
|
||||
|
||||
while read -r network; do
|
||||
# nftables doesn't mind if the last element in the set has a trailing
|
||||
# comma so we don't need to do anything special here.
|
||||
echo "$network," >> "$firehol_level1_ipv4_set_temp"
|
||||
done < $firehol_level1_ipv4_list_temp
|
||||
|
||||
echo "}" >> "$firehol_level1_ipv4_set_temp"
|
||||
|
||||
install -m 0600 "$firehol_level1_ipv4_set_temp" "$firehol_level1_ipv4_set_path"
|
||||
|
||||
rm -f "$firehol_level1_ipv4_list_temp" "$firehol_level1_ipv4_set_temp"
|
||||
fi
|
||||
|
||||
echo "Restarting nftables"
|
||||
|
||||
/usr/bin/systemctl restart nftables.service
|
||||
|
||||
rm -v firehol_level1.netset
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
- name: Remove MariaDB key from apt-key
|
||||
ansible.builtin.apt_key:
|
||||
id: 0x177F4010FE56CA3336300305F1656F24C74CD1D8
|
||||
id: "013577200103762554506315430003013705453362230723150730"
|
||||
state: absent
|
||||
tags:
|
||||
- packages
|
||||
@ -21,16 +21,17 @@
|
||||
dest: /etc/apt/keyrings/mariadb_release_signing_key.asc
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
mode: "0644"
|
||||
register: download_mariadb_signing_key
|
||||
when: not mariadb_signing_key_stat.stat.exists
|
||||
tags:
|
||||
- packages
|
||||
- mariadb
|
||||
|
||||
- name: Add MariaDB 10.6 repo
|
||||
- name: Add MariaDB 10.11 repo
|
||||
ansible.builtin.apt_repository:
|
||||
repo: 'deb [arch=amd64 signed-by=/etc/apt/keyrings/mariadb_release_signing_key.asc] https://dlm.mariadb.com/repo/mariadb-server/10.6/repo/debian {{ ansible_distribution_release }} main'
|
||||
repo: deb [arch=amd64 signed-by=/etc/apt/keyrings/mariadb_release_signing_key.asc] https://dlm.mariadb.com/repo/mariadb-server/10.11/repo/debian {{ ansible_distribution_release
|
||||
}} main
|
||||
filename: mariadb
|
||||
state: present
|
||||
register: add_mariadb_apt_repository
|
||||
@ -41,16 +42,14 @@
|
||||
- name: Update apt cache
|
||||
ansible.builtin.apt: # noqa no-handler
|
||||
update_cache: true
|
||||
when:
|
||||
(download_mariadb_signing_key.status_code is defined and download_mariadb_signing_key.status_code == 200) or
|
||||
add_mariadb_apt_repository is changed
|
||||
when: (download_mariadb_signing_key.status_code is defined and download_mariadb_signing_key.status_code == 200) or add_mariadb_apt_repository is changed
|
||||
tags:
|
||||
- packages
|
||||
- mariadb
|
||||
|
||||
- name: Install mariadb-server
|
||||
ansible.builtin.apt:
|
||||
name: ['mariadb-server', 'python3-pymysql']
|
||||
name: [mariadb-server, python3-pymysql]
|
||||
state: present
|
||||
cache_valid_time: 3600
|
||||
tags: mariadb, packages
|
||||
@ -61,7 +60,7 @@
|
||||
dest: /etc/mysql/my.cnf
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
mode: "0644"
|
||||
notify:
|
||||
- restart mariadb
|
||||
tags: mariadb
|
||||
@ -83,7 +82,7 @@
|
||||
src: .my.cnf.j2
|
||||
dest: /root/.my.cnf
|
||||
owner: root
|
||||
mode: 0600
|
||||
mode: "0600"
|
||||
tags: mariadb
|
||||
|
||||
# See: https://docs.ansible.com/ansible/latest/collections/community/mysql/mysql_db_module.html
|
||||
|
@ -5,20 +5,20 @@
|
||||
nginx_confd_path: /etc/nginx/conf.d
|
||||
|
||||
# parent directory of vhost roots
|
||||
nginx_root_prefix: /var/www
|
||||
nginx_root_prefix: "{{ web_root_prefix }}"
|
||||
|
||||
# 1 hour timeout
|
||||
nginx_ssl_session_timeout: 1h
|
||||
# 1 day timeout
|
||||
nginx_ssl_session_timeout: 1d
|
||||
# 10MB -> 40,000 sessions
|
||||
nginx_ssl_session_cache: shared:SSL:10m
|
||||
# 1400 bytes to fit in one MTU (default is 16k!)
|
||||
nginx_ssl_buffer_size: 1400
|
||||
nginx_ssl_buffer_size: 4k
|
||||
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)
|
||||
# See: https://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_stapling
|
||||
nginx_ssl_stapling_resolver: '1.1.1.1 1.0.0.1 [2606:4700:4700::1111] [2606:4700:4700::1001]'
|
||||
nginx_ssl_stapling_resolver: 1.1.1.1 1.0.0.1 [2606:4700:4700::1111] [2606:4700:4700::1001]
|
||||
|
||||
# HTTP Strict-Transport-Security header, recommended by Google to be ~1 year
|
||||
# in seconds, see: https://hstspreload.org/
|
||||
@ -37,8 +37,8 @@ letsencrypt_root: /etc/ssl
|
||||
letsencrypt_acme_script_temp: /root/acme.sh
|
||||
letsencrypt_acme_home: /root/.acme.sh
|
||||
|
||||
# stable is 1.20.x
|
||||
# mainline is 1.21.x
|
||||
# stable is 1.26.x
|
||||
# mainline is 1.27.x
|
||||
nginx_version: mainline
|
||||
|
||||
# vim: set ts=2 sw=2:
|
||||
|
@ -1,91 +1,90 @@
|
||||
---
|
||||
|
||||
# Use acme.sh instead of certbot because they only support installation via
|
||||
# snap now.
|
||||
- block:
|
||||
- name: Remove certbot
|
||||
ansible.builtin.apt:
|
||||
name: certbot
|
||||
state: absent
|
||||
- name: Remove certbot
|
||||
ansible.builtin.apt:
|
||||
name: certbot
|
||||
state: absent
|
||||
|
||||
- name: Remove old certbot post and pre hooks for nginx
|
||||
ansible.builtin.file:
|
||||
dest: "{{ item }}"
|
||||
state: absent
|
||||
with_items:
|
||||
- /etc/letsencrypt/renewal-hooks/pre/stop-nginx.sh
|
||||
- /etc/letsencrypt/renewal-hooks/post/start-nginx.sh
|
||||
- name: Remove old certbot post and pre hooks for nginx
|
||||
ansible.builtin.file:
|
||||
dest: "{{ item }}"
|
||||
state: absent
|
||||
with_items:
|
||||
- /etc/letsencrypt/renewal-hooks/pre/stop-nginx.sh
|
||||
- /etc/letsencrypt/renewal-hooks/post/start-nginx.sh
|
||||
|
||||
- name: Check if acme.sh is installed
|
||||
ansible.builtin.stat:
|
||||
path: "{{ letsencrypt_acme_home }}"
|
||||
register: acme_home
|
||||
- name: Check if acme.sh is installed
|
||||
ansible.builtin.stat:
|
||||
path: "{{ letsencrypt_acme_home }}"
|
||||
register: acme_home
|
||||
|
||||
- name: Download acme.sh
|
||||
ansible.builtin.get_url:
|
||||
url: https://raw.githubusercontent.com/acmesh-official/acme.sh/master/acme.sh
|
||||
dest: "{{ letsencrypt_acme_script_temp }}"
|
||||
mode: 0700
|
||||
register: acme_download
|
||||
when: not acme_home.stat.exists
|
||||
- name: Download acme.sh
|
||||
ansible.builtin.get_url:
|
||||
url: https://raw.githubusercontent.com/acmesh-official/acme.sh/master/acme.sh
|
||||
dest: "{{ letsencrypt_acme_script_temp }}"
|
||||
mode: "0700"
|
||||
register: acme_download
|
||||
when: not acme_home.stat.exists
|
||||
|
||||
# Run the "install" for acme.sh so it creates the .acme.sh dir (currently I
|
||||
# have to chdir to the /root directory where the script exists or else it
|
||||
# fails. Ansible runs it, but the script can't find itself...).
|
||||
- name: Install acme.sh
|
||||
ansible.builtin.command:
|
||||
cmd: "{{ letsencrypt_acme_script_temp }} --install --no-profile --no-cron"
|
||||
creates: "{{ letsencrypt_acme_home }}/acme.sh"
|
||||
chdir: /root
|
||||
register: acme_install
|
||||
when: acme_download is changed
|
||||
# Run the "install" for acme.sh so it creates the .acme.sh dir (currently I
|
||||
# have to chdir to the /root directory where the script exists or else it
|
||||
# fails. Ansible runs it, but the script can't find itself...).
|
||||
- name: Install acme.sh
|
||||
ansible.builtin.command:
|
||||
cmd: "{{ letsencrypt_acme_script_temp }} --install --no-profile --no-cron"
|
||||
creates: "{{ letsencrypt_acme_home }}/acme.sh"
|
||||
chdir: /root
|
||||
register: acme_install
|
||||
when: acme_download is changed
|
||||
|
||||
- name: Remove temporary acme.sh script
|
||||
ansible.builtin.file:
|
||||
dest: "{{ letsencrypt_acme_script_temp }}"
|
||||
state: absent
|
||||
when:
|
||||
- acme_install.rc is defined
|
||||
- acme_install.rc == 0
|
||||
- name: Remove temporary acme.sh script
|
||||
ansible.builtin.file:
|
||||
dest: "{{ letsencrypt_acme_script_temp }}"
|
||||
state: absent
|
||||
when:
|
||||
- acme_install.rc is defined
|
||||
- acme_install.rc == 0
|
||||
|
||||
- name: Set default certificate authority for acme.sh
|
||||
ansible.builtin.command:
|
||||
cmd: "{{ letsencrypt_acme_home }}/acme.sh --set-default-ca --server letsencrypt"
|
||||
- name: Set default certificate authority for acme.sh
|
||||
ansible.builtin.command:
|
||||
cmd: "{{ letsencrypt_acme_home }}/acme.sh --set-default-ca --server letsencrypt"
|
||||
|
||||
- name: Prepare Let's Encrypt well-known directory
|
||||
ansible.builtin.file:
|
||||
state: directory
|
||||
path: /var/lib/letsencrypt/.well-known
|
||||
owner: root
|
||||
group: nginx
|
||||
mode: g+s
|
||||
- name: Prepare Let's Encrypt well-known directory
|
||||
ansible.builtin.file:
|
||||
state: directory
|
||||
path: /var/lib/letsencrypt/.well-known
|
||||
owner: root
|
||||
group: nginx
|
||||
mode: g+s
|
||||
|
||||
- name: Copy systemd service to renew Let's Encrypt certs
|
||||
ansible.builtin.template:
|
||||
src: renew-letsencrypt.service.j2
|
||||
dest: /etc/systemd/system/renew-letsencrypt.service
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
- name: Copy systemd service to renew Let's Encrypt certs
|
||||
ansible.builtin.template:
|
||||
src: renew-letsencrypt.service.j2
|
||||
dest: /etc/systemd/system/renew-letsencrypt.service
|
||||
mode: "0644"
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: Copy systemd timer to renew Let's Encrypt certs
|
||||
ansible.builtin.copy:
|
||||
src: renew-letsencrypt.timer
|
||||
dest: /etc/systemd/system/renew-letsencrypt.timer
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
- name: Copy systemd timer to renew Let's Encrypt certs
|
||||
ansible.builtin.copy:
|
||||
src: renew-letsencrypt.timer
|
||||
dest: /etc/systemd/system/renew-letsencrypt.timer
|
||||
mode: "0644"
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
# always issues daemon-reload just in case the service/timer changed
|
||||
- name: Start and enable systemd timer to renew Let's Encrypt certs
|
||||
ansible.builtin.systemd:
|
||||
name: renew-letsencrypt.timer
|
||||
state: started
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
# always issues daemon-reload just in case the service/timer changed
|
||||
- name: Start and enable systemd timer to renew Let's Encrypt certs
|
||||
ansible.builtin.systemd:
|
||||
name: renew-letsencrypt.timer
|
||||
state: started
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
|
||||
when: (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('20.04', '=='))
|
||||
or (ansible_distribution == 'Debian' and ansible_distribution_version is version('11', '=='))
|
||||
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:
|
||||
|
@ -1,13 +1,24 @@
|
||||
---
|
||||
- name: Add nginx.org apt signing key
|
||||
- name: Remove nginx apt signing key from apt-key
|
||||
ansible.builtin.apt_key:
|
||||
id: 0x573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
|
||||
url: https://nginx.org/keys/nginx_signing.key
|
||||
state: present
|
||||
register: add_nginx_apt_key
|
||||
id: "053473772654754373614404074646527257655730117366337542"
|
||||
state: absent
|
||||
tags:
|
||||
- nginx
|
||||
- packages
|
||||
- nginx
|
||||
|
||||
- name: Download nginx apt signing key
|
||||
ansible.builtin.get_url:
|
||||
url: https://nginx.org/keys/nginx_signing.key
|
||||
dest: /usr/share/keyrings/nginx_signing.key
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
checksum: sha256:55385da31d198fa6a5012d40ae98ecb272a6c4e8fffffba94719ffd3e87de37a
|
||||
register: download_nginx_signing_key
|
||||
tags:
|
||||
- packages
|
||||
- nginx
|
||||
|
||||
- name: Add nginx.org repo
|
||||
ansible.builtin.template:
|
||||
@ -15,18 +26,16 @@
|
||||
dest: /etc/apt/sources.list.d/nginx_org_sources.list
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
mode: "0644"
|
||||
register: add_nginx_apt_repository
|
||||
tags:
|
||||
- nginx
|
||||
- packages
|
||||
|
||||
- name: Update apt cache
|
||||
ansible.builtin.apt:
|
||||
ansible.builtin.apt: # noqa no-handler
|
||||
update_cache: true
|
||||
when:
|
||||
add_nginx_apt_key is changed or
|
||||
add_nginx_apt_repository is changed
|
||||
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
|
||||
ansible.builtin.apt:
|
||||
@ -41,7 +50,7 @@
|
||||
ansible.builtin.template:
|
||||
src: nginx.conf.j2
|
||||
dest: /etc/nginx/nginx.conf
|
||||
mode: 0644
|
||||
mode: "0644"
|
||||
owner: root
|
||||
group: root
|
||||
notify:
|
||||
@ -51,8 +60,8 @@
|
||||
- name: Copy extra nginx configs
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item }}"
|
||||
dest: "/etc/nginx/{{ item }}"
|
||||
mode: 0644
|
||||
dest: /etc/nginx/{{ item }}
|
||||
mode: "0644"
|
||||
owner: root
|
||||
group: root
|
||||
loop:
|
||||
@ -74,7 +83,7 @@
|
||||
state: directory
|
||||
owner: nginx
|
||||
group: nginx
|
||||
mode: 0755
|
||||
mode: "0755"
|
||||
tags: nginx
|
||||
|
||||
- name: Configure nginx virtual hosts
|
||||
@ -91,7 +100,7 @@
|
||||
ansible.builtin.template:
|
||||
src: blank-vhost.conf.j2
|
||||
dest: "{{ nginx_confd_path }}/blank-vhost.conf"
|
||||
mode: 0644
|
||||
mode: "0644"
|
||||
owner: root
|
||||
group: root
|
||||
notify:
|
||||
@ -102,7 +111,7 @@
|
||||
ansible.builtin.copy:
|
||||
src: munin.conf
|
||||
dest: /etc/nginx/conf.d/munin.conf
|
||||
mode: 0644
|
||||
mode: "0644"
|
||||
owner: root
|
||||
group: root
|
||||
notify:
|
||||
|
@ -1,29 +1,29 @@
|
||||
---
|
||||
|
||||
- block:
|
||||
- name: Configure https vhosts
|
||||
ansible.builtin.template: src=vhost.conf.j2 dest={{ nginx_confd_path }}/{{ item.domain_name }}.conf mode=0644 owner=root group=root
|
||||
loop: "{{ nginx_vhosts }}"
|
||||
notify:
|
||||
- reload nginx
|
||||
- name: Configure https vhosts
|
||||
ansible.builtin.template: src=vhost.conf.j2 dest={{ nginx_confd_path }}/{{ item.domain_name }}.conf mode=0644 owner=root group=root
|
||||
loop: "{{ nginx_vhosts }}"
|
||||
notify:
|
||||
- reload nginx
|
||||
|
||||
- name: Generate self-signed TLS cert
|
||||
ansible.builtin.command: openssl req -x509 -nodes -sha256 -days 365 -subj "/C=SO/ST=SO/L=snakeoil/O=snakeoil/CN=snakeoil" -newkey rsa:2048 -keyout /etc/ssl/private/nginx-snakeoil.key -out /etc/ssl/certs/nginx-snakeoil.crt -extensions v3_ca creates=/etc/ssl/certs/nginx-snakeoil.crt
|
||||
notify:
|
||||
- reload nginx
|
||||
- name: Generate self-signed TLS cert
|
||||
ansible.builtin.command: openssl req -x509 -nodes -sha256 -days 365 -subj "/C=SO/ST=SO/L=snakeoil/O=snakeoil/CN=snakeoil" -newkey rsa:2048 -keyout /etc/ssl/private/nginx-snakeoil.key
|
||||
-out /etc/ssl/certs/nginx-snakeoil.crt -extensions v3_ca creates=/etc/ssl/certs/nginx-snakeoil.crt
|
||||
notify:
|
||||
- reload nginx
|
||||
|
||||
- name: Download 4096-bit RFC 7919 dhparams
|
||||
ansible.builtin.get_url:
|
||||
url: https://raw.githubusercontent.com/internetstandards/dhe_groups/master/ffdhe4096.pem
|
||||
checksum: sha256:64852d6890ff9e62eecd1ee89c72af9af244dfef5b853bcedea3dfd7aade22b3
|
||||
dest: "{{ nginx_ssl_dhparam }}"
|
||||
notify:
|
||||
- reload nginx
|
||||
- name: Download 4096-bit RFC 7919 dhparams
|
||||
ansible.builtin.get_url:
|
||||
url: https://raw.githubusercontent.com/internetstandards/dhe_groups/master/ffdhe4096.pem
|
||||
checksum: sha256:64852d6890ff9e62eecd1ee89c72af9af244dfef5b853bcedea3dfd7aade22b3
|
||||
dest: "{{ nginx_ssl_dhparam }}"
|
||||
notify:
|
||||
- reload nginx
|
||||
|
||||
# TODO: this could break because we can override the document root in host vars
|
||||
- name: Create vhost document roots
|
||||
ansible.builtin.file: path={{ nginx_root_prefix }}/{{ item.domain_name }} state=directory mode=0755 owner=nginx group=nginx
|
||||
loop: "{{ nginx_vhosts }}"
|
||||
# TODO: this could break because we can override the document root in host vars
|
||||
- name: Create vhost document roots
|
||||
ansible.builtin.file: path={{ nginx_root_prefix }}/{{ item.domain_name }} state=directory mode=0755 owner=nginx group=nginx
|
||||
loop: "{{ nginx_vhosts }}"
|
||||
tags: nginx
|
||||
|
||||
# vim: set ts=2 sw=2:
|
||||
|
@ -1,19 +1,19 @@
|
||||
---
|
||||
|
||||
- block:
|
||||
- name: Install WordPress
|
||||
ansible.builtin.git: repo=https://github.com/WordPress/WordPress.git dest={{ nginx_root_prefix }}/{{ item.domain_name }}/wordpress version={{ item.wordpress_version }} depth=1 force=true
|
||||
when:
|
||||
- item.has_wordpress is defined
|
||||
- item.has_wordpress
|
||||
loop: "{{ nginx_vhosts }}"
|
||||
- name: Install WordPress
|
||||
ansible.builtin.git: repo=https://github.com/WordPress/WordPress.git dest={{ nginx_root_prefix }}/{{ item.domain_name }}/wordpress version={{ item.wordpress_version
|
||||
}} depth=1 force=true
|
||||
when:
|
||||
- item.has_wordpress is defined
|
||||
- item.has_wordpress
|
||||
loop: "{{ nginx_vhosts }}"
|
||||
|
||||
- name: Fix WordPress directory permissions
|
||||
ansible.builtin.file: path={{ nginx_root_prefix }}/{{ item.domain_name }} state=directory owner=nginx group=nginx recurse=true
|
||||
when:
|
||||
- item.has_wordpress is defined
|
||||
- item.has_wordpress
|
||||
loop: "{{ nginx_vhosts }}"
|
||||
- name: Fix WordPress directory permissions
|
||||
ansible.builtin.file: path={{ nginx_root_prefix }}/{{ item.domain_name }} state=directory owner=nginx group=nginx recurse=true
|
||||
when:
|
||||
- item.has_wordpress is defined
|
||||
- item.has_wordpress
|
||||
loop: "{{ nginx_vhosts }}"
|
||||
tags: wordpress
|
||||
|
||||
# vim: set ts=2 sw=2:
|
||||
|
@ -11,9 +11,11 @@ server {
|
||||
|
||||
return 444;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2 default_server;
|
||||
listen [::]:443 ssl http2 default_server;
|
||||
listen 443 ssl default_server;
|
||||
listen [::]:443 ssl default_server;
|
||||
http2 on;
|
||||
server_name _;
|
||||
|
||||
# self-signed "snakeoil" certificate
|
||||
|
@ -27,8 +27,9 @@
|
||||
|
||||
ssl_dhparam {{ nginx_ssl_dhparam }};
|
||||
ssl_protocols {{ nginx_ssl_protocols }};
|
||||
ssl_ecdh_curve {{ nginx_ssl_ecdh_curve }};
|
||||
ssl_ciphers "{{ tls_cipher_suite }}";
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_prefer_server_ciphers off;
|
||||
|
||||
{# OSCP stapling only works with real certs #}
|
||||
{% if use_letsencrypt == true or item.tls_certificate_path %}
|
||||
@ -38,15 +39,6 @@
|
||||
resolver {{ nginx_ssl_stapling_resolver }};
|
||||
{% 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 %}
|
||||
# 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
|
||||
|
@ -3,17 +3,17 @@
|
||||
{% if ansible_distribution == 'Ubuntu' %}
|
||||
|
||||
{% if nginx_version == "stable" %}
|
||||
deb [arch=amd64] https://nginx.org/packages/ubuntu/ {{ ansible_distribution_release }} nginx
|
||||
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] https://nginx.org/packages/mainline/ubuntu/ {{ ansible_distribution_release }} nginx
|
||||
deb [arch=amd64 signed-by=/usr/share/keyrings/nginx_signing.key] https://nginx.org/packages/mainline/ubuntu/ {{ ansible_distribution_release }} nginx
|
||||
{% endif %}
|
||||
|
||||
{% elif ansible_distribution == 'Debian' %}
|
||||
|
||||
{% if nginx_version == "stable" %}
|
||||
deb [arch=amd64] 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" %}
|
||||
deb [arch=amd64] 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 %}
|
||||
|
@ -8,6 +8,12 @@
|
||||
{% set has_wordpress = item.has_wordpress | default(false) %}
|
||||
{% set needs_php = item.needs_php | 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
|
||||
server {
|
||||
@ -26,15 +32,11 @@ server {
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
http2 on;
|
||||
|
||||
{# Allow sites to override the nginx document root #}
|
||||
{% if item.document_root is defined %}
|
||||
root {{ item.document_root }};
|
||||
{% else %}
|
||||
root {{ nginx_root_prefix }}/{{ domain_name }};
|
||||
{% endif %}
|
||||
root {{ document_root }};
|
||||
|
||||
{# will only work if the TLS cert covers the domain + aliases, like example.com and www.example.com #}
|
||||
server_name {{ domain_name }} {{ domain_aliases }};
|
||||
@ -75,10 +77,8 @@ server {
|
||||
# See: https://httpoxy.org/
|
||||
fastcgi_param HTTP_PROXY "";
|
||||
|
||||
{% if (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('20.04', '==')) or (ansible_distribution == 'Debian' and ansible_distribution_major_version is version('11', '==')) %}
|
||||
fastcgi_pass unix:/run/php/php7.4-fpm-{{ domain_name }}.sock;
|
||||
{% else %}
|
||||
fastcgi_pass unix:/var/run/php5-fpm-{{ domain_name }}.sock;
|
||||
{% if ansible_distribution == 'Debian' and ansible_distribution_major_version is version('12', '==') %}
|
||||
fastcgi_pass unix:/run/php/php8.2-fpm-{{ domain_name }}.sock;
|
||||
{% endif %}
|
||||
fastcgi_index index.php;
|
||||
# set script path relative to document root in server block
|
||||
|
@ -1,6 +1,8 @@
|
||||
---
|
||||
# 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:
|
||||
|
50
roles/php-fpm/tasks/Debian_12.yml
Normal file
50
roles/php-fpm/tasks/Debian_12.yml
Normal file
@ -0,0 +1,50 @@
|
||||
---
|
||||
- block:
|
||||
- name: Set php-fpm packages
|
||||
ansible.builtin.set_fact:
|
||||
php_fpm_packages:
|
||||
- php8.2-fpm
|
||||
# for WordPress
|
||||
- php8.2-mysql
|
||||
- php8.2-gd
|
||||
- php8.2-curl
|
||||
- php8.2-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: php8.2-pool.conf.j2
|
||||
dest: /etc/php/8.2/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 php8.2-fpm
|
||||
|
||||
- name: Remove default www pool
|
||||
ansible.builtin.file:
|
||||
path: /etc/php/8.2/fpm/pool.d/www.conf
|
||||
state: absent
|
||||
notify: reload php8.2-fpm
|
||||
|
||||
# re-configure php.ini
|
||||
- name: Update php.ini
|
||||
ansible.builtin.template:
|
||||
src: php8.2-php.ini.j2
|
||||
dest: /etc/php/8.2/fpm/php.ini
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify: reload php8.2-fpm
|
||||
|
||||
tags: php-fpm
|
||||
when: install_php
|
||||
|
||||
# vim: set ts=2 sw=2:
|
@ -1,36 +0,0 @@
|
||||
---
|
||||
|
||||
- block:
|
||||
- name: Set php-fpm packages
|
||||
ansible.builtin.set_fact:
|
||||
php_fpm_packages:
|
||||
- php7.4-fpm
|
||||
# for WordPress
|
||||
- php7.4-mysql
|
||||
- php7.4-gd
|
||||
- php7.4-curl
|
||||
- php7.4-xml
|
||||
|
||||
- name: Install php-fpm and deps
|
||||
ansible.builtin.apt: name={{ php_fpm_packages }} state=present update_cache=true
|
||||
|
||||
# only copy php-fpm config for vhosts that need WordPress or PHP
|
||||
- name: Copy php-fpm pool config
|
||||
ansible.builtin.template: src=php7.4-pool.conf.j2 dest=/etc/php/7.4/fpm/pool.d/{{ item.domain_name }}.conf owner=root group=root mode=0644
|
||||
loop: "{{ nginx_vhosts }}"
|
||||
when: (item.has_wordpress is defined and item.has_wordpress) or (item.needs_php is defined and item.needs_php)
|
||||
notify: reload php7.4-fpm
|
||||
|
||||
- name: Remove default www pool
|
||||
ansible.builtin.file: path=/etc/php/7.4/fpm/pool.d/www.conf state=absent
|
||||
notify: reload php7.4-fpm
|
||||
|
||||
# re-configure php.ini
|
||||
- name: Update php.ini
|
||||
ansible.builtin.template: src=php7.4-php.ini.j2 dest=/etc/php/7.4/fpm/php.ini owner=root group=root mode=0644
|
||||
notify: reload php7.4-fpm
|
||||
|
||||
tags: php-fpm
|
||||
when: install_php
|
||||
|
||||
# vim: set ts=2 sw=2:
|
@ -1,6 +1,5 @@
|
||||
---
|
||||
# Ubuntu 20.04 uses PHP 7.4
|
||||
# Debian 11 uses PHP 7.4
|
||||
# Debian 12 uses PHP 8.2
|
||||
|
||||
# If any of the vhosts on this host need WordPress then we need to install PHP.
|
||||
# This uses selectattr to filter the list of dicts in nginx_vhosts, selecting
|
||||
@ -10,13 +9,13 @@
|
||||
- name: Check if any vhost needs WordPress
|
||||
ansible.builtin.set_fact:
|
||||
install_php: true
|
||||
when: "nginx_vhosts | selectattr('has_wordpress', 'defined') | selectattr('has_wordpress', 'equalto', true) | list | length > 0"
|
||||
when: nginx_vhosts | selectattr('has_wordpress', 'defined') | selectattr('has_wordpress', 'equalto', true) | list | length > 0
|
||||
|
||||
# Legacy, was only for Piwik, but leaving for now.
|
||||
- name: Check if any vhost needs PHP
|
||||
ansible.builtin.set_fact:
|
||||
install_php: true
|
||||
when: "nginx_vhosts | selectattr('needs_php', 'defined') | selectattr('needs_php', 'equalto', true) | list | length > 0"
|
||||
when: nginx_vhosts | selectattr('needs_php', 'defined') | selectattr('needs_php', 'equalto', true) | list | length > 0
|
||||
|
||||
# If install_php has not been set, then we assume no vhosts need PHP. This is
|
||||
# a bit hacky, but it's the closest we come to an if/then/else.
|
||||
@ -25,20 +24,12 @@
|
||||
install_php: false
|
||||
when: install_php is not defined
|
||||
|
||||
- name: Configure php-fpm on Ubuntu 20.04
|
||||
ansible.builtin.include_tasks: Ubuntu_20.04.yml
|
||||
when:
|
||||
- ansible_distribution == 'Ubuntu'
|
||||
- ansible_distribution_version is version('20.04', '==')
|
||||
- install_php == true
|
||||
tags: php-fpm
|
||||
|
||||
- name: Configure php-fpm on Debian 11
|
||||
ansible.builtin.include_tasks: Ubuntu_20.04.yml
|
||||
- name: Configure php-fpm on Debian 12
|
||||
ansible.builtin.include_tasks: Debian_12.yml
|
||||
when:
|
||||
- ansible_distribution == 'Debian'
|
||||
- ansible_distribution_major_version is version('11', '==')
|
||||
- install_php == true
|
||||
- ansible_distribution_major_version is version('12', '==')
|
||||
- install_php
|
||||
tags: php-fpm
|
||||
|
||||
# vim: set ts=2 sw=2:
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -19,11 +19,16 @@
|
||||
; 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
|
||||
; Unix user/group of the child processes. This can be used only if the master
|
||||
; process running user is root. It is set after the child process is created.
|
||||
; The user and group can be specified either by their name or by their numeric
|
||||
; IDs.
|
||||
; Note: If the user is root, the executable needs to be started with
|
||||
; --allow-to-run-as-root option to work.
|
||||
; Default Values: The user is set to master process running user by default.
|
||||
; If the group is not set, the user's group is used.
|
||||
user = {{ webserver }}
|
||||
group = {{ webserver }}
|
||||
|
||||
; The address on which to accept FastCGI requests.
|
||||
; Valid syntaxes are:
|
||||
@ -35,20 +40,22 @@ group = nginx
|
||||
; (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
|
||||
listen = /run/php/php8.2-fpm-{{ domain_name }}.sock
|
||||
|
||||
; Set listen(2) backlog.
|
||||
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
|
||||
; Default Value: 511 (-1 on Linux, FreeBSD and OpenBSD)
|
||||
;listen.backlog = 511
|
||||
|
||||
; Set permissions for unix socket, if one is used. In Linux, read/write
|
||||
; permissions must be set in order to allow connections from a web server. Many
|
||||
; BSD-derived systems allow connections regardless of permissions.
|
||||
; Default Values: user and group are set as the running user
|
||||
; mode is set to 0660
|
||||
listen.owner = nginx
|
||||
listen.group = nginx
|
||||
; BSD-derived systems allow connections regardless of permissions. The owner
|
||||
; and group can be specified either by name or by their numeric IDs.
|
||||
; Default Values: Owner is set to the master process running user. If the group
|
||||
; is not set, the owner's group is used. Mode is set to 0660.
|
||||
listen.owner = {{ webserver }}
|
||||
listen.group = {{ webserver }}
|
||||
;listen.mode = 0660
|
||||
|
||||
; When POSIX Access Control Lists are supported you can set them using
|
||||
; these options, value is a comma separated list of user/group names.
|
||||
; When set, listen.owner and listen.group are ignored
|
||||
@ -63,6 +70,10 @@ listen.group = nginx
|
||||
; Default Value: any
|
||||
;listen.allowed_clients = 127.0.0.1
|
||||
|
||||
; Set the associated the route table (FIB). FreeBSD only
|
||||
; Default Value: -1
|
||||
;listen.setfib = 1
|
||||
|
||||
; Specify the nice(2) priority to apply to the pool processes (only if set)
|
||||
; The value can vary from -19 (highest priority) to 20 (lower priority)
|
||||
; Note: - It will only work if the FPM master process is launched as root
|
||||
@ -71,8 +82,9 @@ listen.group = nginx
|
||||
; 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
|
||||
; Set the process dumpable flag (PR_SET_DUMPABLE prctl for Linux or
|
||||
; PROC_TRACE_CTL procctl for FreeBSD) even if the process user
|
||||
; or group is different than the master process user. It allows to create process
|
||||
; core dump and ptrace the process for the pool user.
|
||||
; Default Value: no
|
||||
; process.dumpable = yes
|
||||
@ -94,6 +106,8 @@ listen.group = nginx
|
||||
; state (waiting to process). If the number
|
||||
; of 'idle' processes is greater than this
|
||||
; number then some children will be killed.
|
||||
; pm.max_spawn_rate - the maximum number of rate to spawn child
|
||||
; processes at once.
|
||||
; ondemand - no children are created at startup. Children will be forked when
|
||||
; new requests will connect. The following parameter are used:
|
||||
; pm.max_children - the maximum number of children that
|
||||
@ -129,6 +143,12 @@ pm.min_spare_servers = 1
|
||||
; Note: Mandatory when pm is set to 'dynamic'
|
||||
pm.max_spare_servers = 3
|
||||
|
||||
; The number of rate to spawn child processes at once.
|
||||
; Note: Used only when pm is set to 'dynamic'
|
||||
; Note: Mandatory when pm is set to 'dynamic'
|
||||
; Default Value: 32
|
||||
;pm.max_spawn_rate = 32
|
||||
|
||||
; The number of seconds after which an idle process will be killed.
|
||||
; Note: Used only when pm is set to 'ondemand'
|
||||
; Default Value: 10s
|
||||
@ -141,7 +161,7 @@ pm.max_spare_servers = 3
|
||||
;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:
|
||||
; recognized as a status page. It shows the following information:
|
||||
; pool - the name of the pool;
|
||||
; process manager - static, dynamic or ondemand;
|
||||
; start time - the date and time FPM has started;
|
||||
@ -231,7 +251,7 @@ pm.max_spare_servers = 3
|
||||
; 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
|
||||
; It's available in: /usr/share/php/8.2/fpm/status.html
|
||||
;
|
||||
; Note: The value must start with a leading slash (/). The value can be
|
||||
; anything, but it may not be a good idea to use the .php extension or it
|
||||
@ -239,6 +259,22 @@ pm.max_spare_servers = 3
|
||||
; Default Value: not set
|
||||
;pm.status_path = /status
|
||||
|
||||
; The address on which to accept FastCGI status request. This creates a new
|
||||
; invisible pool that can handle requests independently. This is useful
|
||||
; if the main pool is busy with long running requests because it is still possible
|
||||
; to get the status before finishing the long running requests.
|
||||
;
|
||||
; Valid syntaxes are:
|
||||
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
|
||||
; a specific port;
|
||||
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
|
||||
; a specific port;
|
||||
; 'port' - to listen on a TCP socket to all addresses
|
||||
; (IPv6 and IPv4-mapped) on a specific port;
|
||||
; '/path/to/unix/socket' - to listen on a unix socket.
|
||||
; Default Value: value of the listen option
|
||||
;pm.status_listen = 127.0.0.1:9001
|
||||
|
||||
; The ping URI to call the monitoring page of FPM. If this value is not set, no
|
||||
; URI will be recognized as a ping page. This could be used to test from outside
|
||||
; that FPM is alive and responding, or to
|
||||
@ -271,13 +307,13 @@ pm.max_spare_servers = 3
|
||||
; %d: time taken to serve the request
|
||||
; it can accept the following format:
|
||||
; - %{seconds}d (default)
|
||||
; - %{miliseconds}d
|
||||
; - %{mili}d
|
||||
; - %{milliseconds}d
|
||||
; - %{milli}d
|
||||
; - %{microseconds}d
|
||||
; - %{micro}d
|
||||
; %e: an environment variable (same as $_ENV or $_SERVER)
|
||||
; it must be associated with embraces to specify the name of the env
|
||||
; variable. Some exemples:
|
||||
; variable. Some examples:
|
||||
; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
|
||||
; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
|
||||
; %f: script filename
|
||||
@ -306,14 +342,30 @@ pm.max_spare_servers = 3
|
||||
; %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
|
||||
; The strftime(3) format must be encapsulated in a %{<strftime_format>}t tag
|
||||
; %T: time the log has been written (the request has finished)
|
||||
; it can accept a strftime(3) format:
|
||||
; The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag
|
||||
; The strftime(3) format must be encapsulated 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%%"
|
||||
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{milli}d %{kilo}M %C%%"
|
||||
|
||||
; A list of request_uri values which should be filtered from the access log.
|
||||
;
|
||||
; As a security precuation, this setting will be ignored if:
|
||||
; - the request method is not GET or HEAD; or
|
||||
; - there is a request body; or
|
||||
; - there are query parameters; or
|
||||
; - the response code is outwith the successful range of 200 to 299
|
||||
;
|
||||
; Note: The paths are matched against the output of the access.format tag "%r".
|
||||
; On common configurations, this may look more like SCRIPT_NAME than the
|
||||
; expected pre-rewrite URI.
|
||||
;
|
||||
; Default Value: not set
|
||||
;access.suppress_path[] = /ping
|
||||
;access.suppress_path[] = /health_check.php
|
||||
|
||||
; The log file for slow requests
|
||||
; Default Value: not set
|
||||
@ -372,7 +424,7 @@ pm.max_spare_servers = 3
|
||||
|
||||
; Redirect worker stdout and stderr into main error log. If not set, stdout and
|
||||
; stderr will be redirected to /dev/null according to FastCGI specs.
|
||||
; Note: on highloaded environement, this can cause some delay in the page
|
||||
; Note: on highloaded environment, this can cause some delay in the page
|
||||
; process time (several ms).
|
||||
; Default Value: no
|
||||
;catch_workers_output = yes
|
Reference in New Issue
Block a user