diff --git a/README.md b/README.md index fb990e5..707f9ce 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ Currently the following hosts are installed: | neon.binary-kitchen.net | Debian 12 | Auth. DNS | | sodium.binary-kitchen.net | Debian 12 | Mattrix | | magnesium.binary-kitchen.net | Debian 12 | TURN | -| aluminium.binary-kitchen.net | Debian 12 | Zammad | +| aluminium.binary-kitchen.net | Debian 12 | Web (div. via Docker) | | krypton.binary-kitchen.net | Debian 12 | PartDB * | | yttrium.binary-kitchen.net | Debian 12 | Hintervvoidler * | | zirconium.binary-kitchen.net | Debian 12 | Jitsi | diff --git a/group_vars/all/vars.yml b/group_vars/all/vars.yml index 34219bc..adfa065 100644 --- a/group_vars/all/vars.yml +++ b/group_vars/all/vars.yml @@ -105,6 +105,7 @@ mail_aliases: - "root@binary-kitchen.de moepman@binary-kitchen.de,kishi@binary-kitchen.de" - "seife@binary-kitchen.de anke@binary-kitchen.de" - "siebdruck@binary-kitchen.de anke@binary-kitchen.de" +- "therapy-jetzt@binary-kitchen.de darthrain@binary-kitchen.de" - "vorstand@binary-kitchen.de anke@binary-kitchen.de,christoph@schindlbeck.eu,ralf@binary-kitchen.de,zaesa@binary-kitchen.de" - "voucher1@binary-kitchen.de exxess@binary-kitchen.de" - "voucher2@binary-kitchen.de exxess@binary-kitchen.de" @@ -186,6 +187,9 @@ strichliste_dbname: strichliste strichliste_dbuser: strichliste strichliste_dbpass: "{{ vault_strichliste_dbpass }}" +therapy_domain: therapy.jetzt +therapy_secret: "{{ vault_therapy_secret }}" + vaultwarden_domain: vault.binary-kitchen.de vaultwarden_dbname: vaultwarden vaultwarden_dbuser: vaultwarden diff --git a/group_vars/all/vault.yml b/group_vars/all/vault.yml index 57841a1..d8310a4 100644 --- a/group_vars/all/vault.yml +++ b/group_vars/all/vault.yml @@ -1,109 +1,110 @@ $ANSIBLE_VAULT;1.1;AES256 -63626562396631623335303064393137396262393239366236373634323333343264343335306330 -3861326430303265376564306139323064356339653039330a613335323233356361303066663139 -34386465306537666464643736656230356632633239363865386166373834653030363736613834 -6339303364363166620a626134303835346130386238653232316663346633313631653164336336 -34653639363635663537356639646333616438336438333463656537326134343531393435663266 -64366333346130653730613865346134356161373237343539373965623036656231653939303365 -62326638666431333265343639326461313433656639393839396366633431616435393263336231 -66303634656536636165636462396637656331666336623734333139316533636664306262326566 -36616366663933613561336164386463393635636264613737316464666535366361613065363362 -30316566323663623133346130393032646237353934363531326530396263363130326638393032 -30633832663134613964323733623230363831636664373661633966366264373766326161623862 -39396331313231633237313735636261653531313961616230626565623633636638643936326237 -62333066366439643163336233353361343662326237376332396461393663623761613962333237 -65633039363636323235356632326563376163386161373362383466346339356463636437646262 -38313164393036393661336633373265303536316165623330643236313936666139376237366164 -31373364663136356139356433386132343630396531373961616131343333663463616262373439 -34393161323334333732383866653463656265393761346533663530613530313062626330356535 -65393037636665303564316536376531386561366466643961666439326462353864643635353934 -66616432303966643731386133613430313737356539386331623832656132663461393538363962 -64313935613063373832343862373734316634663333313835323836386466336663643661656436 -61353663646165623165663035383461376331373439666433386433376234613163396234373632 -61646230363163366338653332373834386534333436373737383463363335356436313463626333 -63393166316663323066323863373830393937353864376366313535663565613031643932383364 -62623633353662323965393563363261623564396632643662663032613032666162616132336130 -39376430663833303264306135643832383231623336613734373964653736376235653334333639 -63376661636561383236633365303031326630356661633062663564396133313633323738333539 -66303235613562313636343766356263383132643962393232396263393665666334633438383632 -38646635643030303464396634356161333836376364333361356461346664303563346463333838 -34356139373233313631653533356633643730663438646630373331313065363136663938306439 -38336563363966653632613436356530316234326365666438326635313537343665663233363731 -36646565393937326336626333383863656565323832303937323536346366303839633236663566 -32373632646463363634363031626635383233656361336532636366653434623562623937656137 -66303663316165633932643365623732323430376334303036303961396264303664616433356361 -64366135376232313265376563633163373933343066653939313433366539396163656163346663 -30626331333034316131343361636364653936373235623562336366336237353966613536316637 -61343530326139636365613434386263383430626663333932386431313164346532666562346537 -32623538353365383030396332386133343464643732653038623337353135663964643566396439 -64633435623763666461356331306539373638383034343735373765373333656562326338613763 -63633732373765316238633539316665623431616333363364316531306630343735393335616630 -36613362336566393866623566666430336639376662633233656130653837313161653462346335 -63396532663633393363626136373161303235613761373235633831393736343630353031613364 -32353463383934313961313638613533623638383062343936616336646431383935393938623138 -31383032326365333136666165633832333836346231636332353830336264636235383162356630 -38316137623935633863363162376239623932373233663663323830363162313665613830623763 -63656237343662616130326339386231376564613164666163393232653762613932343561343031 -66386431343139373734626430656139353635636233336236653438353066393732663637323435 -63303434376634366262646662616162343664666365373934346530343239653330356234373065 -31373934363731373136346665623334306631626134613334633135666461636462303164653662 -36323132376532613431653063643965636233373165333639323966663333633563303438396466 -64633761376164383835613038633630623439643364323232633437386334346138343361306638 -38626632326137303839306531633536643161656231636662383461373964646333303936343733 -36333863316162393134646563316235663164613062303734346662386466656461346364356564 -35326234336439623961383938316136633037343863363933616663366536613866666165376664 -30306438666365333333636632643832303463356533343033623938653365663732336164303033 -65653936363839323239306463366533653439663437343536393564336163313962313935636534 -34346330393637343834323931353762613839366166353139303535376230356466646261363464 -33386337616230623537376665663835373766316332363433313234326461313935636666363261 -30653433333436306564653461303165656163363331643536323535623062396561643662323334 -35626565616538396566363433363732656538313531636632643163633637303339656431346466 -61353030666638393361613833353532656130643866636135643434366562386363656434323366 -36343764316136316630353338363735646533346362386266643136626366356331656363393133 -35636633353662393435346365663432656166646136346331363563363539326162633166393164 -34303164353632373437613564336266373934396236383962376530613631633932626431333864 -64623439336638613337383763353531376133343436346330373362313034616166616537636366 -30306132613333633261326630323038323431643163373365376662623339396136313531366332 -66663037643036303836376632646132383563316262393438636432666661333836376663666130 -31316135366562633134306633333834636132623739373131626161633636313737646334376434 -33376337393630663338643366316465353266346365333830613533393139333235366237323339 -66346465313462373334316535383633343165373733313230373461366336353664306537306538 -32653538366565663764353031303763613835366461666163336665656436333563613835653438 -65376265303131376239616536353933346633393438643466343439643039313236373033323034 -64316364663139353664653564393262323565646235356431326331343433373639316234363938 -65633034666532306137353431613732663166323936356433323733376261386161383265663264 -35643038663565646135343233623530396165336263303931653037393934343833623337343834 -31343631343563626561393763356463393930616338623861363835343635376238653337653133 -31393834343536396536363533363739306639646333313836393331306566393534383265613234 -31623238306531383936343836336466343336396530633033323063346261366633343936316637 -30343165333861346635623934363537383531323637313461663964353338653639366562306236 -30363265393038633564626463393166333665396538663639346665353736336134643862663630 -62393037363963613263313939613865393066323830656362656464643730636535623639636131 -63343263333134336364323236656639613635323165383164636465353438653134646334643962 -35306463626336626664383638323865633631346437613139623239663538666363313237323663 -39323734353363643334343538303635366637373530383832393861346164666666306631643563 -63306565306337383539636330623933666266353635396238656435373563383830666636616335 -39386134383938626439366437383138303062333236306436336163393832613532303332303833 -39323539396235383765613234303765303136653064336361333035643365386232613766356362 -30656437376537623165626530623365393463626337383139663734396331396363396162383330 -31663636383037613563346330323063393637616334356439666263623662383666376265313732 -63343837306336313264313934653836363665616264396662633761363237366437653962626664 -38383462313435383133613465656435363563373765313361623565636564616236313666633264 -37393165386163393666376636343963333932346463303661373339303765303938636135323363 -35663731656431656330336366383330616163353934333564356633613165396463393066396533 -32396264653265333865643365346233633863333335383735396134663062343166656233613931 -35633133336337343531313266323663363830353236323035313031646434303761343737633139 -30343439323330353531633337353365363031666635653364326235316435383835663139376136 -39343361636662346166363432366162666631366431623563363936336164323836376232326162 -39316337343436386363643064653337613131346266353636333664373262326563386264303831 -65343534616464633232373532313865363732663235376534396436333531633261393066313263 -38316437643232336234343663666536353134626139623138636234396661613261326437303065 -36383331323061643632323339383530626430343132613039393434333939383065623464646362 -65303135313962613564666261356533313961323464623535393631613337663366626136343364 -61363035333636366439313961326462633463616237343133356437303234323363306337343237 -61376138323336663839623539633866313133346338313165623039336335663666313532636261 -36383332346636373936366632393364323331303866623533643062666361613133383262383538 -64343665333761326134303566656638633362643031306535333661623437636139353565623435 -39323631393132336636653731636264356637373031633037653466383163663865626339323731 -34623137386338343038373464613832363761643362623434373136376638663537623762646266 -63306439363039303461 +35346137343735356637663033653465666664363730663138663936636632306566313836643132 +6633663564393937323035363563326465366364373961310a643132653066323938333863626264 +66656663646164633538396132363231373430636134313632333834633435336331396338623933 +3832343264356539390a313937393535623838356465313530303836346164313261613537366430 +64393533613662376466363462643262643433663839393166613938616462663732346234363436 +66663837333861303530373036363536376239633764356461303534626233343861343135353234 +61356362353635343737356430666536636339306630613263613933356330366132356661343566 +33306437666461656339653131633537643931333164396463623433633263633139366565636362 +35306339333631623036386134373839303739373230636164653137393439633530366163613636 +65326635396135313530366161373438623365356437353234343537393033356135623862393033 +62643033656331373435316665313933653835653663376432366461363261303131623237623663 +33363238663963363963326531386137613564633338653466393436663438313231313466323433 +32323934343462333264646137366461303333363165303433663130326437353236653336623266 +30653930616465313930303961383538376662386331663430613064306366323035663431656461 +61623735336162636662616232346637653566306433316237613762623133323236353533623833 +61306630376231643266663732343565386465373066643339633136643961656161393738373862 +33353162656331363563343234303538383763303736393661333831366436633533656265343930 +38616462363238613464386439663830663264646133633631646166346130663464633333333730 +33653231303636653638323136663066666465353532383331663163626237656265656463393139 +64363465663732343930613931313363336633363335383564626366383537376634363461616163 +39393630343531313638363230656634623836396366326530616637363334313961366233306233 +35633961303661376663643339613835633563336361646137353466366436373263363138663563 +62356365616664353131663764303730643361613038663833373834336132306265376436616464 +38383937626439303362636432363936313930313339366565353034313339663536373138376438 +34366637363838623064633765653134383230656565373263356164326661326133353634636536 +31383961343066306437623031386461643430326134646537613366623131353161353335313664 +61633834656438366331653966373131656634303135373630363762313765316364343837663431 +32373438616561333634343436366638353439363563656331333263653061613231303733633134 +66386563346535646339303039353962363762663164386436626632623465363833323434343066 +63626466653162616164323831336165646136613530383063353232333464333234316435386266 +62333535373131666434626261333335663762346663313630643136383835376663636136363933 +33623237666537613164623362396537396163373437633537376435356638653533613939663734 +66626564633435663164616365313339386232386562636461653262363332393536353138393730 +33323464376666663236366134366436313237666635356565346235363630363265343535356233 +35653163663962316336323931356436366439653835346138623966366436373066303932346637 +31393932343136633239663238363337626266623163316165646533333363393038383038316664 +34363739613234666466353163643236356238353831636163393763336261353831313136653963 +33636265383634393332373031306261363764303730633466616432316433656166393035653737 +30643231616334366231333761633461653338653633663564643938616163663532333639353830 +64383761306138303736643962386235353366333832616138306237393738396230303633333132 +31373362323261303362613336333130626364646561653335373639333262663735376437376433 +36386236343233373631303633626363336665656131633862633363326233636636373832353937 +39303237393632363337396362323936646333376439373031626330343139373636333062383138 +33333137623066303961376137613361313831636631663865343863633735366433643165643035 +39373565396561326362376435666539386263666635363664633833336536366466613163323134 +39653239653935346262656333306635646535626563323130663838313564383165393961346161 +39616439376435613535336434343364343066353863626363613765303862306663373730346539 +39363136393463333538323266633235643963363663323265313738633037303862633265353236 +64343361316437623732366163326633346462343332333735333936633266623832633939626362 +32333035613963666530663335656562393465323063336330383535326565346536393731333165 +30373733343136306532636666313338626434313334303933636238643034386438386364663932 +35313134633532373466363132623632376666396161333064376538616137656163663633653064 +66623633343939306638643132386139303761646364656163326263313066616535623234323361 +37396366663734373334386131663161346461383938313263346537353836366264616164636262 +64376535373431376465386165613765653732303461356565623965346334376564343439386164 +30393664353461623965303265393338353366616164633739383434623834306166376631643330 +31303866306561366132333532396135653261613935623537366562313433396436343666386535 +37323861343462396163333431663137643232393865643238316338323735366637643666343735 +30663334326332616361623662653133383536326635626434383830633434366330313731356531 +30366562613532643334613430313737633266343237373765366238313833656463646462613666 +32393734356638633966643133383961613332623331633634646439353338303266393366323564 +36353032383030623163323065653833656330363466336466656562373034653061346163366238 +33346534313633333134356665656462346234393230323132626661666362373566383036653937 +66366266333934343263326433326163373730383361653262633966333135316437633835303665 +66663430363039633464636531326135616563636131656265356438313633306236653431656664 +30343733313638363237343131626538643932373931623136323862646366623362306365616131 +37303966343562313730653763633564336435336362656262363735393966633135376236616163 +39626637393865643338623863346666333764616430383038303434626164653861346433333764 +61386131303764383137616334363866363363313165366339636530393362396135306265303464 +63333030306338346633633863306238333334393562373662663562313733643432396462313131 +65333661343031656263623230346230353266303261646131303731636466303863323466356232 +63383835316161306431663962343966366338323138383632326533646461326232356133356265 +39636434376436363439376230633237366536653561616264613665656635636532623330353466 +65366132646536316131323038313263333961656430343661303664366266313861343463303364 +32303662393433353462346464393931393637316537623061343635353938663765646234323431 +38643531653132633763666663623637373431653731383037346262646332393864643431363338 +32343963623364613538656338336365343265383262656139643934333037383930376564343636 +33623835663035313839656333613833396635646537616464376138663262346564383834643933 +30383039633164353730656339616436343330333134323136646664393764343163313536373261 +31646164656166376232653034363864623161326564303337636534653762336337346335373238 +64373062306165616162666362326531643964656366653037663163363964653462346633666434 +35303638623239353934636332373562343962393531346132303032623334333335373734643034 +64646361373066316134613635666435306235313632633633643864373261643065303937323639 +65383663626338303134613532623763626430623864313930366463663632313130383033633831 +66613531623534336461393764623237383231333133336638313637306439633361353039613938 +30613562393635646235336330633933336233363735346534633266633730346236353265333464 +39613132306232653639326336643662353461356439623233316465316232396366616531396464 +63626462383639353434316364363164376639363264646530323038373439643132343264643231 +32656465366265383630626332613636336632656136333330643937633630396663626632333930 +61623661633666316630616632633832613231386235653434663964316533306233383539343637 +38663431666230653736326531353934396562656161616462383466353637363732616636373033 +39643438356632306431386235333532326463646161616466646634633163366233363362343563 +34393631343733326363363737623638383939353266343262633232336633386233346436393333 +31646161613464623137353939613437623835316531343336323833653437363563363462633536 +36313230363131373233623731636363313034366665633737346134366666393634386637626563 +36376135373330396664616435353539333439306434313933333235646363313262336163386263 +65353361363066363234353336623466393331326332316530356636343865663137313737313830 +35633563343064333565373463343234393732333735363963333336646561393764316462643466 +36653162343239373038336134393532386363333638383831333834373030633138633530353336 +63376334666632323130633136613230306135336231666635363036633066323863346138643330 +33623462653638656237646634623431313664336636366330626135653730323239323462383262 +39326431386235363034386138653665353136356536373838636336626430623164353761636662 +32623363663163633433623833633665313662636264656662373061356336383965303731313431 +34373332616336303062363564656137383463353836303134363434356265393361346365343630 +32613933633139643637363136623863663962356166336134656464613362363130333930356230 +63626365353266383137643263636163613932343333363632333936613831616465646437656465 +35636534363461336332626134346239656238643561313935363366343462333639633937303664 +64323739643562343234333739353334663834626438386432663737653366633466666362643138 +64313536306363653562623536646261313639333266643336613932363835356665 diff --git a/roles/therapy/handlers/main.yml b/roles/therapy/handlers/main.yml new file mode 100644 index 0000000..0e343c2 --- /dev/null +++ b/roles/therapy/handlers/main.yml @@ -0,0 +1,13 @@ +--- + +- name: Reload systemd + systemd: daemon_reload=yes + +- name: Restart therapy + service: name=therapy state=restarted + +- name: Restart nginx + service: name=nginx state=restarted + +- name: Run acertmgr + command: /usr/bin/acertmgr diff --git a/roles/therapy/meta/main.yml b/roles/therapy/meta/main.yml new file mode 100644 index 0000000..8fcf724 --- /dev/null +++ b/roles/therapy/meta/main.yml @@ -0,0 +1,5 @@ +--- + +dependencies: +- { role: acertmgr } +- { role: nginx, nginx_ssl: True } diff --git a/roles/therapy/tasks/main.yml b/roles/therapy/tasks/main.yml new file mode 100644 index 0000000..6046288 --- /dev/null +++ b/roles/therapy/tasks/main.yml @@ -0,0 +1,55 @@ +--- + +- name: Install packages + apt: + name: + - docker.io + - docker-compose + +- name: Create therapy group + group: name=therapy + +- name: Create therapy user + user: + name: therapy + home: /opt/therapy + shell: /bin/bash + group: therapy + groups: docker + +# TODO +# checkout source to /opt/therapy/source - currently done manually + +- name: Configure therapy container + template: src=docker-compose.yml.j2 dest=/opt/therapy/docker-compose.yml + notify: Restart therapy + +- name: Ensure certificates are available + command: openssl req -x509 -nodes -newkey rsa:2048 -keyout /etc/nginx/ssl/{{ therapy_domain }}.key -out /etc/nginx/ssl/{{ therapy_domain }}.crt -days 730 -subj "/CN={{ therapy_domain }}" creates=/etc/nginx/ssl/{{ therapy_domain }}.crt + notify: Restart nginx + +- name: Configure certificate manager for therapy + template: src=certs.j2 dest=/etc/acertmgr/{{ therapy_domain }}.conf + notify: Run acertmgr + +- name: Configure vhost + template: src=vhost.j2 dest=/etc/nginx/sites-available/therapy + notify: Restart nginx + +- name: Enable vhost + file: src=/etc/nginx/sites-available/therapy dest=/etc/nginx/sites-enabled/therapy state=link + notify: Restart nginx + +- name: Systemd unit for therapy + template: src=therapy.service.j2 dest=/etc/systemd/system/therapy.service + notify: + - Reload systemd + - Restart therapy + +- name: Start the therapy service + service: name=therapy state=started enabled=yes + +- name: Enable monitoring + include_role: name=icinga-monitor tasks_from=http + vars: + vhost: "{{ therapy_domain }}" diff --git a/roles/therapy/templates/certs.j2 b/roles/therapy/templates/certs.j2 new file mode 100644 index 0000000..7d09f38 --- /dev/null +++ b/roles/therapy/templates/certs.j2 @@ -0,0 +1,15 @@ +--- + +{{ therapy_domain }}: +- path: /etc/nginx/ssl/{{ therapy_domain }}.key + user: root + group: root + perm: '400' + format: key + action: '/usr/sbin/service nginx restart' +- path: /etc/nginx/ssl/{{ therapy_domain }}.crt + user: root + group: root + perm: '400' + format: crt,ca + action: '/usr/sbin/service nginx restart' diff --git a/roles/therapy/templates/docker-compose.yml.j2 b/roles/therapy/templates/docker-compose.yml.j2 new file mode 100644 index 0000000..6919f9b --- /dev/null +++ b/roles/therapy/templates/docker-compose.yml.j2 @@ -0,0 +1,12 @@ +--- +version: "3.4" +services: + server: + image: therapy + build: ./source + restart: unless-stopped + command: server + environment: + THERAPY_SECRET: {{ therapy_secret }} + ports: + - "127.0.0.1:5000:5000" diff --git a/roles/therapy/templates/therapy.service.j2 b/roles/therapy/templates/therapy.service.j2 new file mode 100644 index 0000000..0f2239f --- /dev/null +++ b/roles/therapy/templates/therapy.service.j2 @@ -0,0 +1,28 @@ +[Unit] +Description=therapy service using docker compose +Requires=docker.service +After=docker.service +Before=nginx.service + +[Service] +Type=simple + +User=therapy +Group=therapy + +Restart=always +TimeoutStartSec=1200 + +WorkingDirectory=/opt/therapy + +# Make sure no old containers are running +ExecStartPre=/usr/bin/docker-compose down -v + +# Compose up +ExecStart=/usr/bin/docker-compose up + +# Compose down, remove containers and volumes +ExecStop=/usr/bin/docker-compose down -v + +[Install] +WantedBy=multi-user.target diff --git a/roles/therapy/templates/vhost.j2 b/roles/therapy/templates/vhost.j2 new file mode 100644 index 0000000..b3306d2 --- /dev/null +++ b/roles/therapy/templates/vhost.j2 @@ -0,0 +1,31 @@ +server { + listen 80; + listen [::]:80; + + server_name {{ therapy_domain }}; + + location /.well-known/acme-challenge { + default_type "text/plain"; + alias /var/www/acme-challenge; + } + + location / { + return 301 https://{{ therapy_domain }}$request_uri; + } +} + +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + + server_name {{ therapy_domain }}; + + ssl_certificate_key /etc/nginx/ssl/{{ therapy_domain }}.key; + ssl_certificate /etc/nginx/ssl/{{ therapy_domain }}.crt; + + location / { + proxy_pass http://localhost:5000; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} diff --git a/site.yml b/site.yml index a23e46b..fb05beb 100644 --- a/site.yml +++ b/site.yml @@ -128,10 +128,10 @@ roles: - coturn -- name: Setup zammad server +- name: Setup web server (dockerized) hosts: aluminium.binary-kitchen.net roles: - - zammad + - therapy - name: Setup jitsi server hosts: zirconium.binary-kitchen.net