diff --git a/Makefile b/Makefile index 5044259..c5c9157 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,9 @@ bootstrap: qnap: ansible-playbook playbooks/setup-homelab.yml --limit qnap +dell: + ansible-playbook playbooks/setup-homelab.yml --limit dell + services: ansible-playbook playbooks/setup-homelab.yml --tags services diff --git a/ansible.cfg b/ansible.cfg index 98fb2e2..dd4497b 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -4,8 +4,8 @@ inventory=hosts.ini vault_password_file=~/.vault-key host_key_checking = True enable_plugins = linode -private_key_file=~/.ssh/ansible -remote_user=ansible +private_key_file=~/.ssh/id_rsa +remote_user=cianhatton roles_path = roles collections_path = collections ; TODO: put the filters in a place that makes sense. diff --git a/group_vars/docker.yml b/group_vars/docker.yml index 7904b7d..d5e8b0f 100644 --- a/group_vars/docker.yml +++ b/group_vars/docker.yml @@ -4,4 +4,6 @@ pip_install_packages: docker_users: - cianhatton - - ansible + +docker_service_state: started +docker_service_enabled: true diff --git a/host_vars/dell.yml b/host_vars/dell.yml new file mode 100644 index 0000000..729c9da --- /dev/null +++ b/host_vars/dell.yml @@ -0,0 +1,45 @@ +--- +vault_file: vault_vars/qnap-vault.yml + +portainer_required_templates: [] +#portainer_endpoint: 23 +services: [] + +docker_compose_services: + - name: minio + definition: + version: '3' + services: + minio: + image: "minio/minio:RELEASE.2023-06-29T05-12-28Z" + ports: + # The API + - "11000:9000" + # The web console + - "11001:9001" + volumes: + - minio_storage:/data + environment: + # specified in the vault file + MINIO_ROOT_USER: "{{ minio_username }}" + MINIO_ROOT_PASSWORD: "{{ minio_password }}" + MINIO_API_ROOT_ACCESS: "on" + MINIO_BROWSER_REDIRECT_URL: "http://{{ ansible_default_ipv4.address }}:11000" + + command: server --console-address ":9001" /data + volumes: + minio_storage: { } + + +ansible_pull_path: /usr/local/bin/ansible-pull + +backup_directories: [] +cron_hour: "4" + +# docker options +#docker_daemon_options: +# hosts: +# - "tcp://0.0.0.0:2375" +# - "unix:///var/run/docker.sock" + +docker_backup_host_backup_directory: "/tmp" diff --git a/host_vars/qnap.yml b/host_vars/qnap.yml index 07ee021..2fb36ff 100644 --- a/host_vars/qnap.yml +++ b/host_vars/qnap.yml @@ -22,7 +22,10 @@ backup_directories: s3_name: paperless-docs cron_hour: "5" + +docker_backup_aws_s3_encrypt: false docker_backup_host_backup_directory: "/tmp" +docker_backup_retain_count: 3 devices: - uuid: a54c1bde-1400-4975-bf24-08c603ca3a11 # /dev/sdc1 @@ -119,8 +122,6 @@ services: - name: paperless - name: gotify - name: diun - - name: ghost -# - name: minio -# template_vars: -# image: minio/minio -# tag: latest +# - name: ghost + + diff --git a/host_vars/snunmu.yml b/host_vars/snunmu.yml index a4e714c..210b34b 100644 --- a/host_vars/snunmu.yml +++ b/host_vars/snunmu.yml @@ -1,6 +1,8 @@ --- vault_file: vault_vars/qnap-vault.yml +docker_backup_aws_s3_encrypt: false + portainer_required_templates: - source_file: diun-config.j2 dest_file_name: diun-config.yml diff --git a/hosts.ini b/hosts.ini index 1961e5e..cdb46ea 100644 --- a/hosts.ini +++ b/hosts.ini @@ -4,22 +4,24 @@ qnaps linodes snunmus +dells [qnaps] qnap -[sambaclients] -snunmu - [snunmus] snunmu +[dells] +dell + [portainer] qnap [docker] qnap snunmu +dell [mergerfs] qnap diff --git a/playbooks/setup-homelab.yml b/playbooks/setup-homelab.yml index c788421..313bdf9 100644 --- a/playbooks/setup-homelab.yml +++ b/playbooks/setup-homelab.yml @@ -28,9 +28,8 @@ hosts: docker become: true roles: - - geerlingguy.pip - - geerlingguy.docker - + - role: geerlingguy.pip + - role: geerlingguy.docker - name: Install Portainer on Portainer hosts. hosts: portainer @@ -45,14 +44,25 @@ vars: portainer_version: "2.18.3" - -- name: Setup and deploy services. - hosts: servers +- name: Setup and deploy compose services. + hosts: dell become: true pre_tasks: - name: Include vault variables. ansible.builtin.include_vars: '../{{ vault_file }}' tags: [always] roles: - - role: setup_hosted_services - tags: [services] + - role: setup_compose_services + tags: [compose] + + +#- name: Setup and deploy services. +# hosts: servers +# become: true +# pre_tasks: +# - name: Include vault variables. +# ansible.builtin.include_vars: '../{{ vault_file }}' +# tags: [always] +# roles: +# - role: setup_hosted_services +# tags: [services] diff --git a/requirements.txt b/requirements.txt index 5075535..e69de29 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,33 +0,0 @@ -ansible==6.3.0 -ansible-compat==2.2.0 -ansible-core==2.13.3 -ansible-lint==6.5.1 -attrs==22.1.0 -bracex==2.3.post1 -cffi==1.15.1 -commonmark==0.9.1 -cryptography==37.0.4 -enrich==1.2.7 -filelock==3.8.0 -importlib-resources==5.9.0 -Jinja2==3.1.2 -jsonschema==4.14.0 -MarkupSafe==2.1.1 -packaging==21.3 -pathspec==0.9.0 -pkgutil_resolve_name==1.3.10 -pycparser==2.21 -Pygments==2.13.0 -pyparsing==3.0.9 -pyrsistent==0.18.1 -PyYAML==6.0 -resolvelib==0.8.1 -rich==12.5.1 -ruamel.yaml==0.15.100 -ruamel.yaml.clib==0.2.6 -subprocess-tee==0.3.5 -typing_extensions==4.3.0 -wcmatch==8.4 -yamlfmt==1.1.0 -yamllint==1.27.1 -zipp==3.8.1 diff --git a/roles/bootstrap/tasks/main.yml b/roles/bootstrap/tasks/main.yml index 48ce1da..d4dd75c 100644 --- a/roles/bootstrap/tasks/main.yml +++ b/roles/bootstrap/tasks/main.yml @@ -12,17 +12,28 @@ upgrade: dist update_cache: true -- name: Create ansible user - ansible.builtin.user: - name: ansible - groups: root - shell: /bin/bash +- name: Install Sudo + ansible.builtin.apt: + pkg: + - sudo + +#- name: Create ansible user +# ansible.builtin.user: +# name: ansible +# groups: root +# shell: /bin/bash +# +#- name: Add ssh key for ansible +# authorized_key: +# user: ansible +# state: present +# key: "{{ lookup('file', '~/.ssh/ansible.pub') }}" -- name: Add ssh key for ansible - authorized_key: - user: ansible - state: present - key: "{{ lookup('file', '~/.ssh/ansible.pub') }}" +- name: Ensure the sudoers.d directory exists + ansible.builtin.file: + path: /etc/sudoers.d + state: directory + mode: '0440' - name: Add sudoers files ansible.builtin.template: @@ -32,5 +43,5 @@ group: root mode: 0440 with_items: - - ansible +# - ansible - cianhatton diff --git a/roles/setup_compose_services/tasks/main.yml b/roles/setup_compose_services/tasks/main.yml new file mode 100644 index 0000000..a6e4302 --- /dev/null +++ b/roles/setup_compose_services/tasks/main.yml @@ -0,0 +1,15 @@ +--- + +# TODO get volumes from docker-compose.yml + +- name: Install Docker Module for Python + pip: + name: + - docker + - docker-compose + +- name: "{{ item.name }} | Docker compose up" + with_items: "{{ docker_compose_services }}" + community.docker.docker_compose: + project_name: "{{ item.name }}" + definition: "{{ item.definition }}" diff --git a/vault_vars/qnap-vault.yml b/vault_vars/qnap-vault.yml index 396eb24..e00ea2d 100644 --- a/vault_vars/qnap-vault.yml +++ b/vault_vars/qnap-vault.yml @@ -1,106 +1,106 @@ $ANSIBLE_VAULT;1.1;AES256 -33346131346431373431303965313765616363366338653038663434633962653038313463303966 -3735643366623237613639666566336433666366396164640a396536313536366235643139303835 -36356434623531346465383135363461326133353264396533383564303037363535346362393930 -3439656437303165390a613964386438626165396363623637653265396139366134386639363437 -33656562353535313334636235386662643538643439663035616633313431363266623566333437 -39653066316433333331323034346666346232626461313165616662383332313933653232346639 -62373830303663343936306166366231393062336333633832343037636538383433613430373931 -66663764373265306336393562343733653334633638303431306639303032653131303531643965 -39343034313438346164353633356236363030313862326336363235626563613638303630333930 -37306633303736393366336465313561353733666664623965303239353162343334396566313736 -65346138363039616130336163653065386236303561663537623038616336613830636237366235 -36646564643837353166313665623166643935353366653635356266383239636662353237353138 -33326534343033323238666139393765303666396561663638653263393566633339636239333037 -63663764663964656364316130656131366136613761623231623030366164613538643331636535 -31323464343937636164626433323831343434303464303166643037363832613530353939343864 -33633836643361616332336633353036663861333564613630643765393338313135373161333666 -39376266346431383932313766306465396665346234313532666462353938346439613037336133 -36303161313666396531613631333937643162313233383937633665373534383732356138386633 -34313637353265353235323234653263363030653066653135326339623037333962373338353161 -66346261626662363263363461376633356130306534643665643761383638396635613163373362 -34343930366634363736396633343736323135326564373733633361313635383439663766366139 -33653763633739646638653239316332656235646461633638373664343237393963386534343162 -65643461613036383235646234653132356531323638333931306633343062383938386566646466 -39653666643265393739303363363831316535616263323937333662303663643434653363303939 -61663363313930636631356238623732613630383966303037343061616436303734663837666265 -36656530623634376133366531383362326430626438343532376534666534393337653762333534 -64626466643438623836306264626562353333316534353638353664323563366161393237643462 -33633233333362643364653333313434663766366661616233363162643835333830376537393936 -34326266373836613333343134323033343634656563326262303765373736613636333133376331 -33383366303062303834636635333133656232323433616338663164613636353535613630623838 -33393661343364353838623730366532313764383233366265393630343965303631373762323563 -39336263353861663861353339643766356434366564633863336334626565643165633434323234 -35636464356237316265663737303430616262376666323130643136373432316433363463653334 -63636434653162356436343831373134363434316435323465663763333036653166373431373838 -65663665323166343735633631383339306466343832356538613832336434323865386265386239 -32653430353531316462383734653863383033653764363764356662383833363963616635653564 -61363361363137393730373262663838333830316136316430303039353430373466343132366130 -36303364383066393734356330643437633937663836383031386163666636343762313732636432 -64656362333161383364306632343762343434313536396336646231326266323966353964326331 -36353739613838656637346166626639343664663138366335343738306461356366383861323164 -33316363373334383935663965363939613234386537346565353837323436336433343763313637 -31343135303632373161663035623637646638663032366566323763333739343932313439656564 -38366265343233333665303330366631623963326338313961613233393636333466336461326138 -63303434313165396462326561643366623832366639356362623830383561303339623461376466 -35393064303836373231363737326462613735396330626131636530626230656432656130316632 -38353862613262343535626264306433643037323662393535353261616666633339663737326564 -64336331363137646335623635613766313362663432393761336139663635343764343633616239 -65386430643436373231636462323137333138333735643537353838326666326633633764646133 -65613036316434633864393736613239363461383133333030343362353238373232386632343662 -36623633613066333839373465623362353338646436613861303138663830353461623736653830 -31383963306531666164633764323265366430646336343131643866346166323635356665363139 -38396566643263623732633931313963386466333138616465396439363563616366303735393735 -30343263386165656434653739616266353438626535323863313966646335353332393966313966 -39643032386665623764366237383563396336363164386538396237356232633132613566613664 -63323438643163343230303538356332303266313630353065643538663834623033386637653961 -35353763613366653739306532613266346366396538646663626435343465666163613364653332 -34303434346263313465323631386132653539376265323130666235323066626166333132333566 -65386565626234353663326463613630386562346563323763323165356235316439323037623430 -39636161306336306636653232626335346465646334363734396633383034316461393134663038 -64366132336662643931356539353334633331373535383831303931336237653937663833313766 -33316631323231366634646665366538363063363532336463353638616363383332333236653032 -66323532363034333964356238313565626238653961663433366433666666323831326430656366 -65363662303838633262623263343065653236363733326435333838303334353736366165323934 -62386162326363303833633535663631326135623064393662666262353535346361303362656261 -66383264336636663032343430363665376134643730363365396635333261383436613064336162 -35663734363136376664666165313562613930313832623364303166323963303963323431396539 -38346334363064316266336463303539383966363430653730613434393633396331356539333332 -31366336613339646131306631663137326530376333643338386663356563646165626662626336 -32333766656566336639316136316163366535353035643733343763373030626364616334363934 -37653966333134376266636661306261303663623936623133393236663964666135373932323162 -65376234373336363161363731373634643338666534306137666561303835633933353865396365 -31303138626432653439646262623236336664393066303966396265636439363530336135326361 -36663435396230383634633732366230373163666231636430666134656330666239643639616334 -33656230383535666337633561633937343839663938313739343662303164326536333331343661 -63653931353064396364666665393364646332363734316436383831616536656631383161306433 -31636330313662303830643634633464653562393363306532356238366363613239373734613135 -30343735303735323264653432626364393936626234633264643636346630363161316434653662 -36383464653035323137643032343837653134663963623064356337656132373633656239616261 -36303861646231323438303034333234626364633663306330396134633939303862373533323430 -34366661666537306532343035623631383938313136383937643331663964373766616133316138 -62653234653635333231633234663665383966643336353934396539663763343630663532616565 -36396264636431353232303362653638383833396330313636333839663165656533633333353231 -36393533663465363637333063376638653262656439353934373131333963333266373862383236 -61663662633839333736393639383434303562303232336631393337383337623130323232613266 -64633564656435306534313432663835666137383833656234623834386534333037396238343735 -33323939396261353037306665386666326464663032303335383339366364623865656338393433 -62313737393666393537303435626163656662666262346635366432336332366261383836316538 -64623030313230346335316434366333303936313862343565633533353038363065633939333766 -64363362653665363337613235666561326531316565353239316331666336323464356566643033 -38333537623039616336386562633736626635633162393734343536643864363062613930313733 -61386138613332663461636362643830343230643938396439333465363166346362316262653735 -31626332376163373765616633353563313835323163336134383232366433303133666638303234 -34323434333534386364663263343230333962396534326434643564346330316630386162653438 -36323930366139653137613134393864353835616362343865303038346436616338353134346636 -64316632333439363130383362643637363732303265356630303239353630363932373835613438 -36363464626233366565393362306335646530326634663463323131336335323666653461633662 -37346566373861666361356631373837633137303834373865313163363865343762383666313265 -31373965353631313330643662383565353438326161623637343564323336646465636164616665 -38626134636231613335383361303736306430653337323539646563313536336631643733313163 -36336237343836616462663266343466613661393936383035616438353031343763353334666337 -30316437326639636339613263343263313638623035666161383631643138653931643364623431 -64363137353966653035313930373534376264303530353263313861613736613638316539383535 -64313536313635633863656434353865356161386630383465386136353163376630626438643531 -36343361373730613263333361383331633335656137396536393333343261623032373333646662 -3835 +32626330363838663037323939306562326338656437363064633039303663353264623766333663 +6333663439373064326236653133343837366165363837610a333338626337623632366538356661 +64646564366333623162343932306164386432313462373837323064353230376539333835303534 +3930333638316634390a356131353839393433323732386537386365333634313931323038346138 +39313732353236336330643862313164306132303338306233663531316565313964326338356633 +61313137636534643537343666393431633035303238613936643465363230366632346130643538 +61313530643330386664373536326330323335353330396262663331613762303432613863613539 +31323833376166313536643938306439623535623235613663623938373965633930623130383862 +37366231626434376537376465663132663134383439396139666663343032343532343463366664 +39346237303331393666663732366530623731666366393931313539346236626135613231313463 +34383634373838336665663035353664336231373237356137383962383639646461613862396662 +64373338326137376265353262363735643438666436643332376437386363333132386139323566 +38353432333039356236363336376261366362353930316638326132336135346236376133303562 +34616265343165653530623238313261393264616337663037656262653139646535646161386666 +61336636656231613637323864623938663262373837623035366236316662323137333461383036 +63376131393161356337656638353263323362336237663562323663626630313266653531633632 +32373631373638623965653337333531353935323134303833666364333137646430306436623330 +66663965663565336130646534373334313437373837326332633834393130613963386437646465 +38303562626661646463623361333464393435636638656266366333326438656333353762333766 +30376330343735363066656239633332323961616364313264666635613139383131623736363930 +38633639336166356433336237393366306137303161656333636636613562323639346239663339 +62653562373066613361373937306664303565656134626539343262626132633038333038643631 +32646434336436396563373732373337343361633861656664383464623064616463623764643131 +37386432366532343439363630376436316232363761663533653330623561386334313734646365 +61313632376338383331663238303536393936343261616361393466353038646566366164303161 +34393737653265303364663163336335653532346365323139333639646564636639643639383031 +32336465353364383430383432636335303636626365353135396562636463316139396237633435 +35326630376437636630343736636338636166663736666236363937643864353238323333333737 +31613666316366653765333930303738323338346164306366616563653065393131353464353035 +31626532613735666639353362306334633538353339303232366133613834373930663933373836 +66363335353634666631376564373065633162613533393737626533616263636634633832373338 +33633936663736353739333261656263313061346565613063643032366439613366623164363032 +63633333343639336563323335656633646230633836616663623466333564626436383638326266 +33326231633634353763623836633730623732666334386132303935313339386561613930333332 +36373537613239643764663761356631623533323330323533323161356364363566653733653761 +37306562623662316463343664613161333362323834373832646262353830613131666561663864 +62323738386432646534623739626566643533326238363366323565623264633332666239343233 +62346430336533616562663436643533656638636437653136343337383366613562656165323330 +35313864623564643233393961353536346262323466326465303666623239663166616237643836 +36666665393537323236303834313934373933333265643165663136393863643537313134386166 +62326162303438653063326430333066613836383765333261663934303863636465653932616364 +39366433323237656664333864353164353437313436356130303862613435643433656530383039 +66306632646639326662396634356263333564326335663863636363613536616538656163373534 +66363538333032366131356437306334336663326130313033316235336639323835363861323139 +62663333646537383730336562636636613264666466303634313736336465663437376564666438 +61383534346635333163656465646631353333646565383230373965633930613131363564303831 +33323664663431396664646262663364356333303230336262353836663062373930363130643233 +64616434613865393366363739666464363938313536636566396239666464333264353330333261 +30333331616437393566326439373064313735336161323439323564383036373633363136623963 +39626339643264376665633239653163666433323837376364396365636536366466333361653336 +30613032643865643536633166316561653363373830363636666461396266663333303166616233 +31343939663834316234343833336534666430383834636630303837323866643564613764313237 +34656661313762386538643833616461643838316536326636663337363539366337313465386133 +36323266396332363362333638303930393135623366373838323731326165373435353661613633 +32316439646336306563663639656236656536303665363038613831626362353631633330616534 +64646138636431333634393433303261386265393432626161363965633862356132396439616634 +63336131343362393637333935313338313539633263333830316466306461393761383763336263 +34393064346231626164323365336335373063353230376237313935653636313339373565653639 +33656364656562376364633231623137336265396136613130633639316337383663313738623764 +30326236626434303131356162626338363064643333383163653163643934326436646562323266 +62393963343465653439323532323434363333633439653164666232306235366564656631663863 +31363930623539326364363139303136386664613865383132393566636461343063353762626266 +37313430343732313234373461303565623136386636626563383366363339313061383439353562 +38646533363864613530623365633339353831336263303165636466616330633637366332623062 +32346136376531313839636436616536623937336564303838396262326530623739343639363139 +66643331313933646463623761643537643061613661373162616232303639613734336665333730 +33613132666430353965333466613264303830343433333461653132636330633861343962316339 +35646366613532333065626130663430366465616631393239343766396132353036623836316634 +31303134343161323334653863636134393463616437306263393130323865303531653535613061 +63316666336165643065323364633631666331623836376566343564323862626639613065393165 +35333333663366336365336664646237363733653535373165336664353031383138383532653134 +31623463306334383266363465373865653731323739383362363531663730366438656333623561 +34323730303439643766663439373631363863396539353237663537333162623538613561616531 +36303031343633303734323064363237633662333331306531646336613834396166613262353466 +62383037663337323639396636363134366635396137386431373736643336343836326361376462 +34373463376264646533393261623236613339323432323939303433303662626364336438343362 +65373634623337623661336331333833356261393537323939623833303333303261363436623563 +65316262633832353035323664646364313464376566353563336561323338666134613661633832 +62366566303234633830306162376137396530646431653164646433636162646234653762633166 +39383331353039363630343834643561383839306162363138333733343163313739323730316431 +35363933313666353439303563633938613966656465363435326136353932643763393734373231 +36353634333864303263626230633866656363366663656266343232356164616162306136383932 +30623963323163376237616164333237353639363536333330366565356430663262633330623630 +32333639623232636331373931626665333430613466336535643538316232353835346464366137 +31613734313333303065386438393862356261333234373661393936373065633336393135306664 +39373861646164663637616131386566653465363436303837353730363934346464373935363034 +65623939393935653366653431343061323535663561373366356462656130376161613864376334 +66376533323363613532366437326664383632333439356637666534616163633633343636313439 +64383461663230313237646635326539323133613162313038393637343236333234363964313031 +65326166323261396366666262613466313033333038623730343963393532326366313563363561 +63366165616566643466623033306266356337306437326130636630303632633465313536383962 +64326166343762383639323839613962613930663763643162646536346364396335306333636536 +63326233323839363365356532613261393136336630326166623065393932373663393436386535 +39386636633039303764663830376134613634376161393930303332643737336661306161343265 +36396131343466356337313933633433383531353639633735353163303263613239393764393237 +36303935393533663161346434643035386132613065336662383639383962623335343636343666 +32356335326430616262373265646435633761313564376464653730626264346633343330373734 +31653933626339636430373435326238663963613631376564613232383764616133313064663836 +31333261646463643733306338623761303662346534353166303361656465363762653463303239 +35653338303031313933383363316265643264636535663261623836306434383236373164656363 +31303132366431396131383938383063316130666130303931383738333262616637323133396165 +38366230626164623765333634626239653139396164353335323438663930353465376562643663 +37316137623530623861313134633335623632373963353264313461623935313538643138616638 +37656533663065663530313832343564323634623834626139303234363266376336623437643534 +3461