summaryrefslogtreecommitdiff
path: root/roles/repo_service
diff options
context:
space:
mode:
Diffstat (limited to 'roles/repo_service')
-rw-r--r--roles/repo_service/defaults/main.yaml122
-rw-r--r--roles/repo_service/files/repo_service.service13
-rw-r--r--roles/repo_service/handlers/main.yaml5
-rw-r--r--roles/repo_service/meta/main.yaml4
-rw-r--r--roles/repo_service/tasks/as_repo_service.yaml40
-rw-r--r--roles/repo_service/tasks/main.yaml13
6 files changed, 197 insertions, 0 deletions
diff --git a/roles/repo_service/defaults/main.yaml b/roles/repo_service/defaults/main.yaml
new file mode 100644
index 0000000..b297c97
--- /dev/null
+++ b/roles/repo_service/defaults/main.yaml
@@ -0,0 +1,122 @@
+$ANSIBLE_VAULT;1.1;AES256
+33356535393466363739663333613465616166363139663531323631303032396466303261333334
+3632393239333765313863353735313263366533623663300a393130376563646639383261633636
+31616332653035366630323465333431626663393434303430363935396561646433383739346433
+3862376663646564650a383866663436663761353139633838653738313134653366376466303761
+30353030663330356463653530643234346131306534623466373337623530666266636637393539
+38343065363765626561376265336330363563356231643138376337623863356265363837313739
+65366534356666393231366263386139656636316632313865343363646566633738393834616234
+37343838663035373336383566336161643965373235383835313332356237393735313735383965
+30336333633566383638623439323034383938353334386633643936623630306632353933376536
+36643630386666636330373439663361343635343334643230623232346337373336663635633236
+65326337643265666634653332653964383634666432663631386164393739336132303634633235
+33373065646662323066653233646339623237616531303131653833373764643233323331626138
+32613031613436393531343734363338383331376466376663326232343463396665306137353030
+35636632336537643965343034373966613539663533663233336537646665393430663666393862
+37333635653537363539346135613934373133333639316436646364396261313533333164396638
+34363639306666303231306331373034316263323136616235353635616134613437343561656536
+33313565623737326130396264636365613036613034383962373339336162643065666138636266
+38613438643665326331393933613636373066316432356661623434343865303161303634626139
+38343137353361656435336161316563613730346637646466373035366262643965613437613739
+39333932366163386537623961386133373738383035333838383233636136633238653939623739
+33393732363938353935663566313333303166616663326664306337356661373161633865393038
+63383762363334336136306461356466633738633531666666656232376236626332396330653533
+63373764613133353964333530366635626230666365303766333330306338666531623531326265
+66633534616435623035666464656362626564356264356666353732353437323265363464643866
+64343564383432393461636563653435646530633566346434323966653232303335306333643535
+37303065666663376463613038656164366632366365623232353662383032613438353061336136
+34653939393363366263376433303163383461353232386134393236633136396437653637393134
+34393266303332326335343138393338626632353162393066666332303836326338323437313563
+61326338653631383637663065653730383330383031366266643066633363633533373161643032
+37666365313237386539376563336438356366666235376562303061313238353066383664396663
+31343065306433363165646139396162356365333831383537383332306536336461653631356234
+38643136316330333536346138303835326134656439613638356632363934373438383861653761
+35393333643364366133353465656664333232313635656634376536623532393130373839353262
+61393238613765303536613737383463323335343131313633646132323032366231323133613362
+64396361373533616535326664323865336333623935626261356235656566376163363932323935
+31316265356364666231353833353764353633613332386633396638613231336364343238303937
+35353037633031313438323336643636336230383762393434656562653038383761343461393462
+39303730643831326335376332313130653764393731393762376139623832373966366361646433
+38366633626239313666373035353261336132636537646163313164343064613534633230616565
+66323462633961356536353631383634326633373662613537376133306561333433303436363936
+66656364333732393666306362373665376430323133313333623462363362326461643062343163
+31356266336336313139393537346535616161366630653436343937306532386266353963386665
+39626165303462326137373637643264383163343638393837656631626533336633353339643762
+61313933616132633330333066313136383232353362383835623565373665383031393461383133
+35343335366437346466613338646239326161663533666431363231396130653531333331373334
+35663034663061323264373935313864353763366237316634383530326633376166303864313361
+33313061303666366132353839613932346336643131313364646435373639636634396437616362
+62316566663963666166663435653962363661336364306631616633616534643330386466646462
+33303330356238626435353030326232353962326364613362336265353532656633316364613430
+36613632353132616138633962626533373734313539346333366564363533383432306534383133
+63636635613865313437643161316337633661303334393130633135306330663430346432326639
+38343931353631333031316235343132373030316431613537333165393635336333336433396537
+36363035623062336361363736663563363766623632366633336235353833333966626264363162
+61386535633661643161346135633434653634353363383865346636643030303233633132323432
+65383364303461356333363936313831393038663334326232333631333162336461376263303030
+64363464653830613266636137393433303632323737306261663736393435646332623638336436
+39666464323638616635363832623730633239323433326536366132306330346435366130326462
+35623238616438656164336464303636323664646235356638306466373939633637653063656430
+38626564343666356635643732336464663666616135356562303636373932613665336466383834
+64366130373436623933386138633533646536666238613162383364613565323761373433336166
+62393832326239303738363234383164643065316133396439653338376330373166643762613638
+62393132613336633935633464313736386664343433343233386131656266393264616533343636
+34306636366330386538346333326632343165346363613930393238663631323663393036383262
+35613637643664663730363631653336323534633062373434316538313366343432613162646435
+36643038323136386166656436303766626263353961383733643632613535383333346537303336
+35646265316239343363643065336232633362363031643963306539626666353434363838613632
+31613665346366356137646663643338653635306563616137663835666264636636643662396164
+38393066656666646634623638623662363338663930643231383330613036306631346338376234
+36373661626438636261656533653931636663613362623363616266656532616361366536363239
+38666135333763643137386433623039353837323532366336353731353636353366376431356634
+33646262313033373335306161626661633038333664613738353232663565373563636433373239
+64393037386536653064303462653231383531643038366335306537393761616333393630303263
+34633131323861383938363461393065383766643532373761666233343436366366396333366533
+36366361346164666533626135653434366163373730353634633163636431323361383865323166
+63393562393236393063616564666637346165363634356161616662346534646638396163636262
+34396633323634326130353836386261333136636136393736396435626439646530313864396366
+66336435643462396663336232316164316331396634366533313130346264346365633263643032
+37666266323131386561393332626362333231316330313433333964343731386466383362656135
+63373064346464343366373333326638393365643634303238653363623730363635643866386436
+38306537356563363962666366623137623762396233366136346365623332636231636366626335
+65613934346662376338393537326532396661316263623062303662613266653930323132336236
+37323730353662343939343331373335346464626235666263663865653630333434303433363039
+30343561343130313831373835383665306435343232623330393439323334346262396439306534
+30636230653964613030613663656466316637643632336662343339323562613730346336393465
+63663261373538383063376534376165363162323333363937356265656366303432343137343836
+63373730373339663530663932643838333039396231323438353165666563313962623835623266
+34336436333836386435613862383962346435323463323735643562396463663664316537666631
+35373635303864643837366135373430353364663333356261363364353765633965356437623336
+30343435313962653662656537666630333330396631323162333133363963346564356237336462
+31346639363939633263633738623834643433393264303161346466303830353465626365313665
+35623933653963616136313437653339356239633166666238353039313066336138613362633930
+64616130363835386161653034623833323866363066313461313531643765353666363133376265
+31663462666433643464313632636263633939643636343133386632613237613866356530643561
+64356135613630303166633736333363366339663336336630643864393835623439306261666234
+33346335363935653032363436343464393636396430626366376235373263333433663035653263
+38373036333237643261626335373436386439353538333337623139396433313963343634633262
+30383633386436343031323537383231336265333632633237303465373936396535343336386333
+38363261656639663064376234636266666334316532323462366430613632386234656438646436
+63613339343361663030316437383763616664626537306635303438356264373434656164366663
+37376366623865333133383361303365313962386338613733373164303235666132313265653535
+31343762366332353061396466633065643566323738393633393836306265346437373633373632
+33383637373336353362613733626237633164616538633963356132366164303933366533336538
+65663330353434616165393264373463613239343332616430666530636263656366643965366230
+31626630313462343235646533613366613931363039626633316231346565366637633136363131
+64323634663664636534376139653135303432386633373933346233333135336635353637653136
+36356435363466333561623063666466633238343136396565333331663662353334613265643063
+30626562393564633762336230646436356337306361623333653332346463663831383262323033
+65303766616636393336613762656562353163316231323739653936643962643864383864303730
+31626662656431623465663432386363666632613761653832636634323366353663656435313734
+33366434353764633330366565303538316566363463313266613464653133623163613533626237
+32393363303533346630333838313366313264636636343735326133653134373035363662616231
+30366535646362666535636564656661383138346632316539626666393164613938323033383936
+66643232313362333632313362643032373039346331343965393837323138303364316634663035
+30623761396564306564336662613238623365623866383339636662393735643666383231313366
+39336435383233306330346338643164663731366362646362363330343965653230653863643339
+66316462666435336334653432383161653563353532386662636364316666623331616135383737
+36313863666531313062643636643832616335356336393265323132303630303666656130356235
+61643165393134386438303136616665386265373534666136663563313035336432366162643661
+62316638646262376563633835643164376530643063373731373338363063353763656138663264
+61313432363039316265323131336566663365376163323032663833636639363437396564666261
+30636537373534643931383738643864303661383736323639333062663539323464
diff --git a/roles/repo_service/files/repo_service.service b/roles/repo_service/files/repo_service.service
new file mode 100644
index 0000000..15c40ea
--- /dev/null
+++ b/roles/repo_service/files/repo_service.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=repository creation service
+After=network.target
+
+[Service]
+User=repo_service
+Group=repo_service
+WorkingDirectory=/var/lib/repo_service/src/backend
+ExecStart=/usr/bin/python /var/lib/repo_service/src/backend/repo_service.py
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target
diff --git a/roles/repo_service/handlers/main.yaml b/roles/repo_service/handlers/main.yaml
new file mode 100644
index 0000000..4ed34df
--- /dev/null
+++ b/roles/repo_service/handlers/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Restart repo_service
+ service:
+ name: repo_service
+ state: restarted
diff --git a/roles/repo_service/meta/main.yaml b/roles/repo_service/meta/main.yaml
new file mode 100644
index 0000000..7947c74
--- /dev/null
+++ b/roles/repo_service/meta/main.yaml
@@ -0,0 +1,4 @@
+---
+dependencies:
+ - role: common
+ when: false
diff --git a/roles/repo_service/tasks/as_repo_service.yaml b/roles/repo_service/tasks/as_repo_service.yaml
index 6b364d8..b9a99ab 100644
--- a/roles/repo_service/tasks/as_repo_service.yaml
+++ b/roles/repo_service/tasks/as_repo_service.yaml
@@ -3,3 +3,43 @@
git:
repo=https://github.com/cfra/repo_service.git
dest=/var/lib/repo_service/src
+ notify:
+ - Restart repo_service
+
+- name: Create .ssh dir
+ file:
+ path="/var/lib/repo_service/.ssh"
+ state=directory
+ mode=0700
+
+- name: Add repo_service ssh privkey
+ copy:
+ dest="/var/lib/repo_service/.ssh/id_rsa"
+ content="{{repo_service_privkey}}"
+ mode=0600
+
+- name: Add repo_service ssh pubkey
+ copy:
+ dest="/var/lib/repo_service/.ssh/id_rsa.pub"
+ content="{{repo_service_pubkey}}"
+ mode=0644
+
+- name: Read Gitserver Hostkey
+ slurp: src=/etc/ssh/ssh_host_ecdsa_key.pub
+ register: gitserver_host_key
+
+- name: Put Gitserver Hostkey into knownhosts
+ lineinfile: dest=/var/lib/repo_service/.ssh/known_hosts
+ create=yes
+ owner=repo_service
+ group=repo_service
+ mode=0644
+ line="127.0.0.1 {{gitserver_host_key.content|b64decode}}"
+
+# Configure git
+- name: Configure git push for repo service
+ command: git config --global push.default simple
+- name: Configure git name
+ command: git config --global user.name "Repo Service {{ansible_hostname}}"
+- name:
+ command: git config --global user.email "nobody@nowhere.ws"
diff --git a/roles/repo_service/tasks/main.yaml b/roles/repo_service/tasks/main.yaml
index b17319c..19139e0 100644
--- a/roles/repo_service/tasks/main.yaml
+++ b/roles/repo_service/tasks/main.yaml
@@ -12,3 +12,16 @@
become: yes
become_user: repo_service
become_method: su
+
+- name: Create systemd service
+ copy:
+ src=repo_service.service
+ dest=/etc/systemd/system/repo_service.service
+ notify:
+ - Reload systemd daemons
+ - Restart repo_service
+
+- name: Enable systemd service
+ service:
+ name: repo_service
+ enabled: yes