From a058cadcf56f553d1095f02ad176b8820a711844 Mon Sep 17 00:00:00 2001 From: Egon Rijpkema Date: Thu, 4 May 2017 16:32:18 +0200 Subject: [PATCH] Added a dockerregistry docker. We should roll out our dockers from here. Changed password (I failed to save it somewhere) Reencrypted htpasswd using docker's htpasswd see: https://git.greth.me/WederNoch/DockerTutorials/raw/33a74ba9af61dc8e262df52eb926acc26c6a9997/registry/part-3.md --- .gitignore | 1 + main.yml | 6 + roles/dockerregistry/files/auth/htpasswd | 2 + .../docker-registry.hpc.service.rug.nl.crt | 36 ++++ .../docker-registry.hpc.service.rug.nl.key | 169 ++++++++++++++++++ .../files/dockerregistry.service | 21 +++ roles/dockerregistry/tasks/main.yml | 25 +++ 7 files changed, 260 insertions(+) create mode 100644 roles/dockerregistry/files/auth/htpasswd create mode 100644 roles/dockerregistry/files/certs/docker-registry.hpc.service.rug.nl.crt create mode 100644 roles/dockerregistry/files/certs/docker-registry.hpc.service.rug.nl.key create mode 100644 roles/dockerregistry/files/dockerregistry.service create mode 100644 roles/dockerregistry/tasks/main.yml diff --git a/.gitignore b/.gitignore index 0f05cf3..f0e0bc0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.retry *.swp +.vault_pass.txt diff --git a/main.yml b/main.yml index f8f9e75..27a11de 100644 --- a/main.yml +++ b/main.yml @@ -11,3 +11,9 @@ roles: - common - keystone + +- hosts: all + become: True + roles: + - common + - dockerregistry diff --git a/roles/dockerregistry/files/auth/htpasswd b/roles/dockerregistry/files/auth/htpasswd new file mode 100644 index 0000000..06af316 --- /dev/null +++ b/roles/dockerregistry/files/auth/htpasswd @@ -0,0 +1,2 @@ +hpc:$2y$05$cDK0fPSCb2.7E9ZNxNNMqe88CKWfdc/kOBWNqvKvF4t7SBHeo4Twm + diff --git a/roles/dockerregistry/files/certs/docker-registry.hpc.service.rug.nl.crt b/roles/dockerregistry/files/certs/docker-registry.hpc.service.rug.nl.crt new file mode 100644 index 0000000..6b64323 --- /dev/null +++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Pz1wzILvcQvb0FzZ8/coq +ffSNrhzoEOZMoaTtiub+KBlnAn2RwA5L3NMF0ztaZi2syVvxrhK3xJg2P7GGyefS +1HeKQbc5Uf3Qb4rIoMQaPyuef/uv4Sr/F1wSgtThkHsWomw= +-----END CERTIFICATE----- diff --git a/roles/dockerregistry/files/certs/docker-registry.hpc.service.rug.nl.key b/roles/dockerregistry/files/certs/docker-registry.hpc.service.rug.nl.key new file mode 100644 index 0000000..2b0b7ec --- /dev/null +++ b/roles/dockerregistry/files/certs/docker-registry.hpc.service.rug.nl.key @@ -0,0 +1,169 @@ +$ANSIBLE_VAULT;1.1;AES256 +66323263303633663035353864616664306530393639666533303835653763663666363937333866 +6437376135306535643139346135333361353962346633650a313339306330326337393833333235 +65303330333538663330313232623062316437616134623236666435316535346635343465383131 +3364646661313965620a666161333663303736653232613633346434363263346330336134396462 +33306333356363376362303265336232633431383965313234333033333861376564653739386330 +62393961353364613132376365656431303935346362613861303335623337363937373162396266 +38663939386431373130616336656339353565313962633235656634363030613932393030376364 +37623264323433316536623739653030323934316337396262373338336430663461303566663839 +37666431633239633332633864643365363061313732386533663435663234343236353732386336 +65623565656635383836653462373938613534326661613763326465303333623166653432303939 +66343038366533336131663964356636396633303362323031333837663330383332363630346463 +31393435376432653630323235303333313366386263343461656339383638656166666362643837 +34356636633435393663353330616566643866616130343036366433643638383035636564663133 +61616633396534366631643765666135636636323038333332626431353466386635653333396238 +33663464316363316135373063376530356136653762613438623563643935386630613466386166 +62666539666332646361333435326132613737313662663361343136623266356661393033366339 +65386432636638616137613761376538376434663932303339393935643236353862376664343932 +30306137396431363037646133643834643939323863623430646361613134333431343733626639 +39613062393236653339336439303566346230386265376137343936643633393339393533313064 +35396132633734336338333033326663393935373261333566613765396133616563356161316238 +65363931393433343863636237633439333432653935316661333434396365616635326561353334 +62636337373539643939363561346465653031663161386466633035616561373964616561623065 +31633266616163306636336636623330363433356463633334323032626666643466376331623834 +38303839303631333465313366633131313264366561396236616234353766363335336336643830 +32366239613533623234306338653337373536656534623361653164643535383535326561653636 +64396538666639376263643361383166343236633266663361656230313738363537383931613136 +61663335396530336439306335646661623635323739666662393066613264633062303361323361 +37633562663062303435656630323961373934393761616130333331613331313830343238616462 +64363330393033663130663764623039333833333238303733613664373336323830303334343136 +32376134386265333165353066373237646436643964326433646137663935333436656163363437 +66343665306661353538636164383761323137653831393133376361333637393234656639626534 +63653530356232343635366437326163643738343031336438383835666165653262373232653039 +63326336626633613938613039373562656339623463363237643266633866346631623436666536 +38663438326331376132306233656161623431373731633037353336366333326230316662366432 +61316464313765383331643234363036343761663261346231303435353465653363336536386135 +66636561333366353463643563376337613431613034633533336434383237653535663061333631 +33343237393466633465366532656532353337316332653839383266376662393063633731316532 +39616333616465373637383564613762356237303339313738356132346338623637333839343262 +64326136356232326161306133376330303732386466626463303866363938643234353131656130 +30333263613161373632613633363939663663383562623263343837356635393032623535623063 +62343532656632356663336539303462646433366562353034326336323131623831356437393932 +30343961663231633565323437623834643535363634653034626236336463353165306534323935 +33353563306230376365623633313035393336303436626665633762623864336135656264316666 +39663462383035646435393562306336646664666231343565613865616437366135353630396333 +30616264323761363133363836336261326536383536383964633338313435656463343034373635 +65316466613533653666383735613330323762623330383432663366346164316232306532663932 +61326130663838343362656433333434346363353066396331633562656465353339336531353461 +61303939663935323432623035323235643464656261666338333232626465633032646461373139 +34333332323539383238363439636366323035636264316435396630643234393636336665663032 +30643433623031303332343361633761383232343832336466383164333533346638326566626435 +35636663313630666638623037393963633866656133366430643734613961346566386462643261 +31623237393035373663363732633031613330393162316236373965616664663333363036323438 +65633636363537653064663765613532633463373838346635353638383761376131313365393065 +39396465343531353933346336616236383364346162306431363862326632633530633938303736 +30306665623964396434376332396639303135363731363766633966623561316466396131353064 +34663564363465346530373930306636376435633938373532373839393034323335303762303032 +62653737323165386165393263663231633738363230366336653638656430366139333739613636 +63313032396666643365313434353162303665633730333233633134373961663230633433633761 +39643134633331366365333936343334306636303962343930343338616133343332666263366235 +30353033643134303739646261303735653862343131613233663438356661323639393837376336 +32303265326531383164633361353066643237333938376162633864613962613637393037656338 +36356430636666353130363132626665646365653838333761376530313166343962343734666334 +33633138383337646337353666393938613334616363623234396636613662306535326562336363 +36323264333962323731313437353966326630326235313565313937363137373738373138303333 +64643063646139313861663062376639623630313662303861306638343964373164323538633163 +62346365353837616462633533383533356634303136623764633839326137356637306431616563 +65333264316365646334343135336461396565373165663236373661313431663366613738613633 +30363735326164623632316261616632643638346538633235663632346430613062323364386433 +38313836343730303234623863383335346636356631663939646431326232316463393262613362 +66643330373165303635313734356562643637626464306436613231646562383664333162316531 +64393161313439376634306134373734333533656332633337663932643135626233306466316237 +65393431613139333163616266643838373565343263373461623064616333396336646665636131 +61303934303931383561613635636636383836366462623263356230646532386138623665653266 +66636661303334393333303637323934393232393464316533646635643038616433666335623230 +61666535363638333935366366633733656364633965386461383231343266303736386532636439 +66343136353930333166656132353534396332343637376164343939363331653430643939663034 +64653164303865613038316131633965636130336238323861376637613832373934323739353137 +34643362616465663836666364393435356233326363333666623237633836356436316433323039 +30643530643530316533613562633832346439306364336332626134386134356364663964646632 +30313164636162376137353362346633613035326233303762623662363430393363316435373637 +39616664383335343135613064313964653633313634336238383835333133353536346338623362 +35396430613935373363363236346239373637396332653334363362303062393063313365643635 +30656462303230353862616438343432373433363736316137376638626233316238393031333730 +63623632653565346561303032383232393765303165386466646164303538616633626130386531 +36643366376233383230626162303335323533313438363535306237656566613737633437616331 +34646437383961356230343038356531346534626239626266333338653537626563663333343039 +32653031313466333037346230643364623732336266396131633330643461356661343935303030 +34363332663238363665303765613561323030666563353238313331323664656435396333383731 +62313463643666396561613565366265323536333639383632653231323465613366666461323731 +31343638653730656361633563373230636439303031333362633838373437393261316366616334 +63333734353935366632343439616536316432616237663262303037643365393861653133313865 +36663065636465306563306537313263373238376633333363353231643935623336643565323632 +36313031323163656438613937646138643138323966373138346463343832383966636133663261 +62316136636335656231396439366366386339333031376161333432663466373833323263663735 +30613932316263366239616131373064326665303661373964313064323666373231383564373233 +34376635323663323632306233383262643532643763333766626538313962376563343533323231 +38643530353435323937356365623031363466326337633639336332376139373833333163376337 +38333735643839653238616232363665623032363537343332383261373063376362333730333736 +65356666386532393530376331643135303935636135623162313934613633346263356362653930 +33626264303563336263653530666336353036613330633062636639656632336334383333613332 +37366535313562643637323638666131306331663465323631393665663130653235323564323465 +62353566363532333164643733653661626566633134366563636265306665363533303264333162 +61316630376562646263386634336533633132363734343537353136626238633162343063663464 +32643135623161306336353736343736343562623339636138643034346435633137343166373633 +32623438613362396364316230626563343864633862653230323534386362356163613661303930 +36366439323635343335323137666366393330646235323131303032363437393133306438323435 +36633961383933653736386563363665303737616263646365366466386665323430646139306231 +37393233373266333836353034653733336663323030346262333230383331316561306365613430 +64623935306664303435333630393864346231323936366432306266636433313932643437663766 +64666136356361313966663638313130343366366564636638326433663435356364313430666232 +36353833626462616639663164636430663131323437356533653133353865323465343738626137 +38663037396337343734363563623939646339656632346635346363323265396635666230623333 +38383439613438306230313765343637346432643732623137363839376330316438643337326361 +63323731326462653636353664303535373266343734393835666439373530336434313930363435 +31323531663934613839306239373238653536323432643439303537373563633666626236666636 +65316635656464366263343239303761363535376262656162323239366337663330633334613061 +32653231623736393439323363623933666530373332376266623331343839626638333037343961 +65363433386531333762323539383235613263346535623864326435636130663036393261363961 +34346437313966363735393339386562333264383266643734393439353836303066303230656666 +33613932646433616333383466303931313237363235343766666130313733626636663835383335 +64613663393661613333393232636638393161363633336130396236353430393833356536343130 +30383532313331623734333238383665643762666161633531646231663836343135646165303064 +62333636306137626237343761343963663737623061366264356131373564666162383964353964 +38656231393332353539653132383665663763643138386366663639663738643838316266646432 +37626663366361623365353664633138363137666333393862653630326362323638326361396661 +36613833373835326464393936306664313330393038636437663261646636313864346131333061 +32346336333231666362643664363936636337663830366131616439356137636635373631353232 +62616363313465336464663233623639336639376239336631356433656436643335326234633538 +35636535326565323365383438316565653538376130333135616339663566613638306338396163 +61633330616437353035623437323838383962326439613834663261343161356665383933653037 +38613963333764653930343963313838353131356534353435363837386662643230346331666335 +33653836363163363639333464633834623535383139323531396432653538626462396239353065 +39653436373633626633376539323236383732633832353938303965323762656563383733386130 +66613136336138323366643265623761323633393636313461333039373861353961326135313065 +38313662356666313631666439356361613339326363383736343861323532343538613634653162 +64353165393137613835326131373866316166653830366461373337663038623634623431313634 +38323639306364323830666532323834386138353533313766353536313833646661353637643865 +34356662383036623032663431363330653739346231346463613261616335363334306331343139 +61613764383463323237393237356165396334316130613061386665306539653536323664313666 +39666537616139643662356634373561653833663165383064306331313766643864626161623332 +63343761306635376632623939346337313364323561613162653337306263613336656164343832 +33316637656338386262373330343634666336663735663239653062663865616665646433306432 +31366133303366326335323334623932653337633339616439663835386533613963643161656634 +31663136666463616239363839353663626532383634653863316564373435633333333761396330 +32396464663830666637633964313761313038396363326463353562653166626262393363643863 +39653334636634336234373366313261613938303761643364326634373631343362353233363763 +39376165376361373031613765653662353261353736333763336366353136386633353331653433 +32373031636262356139393235616130633466663136636531393838396364643237663662373738 +35313766316132616361656536646133383536333935643538383566623032343663303635666661 +35316161636538636138666262313465313136323763356337393939346633303330313263383639 +38653231393564373934613439333062653137666630386164346662623962613237343937643261 +31393561343061346361313262623130366562346237333066326436356636353364313165383963 +62646138303364343330313563353362343536346233653833393437363335333138626562303232 +33623438303363343431303566343263653563636663636634616265363436666333656238326535 +63393666326264643838373032616236653266303831323838323631343331316562636561323162 +30313334326366353532636231306332643065653737613137643337323464333564346636386532 +35613735303134346333313534663532656331306133396238373032346431356238306565363861 +33366137373964393362643166353435333264373962656666396163316262383262643437326338 +35356135343366363865356563623234326239653733336561326166333335373565633961323738 +63373235616231656263643265626530323237383734363836333430383865303465386133633538 +30636665613631346537666366356535646130363432353733306465383064343039623738366664 +62396634353936356236303336343739373465333230666530393036343765363938623262333831 +36653632616332383334313964333133616666343832373739613533643365646236616361353136 +32656361306136346537316236356164303833343233323439626235663339623437376137333838 +30363563316339393639616161616539396639633762346566333765346631633066333735363965 +62623764303634666264616262313664643462316431303665636639306238646361383433343962 +39383837613231663637356432366664303434303031333935616637353261313262393235353935 +37333766613539313332 diff --git a/roles/dockerregistry/files/dockerregistry.service b/roles/dockerregistry/files/dockerregistry.service new file mode 100644 index 0000000..bbc811f --- /dev/null +++ b/roles/dockerregistry/files/dockerregistry.service @@ -0,0 +1,21 @@ +[Unit] +Description=Docker Registry container with certs and basic auth +After=docker.service +Requires=docker.service + +[Service] +TimeoutStartSec=0 +Restart=on-failure +ExecStartPre=-/usr/bin/docker stop %n +ExecStartPre=-/usr/bin/docker rm %n +ExecStartPre=/usr/bin/docker pull registry:2 +ExecStart=/usr/bin/docker run -d -p 5000:5000 --restart=always --name %n \ + -v /srv/dockerregistry/auth:/auth -e "REGISTRY_AUTH=htpasswd" -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \ + -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd -v /srv/dockerregistry/certs:/certs \ + -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/docker-registry.hpc.service.rug.nl.crt \ + -e REGISTRY_HTTP_TLS_KEY=/certs/docker-registry.hpc.service.rug.nl.key \ + -e REGISTRY_HTTP_SECRET=jahNoh2teev0 registry:2 + + +[Install] +WantedBy=multi-user.target diff --git a/roles/dockerregistry/tasks/main.yml b/roles/dockerregistry/tasks/main.yml new file mode 100644 index 0000000..ed883bb --- /dev/null +++ b/roles/dockerregistry/tasks/main.yml @@ -0,0 +1,25 @@ +# Install a docker based mariadb. +--- +- include: ../common/tasks/docker.yml +- name: install service file. + template: + src: files/dockerregistry.service + dest: /etc/systemd/system/dockerregistry.service + mode: 644 + owner: root + group: root +- name: install service file + command: systemctl daemon-reload +- name: make sure service is started + systemd: + name: dockerregistry.service + state: started + +- name: Copy certificates and passwd file + copy: + src: "{{ item }}" + dest: /srv/dockerregistry + with_items: + - auth + - certs +