diff --git a/.github/workflows/Deploy.yml b/.github/workflows/Deploy.yml index 360443a..25064dc 100644 --- a/.github/workflows/Deploy.yml +++ b/.github/workflows/Deploy.yml @@ -1,79 +1,53 @@ -name: Ansible Deployment +name: 🚀 Ansible Deploy on: - pull_request: - types: [closed] - branches: - - main - - develop + workflow_dispatch: + inputs: + environment: + description: 'Environment target' + required: true + default: 'pre_prod' + type: choice + options: + - pre_prod + - prod + dry_run: + description: 'Check mode (dry-run)' + required: false + default: false + type: boolean env: ANSIBLE_HOST_KEY_CHECKING: "False" jobs: - deploy-prod: - if: | - github.event.pull_request.merged == true && - github.event.pull_request.base.ref == 'main' + deploy: runs-on: ubuntu-latest - environment: production + environment: ${{ inputs.environment == 'prod' && 'production' || 'staging' }} steps: - - name: Checkout repository + - name: 📥 Checkout repository uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v4 + - name: 🐍 Setup Python + uses: actions/setup-python@v5 with: python-version: '3.11' - - name: Install Ansible + - name: 📦 Install Ansible run: pip install ansible - - name: Load SSH key - uses: webfactory/ssh-agent@v0.9.0 - with: - ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - - - name: Deploy to PRODUCTION - working-directory: ansible - run: | - echo '${{ secrets.VAULT_PASSWORD_PROD }}' > vault_pass.txt - ansible-playbook -i hosts playbooks/site.yml \ - --limit=prod \ - --vault-password-file vault_pass.txt - rm vault_pass.txt - - deploy-preprod: - if: | - github.event.pull_request.merged == true && - github.event.pull_request.base.ref == 'develop' - runs-on: ubuntu-latest - environment: staging - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.11' - - - name: Install Ansible - run: pip install ansible - - - name: Load SSH key + - name: 🔑 Load SSH key uses: webfactory/ssh-agent@v0.9.0 with: ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - - name: Deploy to PRE-PRODUCTION + - name: 🚀 Deploy to ${{ inputs.environment == 'prod' && 'PRODUCTION' || 'PRE-PRODUCTION' }} working-directory: ansible run: | - echo '${{ secrets.VAULT_PASSWORD_PRE_PROD }}' > vault_pass.txt + echo '${{ inputs.environment == 'prod' && secrets.VAULT_PASSWORD_PROD || secrets.VAULT_PASSWORD_PRE_PROD }}' > vault_pass.txt ansible-playbook -i hosts playbooks/site.yml \ - --limit=pre_prod \ - --vault-password-file vault_pass.txt + --limit=${{ inputs.environment }} \ + --vault-password-file vault_pass.txt \ + ${{ inputs.dry_run == true && '--check' || '' }} rm vault_pass.txt \ No newline at end of file diff --git a/ansible/host_vars/pre-prod.trackntrain.fr.yml b/ansible/host_vars/pre-prod.trackntrain.fr.yml index e9f7786..73309bf 100644 --- a/ansible/host_vars/pre-prod.trackntrain.fr.yml +++ b/ansible/host_vars/pre-prod.trackntrain.fr.yml @@ -1,142 +1,155 @@ $ANSIBLE_VAULT;1.1;AES256 -39656163373136653066633034313634343535303435373937393332343637636330316236653534 -6636616134326562666566623161646636393262313932390a663032316261313562623038336433 -30663937343466616636626162386366643134333166613736663039373630326465663363346334 -3735646532633035310a396236396331343330346235366565663832356363316162383836346332 -65353430316338323563626333376333346538636339333734306433366561626339313637333737 -61613361623432663961333432313430653066653034636539633633393961626433333366363765 -66363639633531653930313936346430363863646535343366633164353865326235626563383366 -38383661333662653465636364643366613964326266656239613539383837353463663431613433 -34393562353838303666323137623130376536623438613234623630613861396432353834376534 -39373162373766373937666336373730613439346265616266633937623965363037326234373139 -37386565336335623364633537306133376535376563346134663861393937646236653733383932 -37656239313064666364386133633833323662646335383362623866323135343464316264336161 -36623666343162356430346463636234303062666632333533663131646339353339303339366336 -64626263633032393535626533646530303463316234626564363463633936356235626261353335 -66366638613464333537333930623163356266366563346162646132326630653938303632656435 -64636137333763653230323138373435303066343235653461383533383032373839346164303933 -30343061346563633637633065363465613833613430663964653830643566633161653762353537 -36393663373730633832636338383135656532633630626266373162383962323461626163303237 -63653435653863363630643263376261393033303132616563366239313132636463383761653536 -32343035643737643731616435333763313535363833376239383339393864326566623736326161 -36313230386233636666666237316239373432616463643938333862623766376632373536326666 -64393133626563376134356235393436393763383736313264316330666561626430636436363734 -38373934613332393366373734616263613434313235383539353431336537363232626439363433 -31623431326337316363386635396238623534373435616166386532316162616166396136366562 -38616530623661333934383834666637386665643636323766346637383030666361353836653765 -62663937373662316330623335323937326564636565393035626637346562653234356432313837 -37663132313136643134663366373538326139666166346636353834323934336461383833663330 -64333335666461376334396561636339646237316536323062393033323539356335366435663139 -64353433306265373563383963653237626265333431336230363336363736376638323963353966 -36643863646461326439333264373633313835373962383365373466646566323335376437623937 -33313662326334373164373938376235383565356338383738396435336332636565323064383162 -33356631653530326461616162353134323138336533646630376261623366393863633431363838 -62653531376565646336616433323731613134303062303932653265373933333861666564353133 -65326238356665303333356362346461303236323863353438336130346335393363373739363762 -62383036316632336632646533666637383265656539636233656364636439373863386665386561 -31363563623530303465353062646238623337326234356636623661346335376632393662356438 -61613866623364633337376164343765346664653664393838333736626364373738663230653335 -37366233666534656164616266376134656165373563366666653663653562636431316437633365 -62333933613239363635636562363739353030373465386165306137616636633763653464313436 -39636433656463313336353265656463346534353334383730343265353664376538646239623034 -33666339613734666234376130383033376133323562656533336430333833386238366238363262 -62373139623538363638393031316530656365396538346566313837306439303063323062646433 -34323237613232643737323439363639393236663331393134353438386539306566373332383931 -31333035356633303230613736306536373066313166393062306536353031376130386632643933 -61353264343333656665353838346539653963316161356466346636383038366663336539316563 -66363433646163636664613164346439633639326136366337653633316534346631393266663235 -38343165646430663737613330373037363739653862643434306262316335386464383963343365 -32646531353664303830303163616666386633613966666465323131623333353533323563623230 -30373830633663343233363731623366653566373934613165363339643133383832313035646431 -62326161333739396465626130653338646335653033353230383162336265656462353166653532 -38636138613161633366333139323233643835323061636332613835646461613930323638663532 -36616366353164366638626366333330633064633762386133356261343261313739653964323939 -61376261383138373632386232313039643631333137646635633836336635383030623634623865 -34373666653536353231366136613362313035353932623562616538616538326333386638396232 -63363365346466396331396532303031616165343533313366386438303661393132663965306434 -34363461326233363533356362336433656465653930396266646363306638393432303238633938 -63633665393236633136353238316364373537306130643131356164616162386339346138333166 -39373936323330636138616563303035396536663562333635613363383336653862393536306430 -64633232313830623234323363353630663731343431616562663661363737353963373561386365 -61363939333861636234666335323265323661366233366530383737663439313032656231376637 -65373838643161316632316331333433316331666563343539633533343132623262313139653165 -31306636363235313765633031656636333461306165303730356137616633383566393530646538 -66626134633461333166336238663631663631343632333931343035386336383361353061663464 -30373463376163356566356235613632396633383131306430376338346261303236366664393838 -31663763343066396235323933326162366432633632663037623634623835643731653065653237 -65663639616339323835356534663831613962613464363037613835333139653661663531666362 -33306530663061396334393836316238356336313033313563373131616261336566393761333663 -35323765303034333539393361306633396230383338656439306666633233636163333330333938 -39336266636337623431303737303637313436393435313330356631336430623066363064363530 -64383633373463626532376331363264623137643163313334373339323334323934626637383966 -32376439623036323230363034633565373432303665613865383135643064306634653566336132 -32623739393337323261383261616532376264313963356335353032306661613130363162353134 -30376337373632326538303135373236376432333866306531333465663761303939613762313265 -30653831656237626364363433313237626565306665343963663838393931346533323565663533 -66633232323664386664303336623236383831313036643038626433373735656235616164323637 -30343639333939613962346632376438323065323938396138613334333561376265343864356161 -30353335316433313033646334613435643031303931326437623830356363666566333663666163 -34626130653936363865386236343366373337396338623663613134386564343362393533323766 -63613562343637643931346331636636363734626339353132373561353165396561303436613163 -65316636336138356563346535393239383833643366396561383664353936356136353930363534 -62623866626530613166316631383164383666613333656134383435643038643337393331343938 -65313739386364313733306136623433613735313832316130386539303761303764313034363166 -65376436643739353730633761356561663163396638633965666166343138316338366633333063 -30623736363730636263326630393632663734623431643365326361623636356265613733333130 -38616437386439623664363064356435366135323939396238643361363034353333383964643365 -34383637386465653037626662396664343063616236306636303835303833393839383838356163 -31626132613562303662323363633665636530333236643039633061343636376530623466316335 -65393163656238333262343231316330636465333934353334323563613864316431643365373065 -31633262386465316163313135613034366439663538326133646637643862363636316331386334 -31326633626335313165646364383935393731363230366532633062363134373663626263636338 -30623038333664393036373735323633663537643236356462666133653264613362373234616162 -61613565386565623466323864373861323761333230646239376238653239373365356361346637 -35376562633830633865373733613765663666393535633737373139643437383562386363333639 -31623365646137313636353131356638323064386265393039316464373635376134396165366434 -66656361356334633061323235646663323837653830343939613839333137363337363232623336 -32316139316134653031343665373765643366653662353438653430363231346230313162373537 -34643162336665613839333135663138343639363363663161356263306461366365373038366135 -33613439336331653532333038656434656465643433396232623866613265646339383865623361 -37356534346461303862303963653361393535623566396162363638333935636166623466313134 -66323034396437363766353437396536326463323933393336373062623861343730333465616463 -31333338356230623833373363386633373039346366646361366431613233303065313530386639 -32636438383336613638343833616536623531616233363564333962633062326630343263346432 -39616666363335373236376662393636336266326662653434663435356339653936616132396265 -32383763343434666664646339646466343937643331633032626563663731613131383735326536 -33653233636461363932353163326664653830656232383332343263643562323034333733636630 -32636464373832376531616235626230666336393335323533633561623036636566363332353939 -31333535323038376665393261386437306366343135393866343333623534326338323230393237 -61373236666362303731656464633935353164663164306266373562666634356336303339333565 -61643738663238663133333961346537343564343233333865366535393765373634653438356533 -35376263353236663930336461363935313566376166356432396664636632386163633635336139 -62323965613132313639326465386237366539373331653235383138653564316536363565643862 -38616135613734326136626534336432333831663634373539383663653262313062353731306236 -32366439393131653766366632373063323961633736313934643431656535653963333331366232 -33313436353231393837326334653238316635623865623936313431373761623337623537386132 -31376538306139623565636636383236636261376638303164373338663665386334356431653935 -31393436383264396234643861363466306161313465663361393236663463626231663762323132 -63373032613133313061303137616232616262376566656163373566333232336166383138336263 -37353263663361643662336139613438376131373562633439626331643263366233376665376132 -35633063636664653264626131356461646130633662666561656264313231313036363237646336 -61336262653132633465353266646638373138616334376632346437373638376662336535323339 -63313835303266393065363334616339323062366439646535393132343336373463306430353431 -33623532636665356632666434643535333635643564373861316530643034613135633335353739 -36306335373936663638366164363862303464393962326565323030303231353966363338303031 -66653863383831353763316432636366356561353465653561313735393435646432653231303566 -39326432346666653861643363323465326432353962663630303461346164303436653230306139 -65363439333561386434623463623963643763663963636464326633613138336138393461623331 -39393730303039303361386332306330653764316139356363303630316537376430393865653633 -64333965326433346633666535326236656637653333303664646238653630663436316336616463 -63343635326162366163343630623839313438356466646230353934366139313438343964326563 -65343734636334313239316263616439313935643132313363646331393464643737656536316463 -33376635383465396331386166653366326163656135633764623461376636663939373037343538 -35653339323966336330393761393736626431363039316361323733663865366138373330393362 -34616565333133316235373233303063386566396561613033643132303539663638663765346638 -62336234363739616231383739653338376266346633393139613766613039633465323263666430 -30616633323938653337353136306564613064346332383265666166306531613431383562393434 -63353332633464386235383565343139623831646631663135333665633366373533386633393338 -35623631646130326562636162333065333938313766633230353765326133323433333734373238 -34326434323337323362316161366138313262666439313262663338653938386331323463336465 -32613861623064306337663264373539326534363161383038336237386330616366353061623031 -33353838323030313838656431613036323338336139656433306266386638623838336461386635 -3236 +66643834353263393963313130386431346332323035653363303437396534653237383863396162 +6532383339646435656364666234383433313562656332390a393362366136613735663934393238 +63306538633334333938336361363530333861313463363835356134376162343864656634626164 +6232353333313438380a336432666635303766626436646465653530313164633530306164306634 +32306361646563646363373563313037343333373037363166303539383761633465653462633134 +37306633386564366434353338383765623164656335333966613965653537653233383963393131 +31353865333238326366346661646366336535333763323637303330393831396336323238646336 +63323464646636373766616632323239633266346533366334396132393633633131343530393361 +33666334346565316561653563343265343536323833313865663730646164343339316364373465 +32653336313265363039393464626430666438633264346562663465396364356233653563356466 +38373239343335393662316461326361626134363663346535653630383339636339333564366137 +66663962623337626164323036383063343639626166323937326335666639626630656565353932 +38326135363238633537323734336339303438373365333937653563636432656432643138633363 +38306435363865363530356462343339323862653063643930666161323937663366393933396664 +33633534646361386531346461366134353666653938623264383531303839303434313962373163 +33323431393061353834633833306337353432356461386432363338393364653733346564613634 +31336635643838323835336439363365333338623765646532313366653930346330353238343866 +37656635353461383838623938343465616433643763393232303439313963363838306562383764 +65663330393163323931363765626566646432366133636230663461346565646165363035663637 +30356231343930353034333230356265633262653961643431376336633834353639643736363962 +36303135646333366230613738316535323636656534626462373566653136636535313265396431 +64326237316532303761393664386337323435366539303663633839333366373361313063383432 +38653737613866626365643630646634626263393431623430353162663562636166383662383938 +32663464376161393639396166373165306466616533306439613464343737623166646462633039 +61336638663566646264386463663232653036366639666131313237333064666663633035663261 +64313865633433313936613933376563383130623538373761626164366433343430616139326134 +37356138346166626462636231366534376539336535396139343339313938333537396330313632 +62366239363165613562323763373765343938613337633130333537623733336332356433663934 +31373635356234616362333836306266616162386663316561666134663736656566653562633330 +32666233616464623738346561363731636266386135363831323938613031396161656233626434 +66636337663739343366323037323161386131373932333530656534316436306531643935663338 +35303465633934313139663236306434323664363066356136366130336433653433663461336539 +39363034646138346436663435316136383139646566343934383935316133613535313261306138 +36613966623135326433323232666235336533333132613262336438633138363839346234393039 +65313161363837373434303464343430376335323632363166336463333530613230376239636439 +38666166386666393935316133326466326531653066396231613166343830653864636665663761 +62326637626139613864356633333063353631396437333264373638323063323632366362366631 +30353938633633613232333235386230346238626431653030323664323966386661313530376361 +64636364656631663865643437383635643138306239366165353237383263613563646430613231 +38343138346563363338383765336230366631653931363964366633333861626632313030326233 +39353339613566613333626266656436633066633939613337373437346634336133393136353132 +66383035633363663537323437373630383937326432323130393863353335636666306339363462 +62613063393161383936336134383861373439636366643661656237343334316163633563323164 +33356635663333343534633632613732623831653130616239386537366434656561653136633766 +30636665386531373631323438343833646632303330343865343535663635386166333835353833 +36366432613734373732383431326561326234316535346433343363306338623537373034386665 +37326231633532656137313332616266386364316431346130646266666437623935613563626265 +38636136343864636533383762303261643737626338376335623930306465653933643534356133 +36396435353162366363383538363666653663383836653563383637343566303834376363373035 +63346338616436306133393163613237376434633037306633623665396463396433633339653866 +38623536303266343062386535353230343862393137306265353532356130313162636232616133 +33626435323139396535386135653035366633326630623931326531383964306333626635393963 +32376333313434633664353561613461633431663839623462313566336130363933313335396633 +64313437666663306134396231633261666137356332376162323636326135646639613132333333 +33336337386633343330343264313535333634663830366633303862353436353136616639326433 +36663936393861323064373237643862653732323934613366356535303935373430633032393632 +36303136653064666235663062653339356635636135333966666337346665323964383031613865 +61346436623539376137366362346435633833303833303231653038643765383234353132613064 +37643839643732373835313637626537613239393266343332613732316631643633653462383837 +63376430666631643962343337306666623639653936323662396165613837396664303338343830 +63626439356432623663336363613930366564303239393935643732333430376432613130623732 +33663364306366366232353034323439376131373366643634643166376532316531393935373833 +65303437383164663539316535636263333638383438366131323466353236373263643331663239 +35636432376139326265636162336334393135326131376464656536373764336362396164636231 +35363832626436306633343338383737383334643063343165633965323239383235343935396532 +61646564643331376339303530353435323539663930353333303734313135333862306636356439 +37623638633533613238303633376366643636373235306463633537316635336632653563666635 +34323833346437656430346531643265666561633461353635323862613261613337633563666632 +38636437656131343132313830643335383163333935363231636635366232363235316238666364 +65363464626463343931356634623864663539383539613765316562623933373762373738653435 +33313536656634346262396530336434653763626535363764393966303536336263316635363136 +62333039663361356130663364343739626239333961646165373362386438356466373266643665 +31343633303536373038366531393866313535623264626136366233393039393837346434656131 +37643033646430386634623162613030393262356538316336666333653063643538616662653330 +64336661386236653438366366303535646431303133666365313231383839333539356562656361 +65643563633163373531343634373433386239383366326564353137303133366463323465306666 +61323634666266643939303838623936323537646130326264383561643730343538663464333135 +34623737636632663831306330323734376330656133623533343964626264363564366636616537 +62623166656361663863313663666334343363376531396664363162383763613466656261623164 +66326331306664306533353562613765386435643562303339376564633433333431653262653738 +63623732343238373365643362356662663836383139376661353233373535366131313130363935 +63616162313734653061646332393233333432313431393335616663643364316165646532383038 +33383163393539303463666335333736646265356661616131333230306630633937313830353361 +62636634363338383335353364383134343562613162343433393337346432643061333866396637 +66386434623032643663306461383337356361323239633837376165663231333363356139346530 +33613535393665616432306435323363616539303665653734656561366162333962323262373561 +65326134343261653462663266623935343231323639623435643430313630653530323433626237 +63643837393134336633663065386432383631343638626535386362636136636166616365393530 +35633839323331626131623731396134373037356337626263306337653364303366616466666233 +32613264656239643461353137383664626665306433306131356537393861363961363861663836 +35366634336338323732316565663730333162353833383934386434626230613530633063383137 +31613532326265353437373533363132353632383261633537653763663832373964623636393763 +36663833306263656139343535343262346430323931663135373338616138363236633230323230 +63353431303964303139303462353161336463633630623236346635333862306362363463663230 +61656339366432373030633238633863643535366434383838396632646531366664303761373338 +65336562356230626631636165373661613861656264383030306330663830663835626666333637 +36303130636130336235306463313864316363343635633331626632343333393564366562613639 +62636530663139666636323766626563616238356562393231353266653961346563643464633266 +39346361623732613966636463613935646434333330396230333836306530616438643661653834 +64363930643332663262373664343938333562613938663538313166383039303864643339646163 +35636638396265396263393037633064383136646635336335656430613163613738643431383163 +35336463373931306334653664363536393730343439303534316664623433623463613239353230 +62326632323536306363656235653665303630393437383164323535303931653963643662613434 +33613761303039626531396139376161623762613531323964653561333462343865356564393865 +64663365626366346430323465626436346636643337346135366430663862306137666463333735 +38343438353138643435343538393461393763613232376664343934353262633365653138613763 +64366430656436326536643736353839653330656136663761346238373862333163393737306632 +30616437363163343034313933356337363531306337326134633637363530653764316534343364 +39306463346465326432333964303031616465336361366436303130333534613633316532323664 +32393830613364343935343665386264656431626333336466306565323563636432396164646233 +61306637623461323238343466303862663165633737323936366130383863373062356539626437 +30366338666233383066656532636138316662666630306138363735626464363431313533383364 +37323936386537363563353565343364373466343765646231323337636266333961363866353131 +66616665623835346234366161343830363061366139343633646166346562313432323639653839 +66396139313662633930383732393062306639313566653538653666313735376135353337653635 +61353466316439323664333838346131303137323761653630353533313435336461366532626166 +30356239366137313430363733396462663533613366376234616135306636613664336566303032 +34653536303563626566646233303666303838353336326438656466643361653936313030366662 +34613537303238303931356437656535313231393165643430303938346663303730336362663632 +64633165323637366263316663376537373930333036616537323535633734353337363964333931 +65356662396239383665306563616465626633626339643139666564643036383566373236663339 +36666436303830616438303037373631656164623935646261313736356163383936383565663235 +39333866386339383663316432326537313934343032646536663936633664623834646365303661 +31663863376665386536666236376361633234633664656162643035373439383235326562636635 +33306366343135656561363761356330306166303038636464366537613863306235353362623730 +36356132393934323136376636333264633030303062623064363566633365646230656265373236 +31313930366466373939383365666239636235646661633863336139366234356331653563633136 +31613130306132393165383338663637333062393537646238626338393938326130373466653332 +31323566346130633930333161323362323933653138656361323262323335373763623637353161 +65663663383433333363376664313537633662313166346130663632333736313938363634646633 +38623135333831666631623439356663663961616630323534396435666634353435363536313138 +31663336393232643064376464613830373434303234383461316139343864623866346665373036 +65633163353961396433623363643833646138333666316665656566636138333539353236353236 +65616363643963646533616639643432313262623163633035326334613161323666376364623065 +64396331353861656533303635343538373431663765306161316234343462666165326261323963 +36313764616230636139613263336366346239656330326162353561343237386537366461623463 +36346439613330626134323364626232623461633830326338663363306239613735353561623162 +35343763396265643562623663373463623032373439363236616465373163353134373366346361 +65613761663933633031373863393733613862353166653935363938353266343566343434363137 +32333532343830323835616535313231663630313766356134373234346238373732373465306461 +37613836326162373137646365616234303364646437326165666434396563323262326238323362 +31636331393833616365373933376662666530316138393262306432323139353039663431616431 +61636337323536343738306236346230623365396638656232323736643262346663313562323236 +37353931326439363362633834646534633235653238373036323330346461333135663330396663 +66653261333330653336373435316366363666393830636363323165663838626130333366346561 +38373962663338646464653135323337303730623430373763323135333931336163303432313663 +36353435303965386438626136623565353264353964656131363862643535633737363439613261 +33643935623865363564396635613261363237623237326338353766393763636230663961363034 +66366163643937653261336362636630323132316433363231323230323532663430656135623362 +61386435636130623035356639336238326534343762306439386338323334666664316164343565 +36646335363632313737373961363662626662396266333235313833346661653461616661643634 +38623333663762303635626332633137636461623434396630373463383538383462633766356135 +61363962316161336466363531343938373233633632663539326462613436363837323130663131 +3664396664633038626432396164333938643936363565333333 diff --git a/ansible/playbooks/site.yml b/ansible/playbooks/site.yml index 7ea71d5..a0016fb 100644 --- a/ansible/playbooks/site.yml +++ b/ansible/playbooks/site.yml @@ -3,7 +3,7 @@ hosts: all become: true roles: - - { role: docker, tags: docker } - - { role: certbot, tags: certbot } - - { role: nginx, tags: nginx } + # - { role: docker, tags: docker } + # - { role: certbot, tags: certbot } + # - { role: nginx, tags: nginx } - { role: deploy, tags: deploy} diff --git a/ansible/roles/deploy/defaults/main.yml b/ansible/roles/deploy/defaults/main.yml index af0bd51..6ed49c9 100644 --- a/ansible/roles/deploy/defaults/main.yml +++ b/ansible/roles/deploy/defaults/main.yml @@ -1 +1 @@ -project_root: /home/user/project \ No newline at end of file +project_root: /opt/projects/trackntrain \ No newline at end of file diff --git a/ansible/roles/deploy/tasks/main.yml b/ansible/roles/deploy/tasks/main.yml index 3e9baed..c17e6b8 100644 --- a/ansible/roles/deploy/tasks/main.yml +++ b/ansible/roles/deploy/tasks/main.yml @@ -19,11 +19,11 @@ dest: "{{ project_root }}/{{ inventory_hostname }}/.env" mode: '0644' - - name: Génération du fichier prometheus.yml - ansible.builtin.template: - src: prometheus.yml.j2 - dest: "{{ project_root }}/{{ inventory_hostname }}/prometheus.yml" - mode: '0644' + # - name: Génération du fichier prometheus.yml + # ansible.builtin.template: + # src: prometheus.yml.j2 + # dest: "{{ project_root }}/{{ inventory_hostname }}/prometheus.yml" + # mode: '0644' - name: Vérifier si des services Docker Compose tournent command: diff --git a/ansible/roles/deploy/templates/docker-compose.j2 b/ansible/roles/deploy/templates/docker-compose.j2 index c506986..d2deec7 100644 --- a/ansible/roles/deploy/templates/docker-compose.j2 +++ b/ansible/roles/deploy/templates/docker-compose.j2 @@ -4,11 +4,17 @@ volumes: {{ grafana_volume }}: {{ prometheus_volume }}: +networks: + {{ docker_network_name }}: + external: true + internal_network: + name: trackntrain_internal_preprod + driver: bridge services: postgres: - image: postgres + image: postgres:17 container_name: {{ postgres_container }} restart: always ports: @@ -19,14 +25,16 @@ services: POSTGRES_DB: "${POSTGRES_DB}" volumes: - {{ db_volume }}:/var/lib/postgresql/data + networks: + - internal_network minio: image: minio/minio:latest container_name: {{ minio_container }} restart: unless-stopped - ports: - - "{{ minio_api_port }}:9000" - - "{{ minio_console_port }}:9001" + expose: + - "9000" + - "9001" environment: MINIO_ROOT_USER: "${MINIO_ROOT_USER}" MINIO_ROOT_PASSWORD: "${MINIO_ROOT_PASSWORD}" @@ -34,13 +42,29 @@ services: command: server /data --console-address ":9001" volumes: - {{ minio_volume }}:/data + labels: + - "traefik.enable=true" + # Console MinIO (UI) + - "traefik.http.routers.minio-console.rule=Host(`{{ domain_minio }}`)" + - "traefik.http.routers.minio-console.entrypoints=websecure" + - "traefik.http.routers.minio-console.tls.certresolver=letsencrypt" + - "traefik.http.routers.minio-console.service=minio-console" + - "traefik.http.services.minio-console.loadbalancer.server.port=9001" + # API MinIO + - "traefik.http.routers.minio-api.rule=Host(`{{ domain_minio_api }}`)" + - "traefik.http.routers.minio-api.entrypoints=websecure" + - "traefik.http.routers.minio-api.tls.certresolver=letsencrypt" + - "traefik.http.routers.minio-api.service=minio-api" + - "traefik.http.services.minio-api.loadbalancer.server.port=9000" + networks: + - {{ docker_network_name }} api: image: {{ api_image }} container_name: {{ api_container }} restart: unless-stopped - ports: - - "{{ api_external_port }}:8000" + expose: + - "8000" depends_on: - postgres - minio @@ -56,60 +80,32 @@ services: MINIO_BUCKET_PP: "${MINIO_BUCKET_PP}" MINIO_BUCKET_USERS: "${MINIO_BUCKET_USERS}" labels: + - "traefik.enable=true" + - "traefik.http.routers.api.rule=Host(`{{ domain_api }}`)" + - "traefik.http.routers.api.entrypoints=websecure" + - "traefik.http.routers.api.tls.certresolver=letsencrypt" + - "traefik.http.services.api.loadbalancer.server.port=8000" - "com.centurylinklabs.watchtower.enable=true" + networks: + - {{ docker_network_name }} + - internal_network front: image: {{ front_image }} container_name: {{ front_container }} restart: unless-stopped + expose: + - "80" depends_on: - api - ports: - - "{{ front_external_port }}:80" environment: VITE_APP_API_URL: "${VITE_APP_API_URL}" labels: + - "traefik.enable=true" + - "traefik.http.routers.front.rule=Host(`{{ domain_front }}`)" + - "traefik.http.routers.front.entrypoints=websecure" + - "traefik.http.routers.front.tls.certresolver=letsencrypt" + - "traefik.http.services.front.loadbalancer.server.port=80" - "com.centurylinklabs.watchtower.enable=true" - - watchtower: - image: containrrr/watchtower:latest - container_name: {{ watchtower_container }} - restart: unless-stopped - command: - - --interval - - "${WATCHTOWER_INTERVAL:-300}" - - --label-enable - - --cleanup - volumes: - - /var/run/docker.sock:/var/run/docker.sock - - grafana: - image: grafana/grafana - container_name: {{ grafana_container }} - restart: unless-stopped - ports: - - "{{ grafana_external_port }}:4000" - environment: - GF_SERVER_HTTP_PORT: 4000 - GF_SECURITY_ADMIN_USER: "${GF_SECURITY_ADMIN_USER}" - GF_SECURITY_ADMIN_PASSWORD: "${GF_SECURITY_ADMIN_PASSWORD}" - GF_SERVER_ROOT_URL: "${GF_SERVER_ROOT_URL}" - volumes: - - {{ grafana_volume }}:/var/lib/grafana - - prometheus: - image: prom/prometheus - container_name: {{ prometheus_container }} - restart: unless-stopped - ports: - - "{{ prometheus_external_port }}:9090" - volumes: - - {{ prometheus_volume }}:/prometheus - - ./prometheus.yml:/etc/prometheus/prometheus.yml - command: - - '--config.file=/etc/prometheus/prometheus.yml' - - '--storage.tsdb.path=/prometheus' - - '--web.console.libraries=/etc/prometheus/console_libraries' - - '--web.console.templates=/etc/prometheus/consoles' - - '--storage.tsdb.retention.time=200h' - - '--web.enable-lifecycle' \ No newline at end of file + networks: + - {{ docker_network_name }} \ No newline at end of file