From e74753cab4515e64ae64f9fd652004e989ed8bd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=AD=C3=B0ir=20Valberg=20Gu=C3=B0mundsson?= Date: Sat, 7 May 2022 22:53:18 +0200 Subject: [PATCH] Mastodon! --- group_vars/all/secrets.yml | 230 ++++++++++-------- group_vars/all/secrets.yml.contents | 7 + roles/docker/defaults/main.yml | 5 + .../docker/files/configs/mastodon/env_file.j2 | 59 +++++ .../files/configs/mastodon/vhost-mastodon | 2 + roles/docker/tasks/services/mastodon.yml | 118 +++++++++ 6 files changed, 320 insertions(+), 101 deletions(-) create mode 100644 roles/docker/files/configs/mastodon/env_file.j2 create mode 100644 roles/docker/files/configs/mastodon/vhost-mastodon create mode 100644 roles/docker/tasks/services/mastodon.yml diff --git a/group_vars/all/secrets.yml b/group_vars/all/secrets.yml index b6c2897..fe938a3 100644 --- a/group_vars/all/secrets.yml +++ b/group_vars/all/secrets.yml @@ -1,102 +1,130 @@ $ANSIBLE_VAULT;1.1;AES256 -32336562633266653862666430393834306131343538636136643866306639313132383063393335 -3437383263343337323637616330383761346661383065390a396466663135313433643830316439 -65626336303339653730643435353366633839366165393463663031333030356464373338353765 -3662646137623936650a633038376161633737376432306466663938333838333339626235663362 -34303237306533343435346361346461613339323931666461313261623936653936656439663139 -39666639616234653565303235313866636463656237363861636366666433393631366364623534 -39313638363231646539383133383938353439356335313263656362376538623531636166383233 -32653461653965303835613833383736396563306436623762613138343665343461623964666464 -31363836343534616235323238663262343963376133636337333937353732623938616434333666 -37386231356633653034656130383463643065373935633334653766396539326262646465376338 -31346134356162613266393132313839363166623562316230313338373062393535363236363133 -62653261663865323933323061353864643435323538633733363030356636653162616237323839 -33636235396166326336303133613431326231356434383431623366386437303162396234626563 -66333232343234613661363339653234343333323965353537353337303964653066356664303265 -62333237343334333836623566643633656134353034623630323361376562353464636538623664 -65313435316533633834303734636233333164616230393664646261663133323536356338323430 -38623734366530313461653062376136336634386132333138666439326636373536636134333432 -61396432353962366333373961323263633036656362653330393236333737306664633335313438 -34383335313933613930376436323236343539363035323461333366646462623961633933313432 -38656530653336306130313932393162626437383736393162656364333162623831356163303365 -66343433316131313332346537343863343966323765373035306661366633336261306661363966 -39326131336561633463613731396663336639613634636631373435623263353961323539623162 -30383831393164373632336265373662663936336131306563323833643236616338653835633832 -33383530623733386564373935663437613366633536386131363465363466306632373535646661 -62616531363737336536616132343034663038623665666636613232663666303164663661366232 -33626536336435323031663662383836326331633262386634393333373630343431333461393234 -33656664666466623262353533363833616663303637393164633633336438393131366261326230 -63623266353432613832633163663363663964303461386366373236386131376336623138366134 -33626234383661646637323062363265623630663061353630313466626632623062386638643433 -36333262666562396433393866393362303134616664616531386637336233306334383434616238 -62353237396432353335316631336265326135616430383735353638346339623539393064373365 -66336463653139323962333065666363363733376161613434363830663161303735306264396339 -35643535326130313033636135656634303731323030623131613866653932346665343365343537 -30393534346438343833336262646161643665613639373835336438663664643763323735646566 -30303339386131353863643463383333616432333262633962656434343563323165366533643730 -36646431336361316234393731373563656164646437636536353530343731373531373932313633 -61363462386663333465333465363864643039346238303635323362646335363037323437633462 -62373839666639326465383766333462356635636163376366373764373462386430616566386564 -39353662346632623661326238306136373364343231303664626630663761643433393033633335 -62336232376134656537383632643730303330353533626634633138383163356533646461656230 -31373733326436323937373537363839653034356137343864656364313831336235396530373265 -31663035326365373033313030363032343030346635343333656637343961303861393336316134 -35383635393737643935646334373865386637373636303162363562326239326433396466396435 -66336235373238326662323763333733636635313862653233353165346233313663353164383937 -37373934343261373462373832363633323438663536356133343464316563316362343932396234 -30343335396562336433353233306132656239663036663064653235376264653933363636326132 -33353064663930626330386562396564323965393432353430326362616235353464623861313336 -37363333623736306632643931356138373031363938363966616632666236346265323562306538 -39303365613463393964376536383431326661323237616538353333373930616438633630633961 -35303436353231373133666165306534346137396662653736343135303431613438363864616237 -65643338633065663266303232643264316564373066663038306632653962626336346639393061 -33326638323066323264353338636535336363376639646233336234643137646262666238363865 -34623236396437623539653466653331326434643036663930333065393836383265613036393233 -64333530636138356361643635613933313335636662646666656131613834376632313734373261 -66626262373630386337303539323332343831373731643830323661656435626266386633366666 -38626330663635623262336435373432383066393335633261383633343633616564353135613334 -34616663333562643232333133626433313265316561633638633236343334323337643066386363 -33316637303533393165656665373931313666616330316465643531303730333036613965383161 -65346133303835643134643030373966636632663937343434633263633161366236613039313866 -63343362303866313732326438393262643630633461316534313638343230653462636330363437 -36613561366235646465326163343165633764333466643766316235396534363366366238626161 -32656566386130623962643865643562623338353939306463663034653939383864356164316332 -34396661303364323430323764346438393165313430623464373436323337303966613437626136 -34303166396636666237383138636230306161323161343738353062383262373631643637366139 -36313033623162366530366130376338623634363661623965643364666330313066646233303963 -65353137616236396266336238346562343331363964356237356132303734326138646164663961 -62383761663837326431343939666432663132396464646439626364373833653164313931353631 -34633737333961646137663764363763356138396264353534303236633135643936313039303565 -37663937613961643563346130653536653236346165633333383666623961303138363961646138 -36613062346562326537656236343835383663386235353638653861613865333635333161326337 -66343664373262383164313838393261663566393838633364363931653164613663643966643063 -39656261643733663763383339653433616231653737623865353038646331373334666232346334 -39653730613439393532326430623239666239616361313738343738376536303839623938396439 -37393134343333383430303963356563633862336134373962306634613261653131636631626638 -35613635643336306435643832383761353465633537666563333763646338656164333661666462 -38643765313865626535326136343365643362373234326262366332653264363863646539366630 -36623635396635363636373139383530633332386263656339396433653936333834656631373637 -65663564353938623737303332373261623862646566386230313865643835323231373933303165 -39356561656534326661346636633933613532373137393737623737383134333132363436373630 -63653139356565356566663532313736613437623634313236663537376462383465613332656233 -65306131356165366131633432383730356163326561326332346535373738636333333165666365 -31636564303838333061323063653135623162636464656263613538306561303361633864383634 -35613164386334646338613661356134303766393239366530666137376362646263333530623565 -34643166313038376136643032393630303435376631336366343632383735626335333232303463 -33643363313434363633393964323064653966353161636135633264333766386266646366316132 -63303935356138356566306234356435343961356166646430633335386435366666333234636465 -36336439663731643663353732353261313037363231306430373962613838616238313662343761 -33316335316236626631636636386137376263323862306262316366663039396334326564303762 -34623562363839386439366639323662393831653530663463396230663133396466326363303065 -35646635323439323062333864336332333938663536373834663535643832316532313262326265 -63376436356662663165616532613963303030613166663865376531613031383865363864333238 -33616230336263306434643933356530303163653232323331643731353134353939363762303933 -32363061346537666637663733346431643164323364363133316265306336626466353366313635 -66653162643533316162363035373532656239356434623761666663626366663336376539656537 -31323561356363393038323762646633323461666263633937313264346364356439343761623337 -34643731393763323339653636656565663665646431313531616337616363373764626334656264 -66633366346137613032313865666363613530643663373834313731353437373239653332656134 -62376164313138303233623964663234643661336232366165616163313866336230353565393365 -36613361346437336431376164663930393530626339626361323764623635396137396634316364 -31393030323539376233383965366433623562646161643866346138316536613437383035656139 -6533 +61323133323862626633633435646431343564633238646365393335366237613031656239333865 +3866376365386635616332303537633736643530376631620a646135643565343163316232393437 +61643038326566303362343163633965343164613332396436656663356433336264393133326632 +6664376531353534660a313532633464313638623734366364663963613363363933646337396231 +65383065616162353465633132363833393963396463663465383333646336613765663331336163 +37656364396362663066373562666538383436616330316164653434623038306238363861646233 +32666433643663613463303461666332353765326138393966316462633166356666326365346230 +64663334613032623734373661383066623931663533306139333930396635326230353233343737 +30383763323566656561333435613362363436636136313264373063316531366531633733373939 +36396262393030343939613431653635333738306137616130666234616363313665393132346661 +34366463343034653934383532346530376365316164326665643535333639333965376439626230 +38343133336331386266643034623238323461353136323463383931323165366331666133363438 +64353336653832393664303561303137623830393432653661363633353438646339303930343333 +36313935386262353862336363363034363738636234626333303031316338633761623835363662 +33623465336236303539393039363431383937363062666262303737393663633133306135383936 +36316432396161653037363535653061376561356436333533616339656661313238613964636362 +66363162656262333033306262396132383331623032326631383138346361376132303263626138 +32643964336332363133316264336365396239353533356666393563313733373939613463373837 +61643966666337306266313131393866636532343561336464366239393834306138373436366337 +63383030346163626536363433623965333166393562666430623736643635633038663563343633 +30313438623036346137623262386636643232366533346239623631326631613662333932663936 +31363136363035313238336239303561386239666162333365333864643439376566343062623839 +61623163333362666339326337326333373134323836613263343437316439343963663537313832 +32376534663166313939393633313936663438333063396239633666326338346239316662646635 +65306631396664613765373733636435373135316231363232396662666238376539303564343164 +33663264303738393933643231396539376564633930356165613861616162386535626663336131 +38666633663765366335336462366630613137616463343432643661376163393061666239623531 +35353335313761346432313266356138363231373132343863666165666362663065636163323866 +34396662656137626336623465653864393530336237386134373033336563386461373563666238 +30363537376565313263363631303638643664633937393938353337386630313533353636393434 +38396162386563616166393463666431666265396361663530386462343062643036623064363236 +36336163633436373036306539636132333735643131623462383230313430643861653466393434 +36383033623235653665666265336239306533363737306466666265323439383966346666346434 +61323537366662633064646162333965306161316137333131383362653637343531336262633238 +38336533313435303465333732363230623662653662346136343765633066333031323537653961 +36353262653334393339653037316135386638653231626564363139373637663336373839623337 +63663036356563613430373662336631666163333932343562313261323663333961666638376531 +35376238303966636236356566633130666231663139623137336136633537336433393230383165 +61393234663832646638316639613637623632316666333537393737306366333863306361376161 +65613265656536666539643061386366346230323230623466373233626138643261356465653833 +39616265383865313763316339653830313630303861643031386330386239323235373537303663 +33323937306538333137343036656164353630373430633231323832633630666133303866356437 +37326632326634306630653936323166343361346363653964663866313030646137613564316534 +33393937396237336463316164303733306630636564623837383163666166396630613037343337 +33336634303639616536373436666666396438643863363564343533373261333135646133373539 +63363732393664366566336232663630636239353664666461633138336164363433363534356363 +38633034303832376530336462366164613538303136333161313230643138616130376132376337 +33643939666430323037373631383064316465396462613765376539613535643330353239333233 +32323134353438323834336465373230346666636366363938363339353765313238636464303063 +66663661663765366663336435633630613134613661306334356333663430663337663732393832 +64613066396539333231353131346137373936383939316566316435303466666133313437313463 +61373836643536363835633835313263613533303761623135616365646237336564323334363934 +65666631383331393131393363303066396134303964326561396536633562663737326235383938 +32323763643162393133363134396564643032353562343831313765653961663131393166616265 +62653030363232363938633532393262653834626565336432663437376361613537646432633561 +63343133396665636636616137313239653635616564373130366139656337313433303835623563 +63373361396363373932386432646562316230313730333230323364653230343666633636323535 +63313132303436306263653666396234396566343637383562353435663663356566666264313331 +61623632393131303130666437343633666339393562316564333064376631333662373561643261 +36343634353732316631396163643135396566653030376332346261656638363864623966326538 +32356663636333306163653966323965363863316261313532353362376235353330343532353639 +66353439666161666335373437323137366261336530326537393934633139313234656165306662 +36383233313436633930363133313531636235333939393363653038336331616163636433353232 +32646633373562353138326631333038386464653166313038666335643132653664376139343363 +31383666373539316438363661663536653934323466346662626465326434653763393938666563 +65663262643935626436343933366464343738633762636637323338356132363739313765663137 +62343161373466653166666538306133363039353565353635346366343730643537396466306165 +30626638366662383466303137363834393862643435636537346165353935393431356533396464 +37636161373030346536333635633935656663376661313566643464376438643834666161363635 +64656137356335623533353738396137356361396130353966646337353631346263626635316533 +37363066653063616539323430346439333464663766346566323865353235646534303063613433 +30323633626263613038383638313438363932613333336130656234353830636463336437313963 +34376462323361366463646239626238633639666263663031386263643930653461333437643436 +38663136353230653636343966393131313265383962636365633237646537303866646139636130 +37346133343630653932326465396363386431313235666365653366343638633539663865333462 +66343831363438646438376434353131633666613633346563613732343066646239613730653937 +35663035326465613537353566633066336131633765643732386631643732313663363639373462 +32333564386338313766656331653761326231636239303031373138376563636166373930613332 +37356137343462306133656461363130623937633233356638303530636139643038636163623634 +39363735383661346235626662333337343838626463333761303737363464353730356634656138 +30623961353964343462623464313363663462366265303139366263663637653236613439393032 +65313833666232646465323936343862613638326666383938366139373836316462353435303561 +36626366653130613666656662336637313562396236373966613165303834313866383634666637 +64623865316335623836336537313036383562306438326263356138613730333337626461623536 +32663163386138653966323666346162373834666566663233313665333934653863376336636335 +35363862646565623261336634613637323865336437326662666135343763313030336531386537 +65626266616562323139326461376363343336376364363061316333643139356130306264383335 +31656265353566376464666233336333613036643934376239333331313264306462663730376664 +37653937363833313132303164656336653036633961303031306665316634386534393263656337 +65363666643331393262336462346663396638346430333966343261323535623339376131643061 +35326535663934326563376130306539636262353966363731323135366133623337386235386136 +65633935643061336162353436323061336332363535643564326430626664626438393536653639 +34616635363666326530616361336433313530653436663838636666323231623236626637366530 +30626433346433313762333661306632366162396437316135393137343235383161353637366265 +61633538343030636532633239653335653538323962613165353835363538666265646661393330 +61626135666535313262643137333935333730623734356637313933353638646232633637643139 +63313233333831386335643134393332336261643735336263633864336235303634656530613537 +35323962613165313862643033623930393931353932326133373866363734643137386434636533 +36646361323866353736646135633261666338303230623338396236383130303238626464346565 +38383738316235353837363863366339613862633230636662313437653533363863333763313532 +38636130643165383833313563336435646136656333643238646161363966626436393338396632 +37376563363632376437323430643361656365653366663339613661343263356438623831383233 +33633734623735613530383932653735386639383665303666336631383735653364663761643363 +34303633666461633330623263653831376435323934613266653162633732356662636534376464 +30353361333634326631353464303034636135306662373439313239653530626463623637323939 +63383936343865346561353364636130383438376133643938346139353434373230666639663438 +36626630343736363466303364336535353930303562623437653933613233346564373365356661 +35303866623764663634613931643831383862393662373935336233646435643635343937356232 +35343239353465616363383535646664343035306564663463316638653163303237396239613936 +65356466613264626434346262363462653739623630336136306163396333313762333436633136 +37636535386566386530616164616332376536323061613562306534656132393763643132626230 +65633030666262326433346338663030666662333033343034313864666137383137636435613533 +63383365333733366436653735626464613362333162333966366533623961383735316432613965 +38393532383763396134633763633063653762626234333933353263303866636137303766393633 +33386665613935373132363537376632393132623662633362376135333838656431633835333333 +63623933663639376566366131303537666562653730343235386563306336616263336239383037 +61326562303761643562653035616531323130393164333538396432306661663630633038623038 +32326439653131626539376135616463666166356233323836623261356663613836616433303966 +30353562643365646662313366376538646534333839363965313565616532613964366635636530 +32343163643531323034346531313639633431643330306437336363333337396638316633343964 +39343331366364356430616463636662356432386438386239353733306535376536333933376439 +34363931393361633835346236616637376234326239383162633436393863316662633233653333 +33333632643033356337643533633038323937663132666564396330363633333566356130383566 +66643438346630616634323161623562346661353332353534636236386133653538373966396464 +62323631626436633733306131363365623464326139666666636261313137623432353461333963 +37333437313338343933306137393063393861643761636462376462623063376161376566356435 +30613538643764366161636437383036313962346262633532616463313531366665643637613935 +62333239633736333333303566633062333730643666393561363566363562633636353934376533 +3636 diff --git a/group_vars/all/secrets.yml.contents b/group_vars/all/secrets.yml.contents index 71b6a3c..8afb93b 100644 --- a/group_vars/all/secrets.yml.contents +++ b/group_vars/all/secrets.yml.contents @@ -11,6 +11,7 @@ postgres_passwords: mailu: xxx ttrss: xxx keycloak: xxx + mastodon: xxx fider_jwt_secret: xxx @@ -40,3 +41,9 @@ matrix_secrets: keycloak_secrets: admin_user: xxx //used for setting up the initial admin user on first run admin_password: xxx + +mastodon_secrets: + secret_key_base: xxx + otp_secret: xxx + vapid_private_key: xxx + vapid_public_key: xxx diff --git a/roles/docker/defaults/main.yml b/roles/docker/defaults/main.yml index 605595f..86472bf 100644 --- a/roles/docker/defaults/main.yml +++ b/roles/docker/defaults/main.yml @@ -106,3 +106,8 @@ postfix: - "{{ passit.domain }}" - "{{ fider.domain }}" - "{{ gitea.domain }}" + - "{{ mastodon.domain }}" + +mastodon: + domain: "social.{{ base_domain }}" + volume_folder: "{{ volume_root_folder }}/mastodon" diff --git a/roles/docker/files/configs/mastodon/env_file.j2 b/roles/docker/files/configs/mastodon/env_file.j2 new file mode 100644 index 0000000..e894d0d --- /dev/null +++ b/roles/docker/files/configs/mastodon/env_file.j2 @@ -0,0 +1,59 @@ +# This is a sample configuration file. You can generate your configuration +# with the `rake mastodon:setup` interactive setup wizard, but to customize +# your setup even further, you'll need to edit it manually. This sample does +# not demonstrate all available configuration options. Please look at +# https://docs.joinmastodon.org/admin/config/ for the full documentation. + +# Note that this file accepts slightly different syntax depending on whether +# you are using `docker-compose` or not. In particular, if you use +# `docker-compose`, the value of each declared variable will be taken verbatim, +# including surrounding quotes. +# See: https://github.com/mastodon/mastodon/issues/16895 + +# Federation +# ---------- +# This identifies your server and cannot be changed safely later +# ---------- +LOCAL_DOMAIN={{ mastodon.domain }} + +# Redis +# ----- +REDIS_HOST=redis +REDIS_PORT=6379 + +# PostgreSQL +# ---------- +DB_HOST=db +DB_USER=postgres +DB_NAME=mastodon +DB_PASS={{ postgres_passwords.mastodon }} +DB_PORT=5432 + +# ------------------------ +ES_ENABLED=false + +# Secrets +# ------- +# Make sure to use `rake secret` to generate secrets +# ------- +SECRET_KEY_BASE={{ mastodon_secrets.secret_key_base }} +OTP_SECRET={{ mastodon_secrets.otp_secret }} + +# Web Push +# -------- +# Generate with `rake mastodon:webpush:generate_vapid_key` +# -------- +VAPID_PRIVATE_KEY={{ mastodon_secrets.vapid_private_key }} +VAPID_PUBLIC_KEY={{ mastodon_secrets.vapid_public_key }} + +# Sending mail +# ------------ +SMTP_SERVER={{ smtp_host }} +SMTP_PORT={{ smtp_port }} +SMTP_LOGIN= +SMTP_PASSWORD= +SMTP_FROM_ADDRESS=notifications@{{ mastodon.domain }} + +# File storage (optional) +# ----------------------- +S3_ENABLED=false diff --git a/roles/docker/files/configs/mastodon/vhost-mastodon b/roles/docker/files/configs/mastodon/vhost-mastodon new file mode 100644 index 0000000..61d7db8 --- /dev/null +++ b/roles/docker/files/configs/mastodon/vhost-mastodon @@ -0,0 +1,2 @@ +listen 3000; +client_max_body_size 50M; # default is 1M diff --git a/roles/docker/tasks/services/mastodon.yml b/roles/docker/tasks/services/mastodon.yml new file mode 100644 index 0000000..b9ca1a1 --- /dev/null +++ b/roles/docker/tasks/services/mastodon.yml @@ -0,0 +1,118 @@ +- name: create mastodon volume folders + file: + name: "{{ mastodon.volume_folder }}/{{ volume }}" + state: directory + owner: "991" + group: "991" + loop: + - "postgres_data" + - "redis_data" + - "mastodon_data" + loop_control: + loop_var: volume + +- name: Copy mastodon environment file + template: + src: files/configs/mastodon/env_file.j2 + dest: "{{ mastodon.volume_folder }}/env_file" + +- name: upload vhost config for root domain + template: + src: files/configs/mastodon/vhost-mastodon + dest: "{{ nginx.volume_folder }}/vhost/{{ mastodon.domain }}" + +- name: set up mastodon + docker_compose: + project_name: mastodon + pull: yes + definition: + version: '3' + services: + db: + restart: always + image: postgres:14-alpine + shm_size: 256mb + networks: + - internal_network + healthcheck: + test: ['CMD', 'pg_isready', '-U', 'postgres'] + volumes: + - "{{ mastodon.volume_folder }}/postgres_data:/var/lib/postgresql/data" + environment: + - 'POSTGRES_HOST_AUTH_METHOD=trust' + + redis: + restart: always + image: redis:6-alpine + networks: + - internal_network + healthcheck: + test: ['CMD', 'redis-cli', 'ping'] + volumes: + - "{{ mastodon.volume_folder }}/redis_data:/data" + + web: + image: tootsuite/mastodon + restart: always + env_file: "{{ mastodon.volume_folder }}/env_file" + command: bash -c "rm -f /mastodon/tmp/pids/server.pid; bundle exec rails s -p 3000" + networks: + - external_services + - internal_network + healthcheck: + # prettier-ignore + test: ['CMD-SHELL', 'wget -q --spider --proxy=off localhost:3000/health || exit 1'] + ports: + - '127.0.0.1:3000:3000' + depends_on: + - db + - redis + volumes: + - "{{ mastodon.volume_folder }}/mastodon_data:/mastodon/public/system" + environment: + VIRTUAL_HOST: "{{ mastodon.domain }}" + VIRTUAL_PORT: "3000" + LETSENCRYPT_HOST: "{{ mastodon.domain }}" + LETSENCRYPT_EMAIL: "{{ letsencrypt_email }}" + + streaming: + image: tootsuite/mastodon + restart: always + env_file: "{{ mastodon.volume_folder }}/env_file" + command: node ./streaming + networks: + - external_services + - internal_network + healthcheck: + # prettier-ignore + test: ['CMD-SHELL', 'wget -q --spider --proxy=off localhost:4000/api/v1/streaming/health || exit 1'] + ports: + - '127.0.0.1:4000:4000' + depends_on: + - db + - redis + + sidekiq: + image: tootsuite/mastodon + restart: always + env_file: "{{ mastodon.volume_folder }}/env_file" + command: bundle exec sidekiq + depends_on: + - db + - redis + networks: + - postfix + - external_services + - internal_network + volumes: + - "{{ mastodon.volume_folder }}/mastodon_data:/mastodon/public/system" + healthcheck: + test: ['CMD-SHELL', "ps aux | grep '[s]idekiq\ 6' || false"] + + networks: + external_services: + external: true + postfix: + external: true + internal_network: + internal: true \ No newline at end of file