Ver código fonte

[photoview] Add photoview configs and breakout nginx and supervisor

Colin Powell 4 anos atrás
pai
commit
0789309c42

+ 100 - 79
ansible/group_vars/jails

@@ -1,80 +1,101 @@
 $ANSIBLE_VAULT;1.1;AES256
-66326566646231343863343161373133356630343835306665636339393332643562653461306432
-6533393936666132323237396139343038343831336139340a393962373862383634646465323063
-65303736386531306332643033343531356531343462373438633631356266353837316237663433
-3965623964356434380a623862386337623439643137386330333238633334303939666235643366
-36353833623761346432663866346163633962653465333033636438663964633333343634303434
-64343634303031393935646431326233356136383534323964323266323639383331666364393436
-65646635383533636363653162626231643864366232383530303266626566303963653532646165
-32303138643337326462383836386432633162633038646635316466323334383231326261346338
-31323834393831393562303630363534616435623435396161663765623331303630336664643139
-64613638623834363434333939343834636139393561396134306130336638643433666637353862
-36653764373037376662636261623132643435633430356265303130633963343563343764306165
-31636663303362663633623233623162363366386465373434393530663665393638383739633237
-62623134393134323133653239346362643862663261366365643533326436663565663464336632
-64613566623634336265346132356133323538393537363439353465303633356362613133666137
-66643337613331636337613033653861313164323462373235343330313866303265616230383063
-36303830353835383963373333623530626662636631363631333238643631643539313530363830
-34666461353534396663633961356133663531643234333461333838353331656237313364366432
-62303665326366656635643432343534376233343532653362393832373266323537393936346338
-39633465653931373636323462306133363236313037303862396462346638343637316231393733
-30623931396431613965303232313639383235653566636261393338396364396337363261663635
-34646338333634323330346638303931343064316231643236353362666264383834353336353365
-63336136363737313332393830633961336535626134373538313739346332636537633139303232
-33643366656138613836343266303131303531346535623963373961306436633137306366623064
-33336662636661323131326139353638353834646436306432326364313938653537383137366633
-39316534633132393432656466313434353065623965663435323866393766633539633930316532
-32393839353738323136353437663331356535356234396138353137396133633033343630326662
-35303866353262346531633464333338393236393338326139326430373633613863323961636236
-66336236646239343635333161613561633733333130343834646130313132666562383262333563
-33383439383733643632366462396532653363323566343937353430396437613965373536623766
-61663230333162306332626132326638373030363637363161366131386138373362386634613361
-37613265373237633432626433333331393837363638393834613137376631666664623334373137
-61316237656635356566623732373733623062306433663064356632393061396330323533313931
-30306334613638336230323966643133343263663337636563646132616131656530303865366566
-63373061623963663232356338373232633035643339663232636438666136373761666439363930
-63636434623632633765323963343636333761626366653331636433623134353564353861373838
-33353666653666373531356465373634313064613663356165616266643165653837616239366165
-63633333303762643835626564346464346633326334343637663065626162343264383137613563
-33333963646533383435313065376239323863323166393331346466343036333564643362313731
-32303263636533353834393364666634623532356436623163396666323835613433326430353735
-62386536623861666164303038653132376663343631613038383464333566323638623834653134
-62356464323734326564333437396165396331643632636437633264613331643334626133376630
-31313535313464306130663536366238306262363133306462343761396331653263663263616534
-33623739373330373961656437323266303566626637656435616533343462356561653235643632
-65626333363332666534663662353265393261386537636563316665386564666133623962613139
-37626130363130316435373465626365306366326332333365646234626662303538663938353661
-61383063636332393761323334353965376462653435613531346266313463346136313434316536
-39626563376138326439633463333164316462313761663561623336333339376132323331623262
-31633638393638316335626134336130326635656130346166646363343665316262303966383666
-35343361373261316634636333613663623935353662386533373339353239343165393737643033
-31323266366464376365626265623339336531363737373162333739343630643564633664383965
-33363139333133666137646331363162373066356261306237333838616437323362323663393262
-37313337396231663765393663353364653739633030316663656339313662633038313432333034
-61646162393739646364306534336333626366393664353031353639623434346330353731343034
-31616639656365613862633935633564323764376364333438633861346136373132663235343762
-36396465366666616561316261653037313535393134663838356364656130323137616539363032
-38666334383961653661353663313531626532376538333937643465316438313031633136666334
-63303632376463303465356430653032393166343233373936646330636435646663343532366433
-39356630653335616336306234656335333234343962366331326663363939376332316436366665
-62623939636433396439666662363966663831316362666139393930306465626534636666643434
-34623066303763346235376163383939653738346431326335633033636434623831303562653465
-64303261653335656235363630666631386639333033333364653766323564303263666663646536
-30306362383630306432623061666662383235313436346631313637336261376663653232376338
-64666465316261656235316364636530386262333365333962343166396364343661303766653666
-39313538623365373035333537363134646232633763323565303234626131396631383534626264
-61333962306563373831373535306336653437376365313839343765643130316139386237366335
-35653237616630356337633663343166373735303435636164643737343834646637366261633233
-34333335653439336331396562306439366266633665383639613233633635363061336331616534
-65353064316237643431356564396163613430303632636135363333666265333235306233666239
-31666338636239353034366237643239643662623264653339643765376332323461333766323166
-38373136336134306138326436623339393838363934653931623439653734366635376565633636
-35376233383931656564313465363663303532613035643335623364353563663532396561643935
-33303935643263653732646439303663363634333436653138643365623035356430626434313538
-65646134616335303663363436316634623935326430393933323062666237663566356163653731
-61363339336662626638663237393562633862396165653465633232366335393162343833643663
-33353637643762653638646139373964643435306664356439346335356465353461643135666364
-33373161646434346162376162623533363332626561366561623136386532633333656539656433
-63656438386537653832396339633435373765353930326164663436656232353636626237313431
-34653566316632363438636162343835363066316136376464396261343538323332366166613337
-663330343133323436346337366133613739
+66643035306334376531363763393963663238363839633836663264383835323837306535383839
+6361333031353661336161393735356463366132613633350a333930633632376162393235383464
+39386335323034623064636239653539343364333231303461386336633864353661373236633139
+6633663938333739610a333065376366393731656438343638393933386134643332366230336537
+38303936666631656164303131336139383938613063623934623064663832613365396365626261
+36383136383536303465653362343731633836306161383039323131393664666563623764366662
+34383162353366346361386666643131306634656233386635376166666564336563626161633361
+39376231643831386365623165306531663430656333346137656564313835666462326261393933
+31643834383266653866363762373432373138363234363137633261613735393039663065353063
+65616366666435356563663261393865323431653339303938343738343435353531313738356133
+62376534653462323564353664313438663634303136396637343730626261373837643535646533
+66353432306137363531366335336234656533623333323635613539643364623538386564633566
+36323161663464336530393631333636326437323961333238376564323835626537353165663339
+34336235656632626238326166303861393862633838363065353931633931303437613031373361
+62663838313361633138353431653034386436353032633938333665316165623237353765636234
+61326464393665613064306466323735643936396363373761303738633432316135363436316332
+33326139383764356131653035613735313631666263636166613831323235343232363066663166
+63636433333539616663303062623738613439633261616131306630643031643137613435386334
+39383536313532323134366236653566653033316335623837303065636636643933393039343462
+37313633333632656464613266386330643433373835636461393735353434386536663961313839
+34623738383062613361623430326466386566666462396664343863613264623331363933323537
+36653965386430373239356336373932336166373762386231343838636662633534313131356332
+33613534316239616562653137373039653636353561343932316134343436653561316535303662
+61653936303733306633633839333530356263393064366563373733366163313763353630666335
+65666339356361613136323430383937373765343639613530616565346363366336636364653937
+30386364336162353432656664643438663663653034373538383832303662363130336332353762
+38313561373431623762653637386539393865303262363235386366636138623464646462663462
+65653663356237646138623838313665303366316338356636346436366334623539623266303936
+35326531363936326565613733643236343836373734386438323961626437383766633330653336
+39313133616538306539623862353933353564346131616339643366633164336533633637303436
+63333238303563303065636366326637333330643432393563373036373838383561313561363333
+65616563343637643937353434343635353531346437623366356664393731326639383938653330
+63623832306239653066366462353431616232643735323139333561383737623365343539366562
+37643766663634396539343735613862383766666337343333633766376533666261353965616433
+38666466316235636436653130626237366362316538626530326638643230643037663163623534
+33626135326534376163363836393635356631376263643065623630306632386234616636353765
+33623434313463363033646237356634373433343063376263363865383532373964356530636531
+62326261326133626464643835633532363633616663666562303832333332373739633434326436
+61353630323862363261323565376135383237653035386430633039623263663766653431373434
+62363465353463373762373738396132633532616532353038633766613237383762396536343665
+37353565373266383133353930326561643564613530323165656462366639303966613636326331
+38376362363666333037343365303932353937386663626233373265356662636465643162643531
+38393535326136336339663761643533323531386363303232363739646134623661373632383032
+37653434343835316563656135326534336362623163663832363030393239343233656130356664
+66353961613430656566393063346665326435393739336132333666386665313838323862663534
+33633035333530333438303639646566386537646563636162616434623364393235363165616231
+36306130353436616162653365393935363263633064633461636634336435313333363339623863
+31623864626432373833353038643039343738376238623265666534303139383138623962663136
+61306438303031663863303537336166633335343462383232353130663838323737366366316635
+35383733646336373637323337323432366535373531316433343964373763646162653436353835
+38343737373834336262663166386366663537643137343930353438386433373332306432363834
+66333765376433373363326435376135393030313461376564626335626266313834643736626136
+65336362376532336130313732386264643437353432613035613061373737323036663937626235
+35356538633639623632653730613334323866646462656136363430333732313534353338386436
+61326365356361656630396639353933643735646166373435313131633764393165306436343365
+34343134646563303866363535613335336336633066373136393535343637393035653064666339
+30613165346635346237616163336538643363316235623832616263646561623134656334353730
+39353235346331393532643461376239353732393363326630636239666464643135656631363637
+37393330386438303234663962656166653039343161323965663033336138623037306536636138
+37643134643865646230633362396165643038633165306361626466313635613961346237666161
+33663535336531303037666335613761653264663238623939333934336433343761303530396134
+38336465633238633331626235633935633366373137323934623535623636306236356565633535
+32653239613062663932313631356535666665396537356230306332373966646533383837343066
+35613538616333363066326365633931306666653738323365396336333863363566643730363061
+31633664663161316538613464643164363734663636313530303130343564626565373138626633
+63343930336462393532653463356361623035623138636132366238616261633630393862636630
+31663933363261356263666434383434653136656231306230626438333165633865366135363965
+61653132393336326366623430623162376339336363376638303736363437303934353631396636
+38343432326530633661303035316231616137353033623034333339666637393763326234373132
+62323739336335656232333930303431653862396366616332386563326539656537313539663433
+31636162643963663166666261316331303235343566303736363739383466663961313835323863
+31643239323632393231363963333138643531333061366366653561393638336265613031376436
+32353838383061323639356238326638343231306538396263643933366261336330653330356561
+34613634623637353461353736356235666435643863623565383165383632373664613564333132
+38663233633335613033383261326534353838313139366136383835386436323736623039343962
+39333336663731303337633333616361343564626339633731626564393664313264303735386162
+61396133363636646232376465366666333234386536646238666436623861383930306635323362
+32386263666635613266366266343137613735356561303966653365313466326130633730383865
+34343264326661383131623861396665383064356137626132333064313330616132343164633637
+38383165633364353938613965626466626235303436653863373139656638656136353639373365
+61646261633034346232623664373761363534386630333639623962323263393237336438663164
+39623661333565386537326433303538313536386333323965343733353436636562363133383736
+36623861386533643137663264333931383231346437653437386139343965626335323639326333
+65623839353962313234326139613331326632383637363634336437633732616134363330326135
+63656538663166373665663964356635646339613061643361363635303034663330316162323335
+34616137356437616565393934363732636138616635623839656162373565653234663362303635
+62646465653634323765626130353431316339616561393831313663326538306464373431663839
+37353838386435666335623564356537653932666537643434643265666265313732316236366264
+38333365393635313734663532633466393532616539313138633034646134393434373232346530
+30633039313162316561343461346362646439326233613435393961623965343139653436393638
+64333335393634313235616463633039616635646632623762386430626463653634356530343265
+30356530623061323537663461656361303739336361313330653133376566363632313136616132
+63383565616263393364633136313666306563323634376465303161333130383536656564613132
+62653164386133643638386432366433373239613164336435343935333063323864353635386433
+35626263363839366139643737636233643737373736333466613763363339333465303865326639
+33643732306461313731303134636538626466616339393139626334313530396339613138363933
+37356334666166333235633736383836366339343366323938396439646236396438613032313636
+32383334646538303931343735346663613338386366663234326265313730356162626366636662
+63656463613532353237366330633862666431333130373738333865336166663537353638383038
+38653661613839376463

+ 5 - 0
ansible/hosts

@@ -16,6 +16,10 @@ weewx.local
 books.local
 photos.local
 podcasts.local
+192.168.1.81
+
+[test]
+192.168.1.81
 
 [bhyve]
 mopidy.local ansible_become=true
@@ -63,6 +67,7 @@ weewx.local
 books.local
 photos.local
 podcasts.local
+192.168.1.81
 
 [mailinabox]
 box.unbl.ink

+ 25 - 0
ansible/playbook.yml

@@ -1,6 +1,7 @@
 ---
 - hosts: jails
   roles:
+    - role: jails
     - role: avahi
 
 - hosts: dns
@@ -9,6 +10,7 @@
 
 - hosts: dev-mail
   roles:
+    - role: supervisor
     - role: mailhog
 
 - hosts: invidious
@@ -18,6 +20,7 @@
 - hosts: db
   roles:
     - role: postgres
+    - role: supervisor
     - role: pgadmin4
 
 - hosts: proxy
@@ -26,10 +29,12 @@
 
 - hosts: pbp
   roles:
+    - role: supervisor
     - role: pbp
 
 - hosts: fifteen5
   roles:
+    - role: supervisor
     - role: fifteen5
 
 - hosts: searx
@@ -38,6 +43,8 @@
 
 - hosts: weather
   roles:
+    - role: nginx
+    - role: supervisor
     - role: weewx
 
 - hosts: git
@@ -46,6 +53,7 @@
 
 - hosts: photos
   roles:
+    - role: supervisor
     - role: photoview
 
 - hosts: mail
@@ -54,8 +62,25 @@
 
 - hosts: matrix
   roles:
+    - role: nginx
     - role: matrix
 
 - hosts: podcasts
   roles:
+    - role: supervisor
     - role: podgrab
+
+- hosts: test
+  roles:
+    - role: supervisor
+    - role: nginx
+    - role: podgrab
+    - role: matrix
+    - role: gogs
+    - role: weewx
+    - role: postgres
+    - role: pgadmin4
+    - role: mailhog
+    - role: unbound
+    - role: photoview
+    - role: searx

+ 3 - 0
ansible/roles/jails/tasks/main.yml

@@ -0,0 +1,3 @@
+---
+- name: Package cache updated
+  shell: pkg update -f

+ 23 - 0
ansible/roles/nginx/tasks/main.yml

@@ -0,0 +1,23 @@
+---
+- name: Dependencies installed
+  community.general.pkgng:
+    name: nginx
+    state: latest
+
+- name: Nginx enabled
+  shell: sysrc nginx_enable="YES"
+
+- name: Nginx locations folder exists
+  file: path=/usr/local/etc/nginx/locations/ state=directory
+
+- name: Nginx config installed
+  template:
+    src: nginx.conf.j2
+    dest: /usr/local/etc/nginx/nginx.conf
+    mode: 0644
+  notify: Nginx restarted
+
+- name: Ensure nginx is running
+  service:
+    name: nginx
+    state: started

+ 28 - 0
ansible/roles/nginx/templates/nginx.conf.j2

@@ -0,0 +1,28 @@
+worker_processes auto;
+events {
+    worker_connections  1024;
+}
+
+
+http {
+    include       mime.types;
+    default_type  application/octet-stream;
+    sendfile        on;
+    keepalive_timeout  65;
+
+    gzip  on;
+
+    include /usr/local/etc/nginx/sites/*.conf;
+    server {
+        listen       80;
+        server_name  {{ansible_hostname}}.local;
+        root   /usr/local/www/;
+
+        include /usr/local/etc/nginx/locations/*.conf;
+
+        error_page   500 502 503 504  /50x.html;
+        location = /50x.html {
+            root   /usr/local/www/nginx-dist;
+        }
+    }
+}

+ 86 - 0
ansible/roles/photoview/tasks/main.yml

@@ -0,0 +1,86 @@
+---
+- name: Dependencies installed
+  community.general.pkgng:
+    name: git,go,blas,dlib-cpp,lapacke,libjpeg-turbo,npm-node10,darktable,ffmpeg
+    state: latest
+
+- name: Source folder exists
+  file:
+    path: /usr/local/src
+    owner: root
+    mode: 0755
+    state: directory
+
+- name: Libraries for jpeglib linked
+  file: src=/usr/local/include/jpeglib.h dest=/usr/include/jpeglib.h state=link
+
+- name: Libraries for jconfig linked
+  file: src=/usr/local/include/jconfig.h dest=/usr/include/jconfig.h state=link
+
+- name: Libraries for jmorecfg linked
+  file: src=/usr/local/include/jmorecfg.h dest=/usr/include/jmorecfg.h state=link
+
+- name: Libraries for dlib linked
+  file: src=/usr/local/include/dlib dest=/usr/include/dlib state=link
+
+- name: Libraries for lapacke linked
+  file: src=/usr/local/include/lapacke.h dest=/usr/include/lpacke.h state=link
+
+- name: Libraries for lapacke linked
+  file: src=/usr/local/include/lapacke_utils.h dest=/usr/include/lapacke_utils.h state=link
+
+- name: Libraries for lapacke linked
+  file: src=/usr/local/include/lapacke_mangling.h dest=/usr/include/lapacke_mangling.h state=link
+
+- name: Library for dlib linked
+  file: src=/usr/local/lib/libdlib.so dest=/usr/lib/libdlib.so state=link
+
+- name: Link lapack libraries
+  shell: "ln -s /usr/local/lib/liblapack* /usr/lib/"
+  ignore_errors: true
+
+- name: Link jpeg libraries
+  shell: "ln -s /usr/local/lib/libjpeg* /usr/lib/"
+  ignore_errors: true
+
+- name: Link blas libraries
+  shell: "ln -s /usr/local/lib/libblas* /usr/lib/"
+  ignore_errors: true
+
+- name: Photoview source @ master
+  git:
+    repo: "https://github.com/photoview/photoview.git"
+    dest: /usr/local/src/photoview
+    update: yes
+
+- name: API env file installed
+  template:
+    src: api.env.j2
+    dest: /usr/local/src/photoview/api/.env
+    owner: root
+    mode: 0600
+
+- name: UI env file installed
+  template:
+    src: ui.env.j2
+    dest: /usr/local/src/photoview/ui/.env
+    owner: root
+    mode: 0600
+
+- name: Photoview UI installed
+  shell:
+    cmd: npm install
+    chdir: /usr/local/src/photoview/api
+
+- name: Photoview API built
+  shell:
+    cmd: go build .
+    chdir: /usr/local/src/photoview/api
+
+- name: Photoview supervisor file installed
+  template:
+    src: supervisor.conf.j2
+    dest: /usr/local/etc/supervisor/conf.d/photoview.conf
+    owner: root
+    mode: 0644
+  notify: Supervisor restarted

+ 15 - 0
ansible/roles/photoview/templates/api.env.j2

@@ -0,0 +1,15 @@
+PHOTOVIEW_DATABASE_DRIVER=postgres
+PHOTOVIEW_POSTGRES_URL=postgres://photoview:{{photoview_db_pass}}:5432/photoview
+PHOTOVIEW_LISTEN_IP=0.0.0.0
+PHOTOVIEW_LISTEN_PORT=4001
+
+PHOTOVIEW_API_ENDPOINT=http://{{ansible_hostname}}:4001/
+PHOTOVIEW_UI_ENDPOINT=http://{{ansible_hostname}}:1234/
+
+PHOTOVIEW_MEDIA_CACHE=./media_cache
+
+PHOTOVIEW_SERVE_UI=0
+
+MAPBOX_TOKEN={{mapbox_api_key}}
+
+PHOTOVIEW_DEVELOPMENT_MODE=0

+ 17 - 0
ansible/roles/photoview/templates/supervisor.conf.j2

@@ -0,0 +1,17 @@
+[program:photoview-ui]
+environment=PHOTOVIEW_API_ENDPOINT=http://{{ansible_hostname}}:4001/
+command=/usr/local/bin/bash -lc "cd /usr/local/src/photoview/api/api && npm start"
+autostart=true
+autorestart=true
+stdout_logfile=/var/log/photoview-api.log
+stderr_logfile=/var/log/photoview-api.err.log
+stopsignal=QUIT
+
+[program:photoview-api]
+environment=PHOTOVIEW_DATABASE_DRIVER=postgres,PHOTOVIEW_POSTGRES_URL=postgres://photoview:{{photoview_db_pass}}:5432/photoview,PHOTOVIEW_LISTEN_IP=0.0.0.0,PHOTOVIEW_LISTEN_PORT=4001,PHOTOVIEW_API_ENDPOINT=http://{{ansible_hostname}}:4001/,PHOTOVIEW_UI_ENDPOINT=http://{{ansible_hostname}}:1234/,MAPBOX_TOKEN={{mapbox_api_key}},PHOTOVIEW_DEVELOPMENT_MODE=0
+command=/usr/local/bin/bash -lc "/usr/local/src/photoview/api/api"
+autostart=true
+autorestart=true
+stdout_logfile=/var/log/photoview-ui.log
+stderr_logfile=/var/log/photoview-ui.err.log
+stopsignal=QUIT

+ 1 - 0
ansible/roles/photoview/templates/ui.env.j2

@@ -0,0 +1 @@
+PHOTOVIEW_API_ENDPOINT=http://{{ansible_hostname}}:4001/

+ 8 - 0
ansible/roles/supervisor/files/supervisord.conf.patch

@@ -0,0 +1,8 @@
+@@ -125,5 +125,5 @@
+ ; interpreted as relative to this file.  Included files *cannot*
+ ; include files themselves.
+
+-;[include]
+-;files = relative/directory/*.ini
++[include]
++files = supervisor/conf.d/*.conf

+ 23 - 0
ansible/roles/supervisor/tasks/main.yml

@@ -0,0 +1,23 @@
+---
+- name: Dependencies installed
+  community.general.pkgng:
+    name: py37-supervisor
+    state: latest
+
+- name: Supervisor enabled
+  shell: sysrc supervisord_enable="YES"
+
+- name: Supervisor config file patched
+  patch:
+    src: supervisord.conf.patch
+    dest: /usr/local/etc/supervisord.conf
+
+  notify: Supervisor restarted
+
+- name: Ensures supervisor conf dir exists
+  file: path=/usr/local/etc/supervisor/conf.d state=directory
+
+- name: Ensure supervisor is running
+  service:
+    name: supervisord
+    state: started