From 92fc0ffb1c5db90bfb361bb76118bf2b68d3eff8 Mon Sep 17 00:00:00 2001 From: Francesco Antognazza Date: Tue, 1 Aug 2023 10:57:16 +0200 Subject: [PATCH] Add github CI runner for gitea --- containers/act_runner/tasks.yml | 99 ++++++++++ .../act_runner/templates/configuration.yml.j2 | 85 +++++++++ host_vars/chef.heaplab.deib.polimi.it.yml | 178 +++++++++--------- 3 files changed, 277 insertions(+), 85 deletions(-) create mode 100644 containers/act_runner/tasks.yml create mode 100644 containers/act_runner/templates/configuration.yml.j2 diff --git a/containers/act_runner/tasks.yml b/containers/act_runner/tasks.yml new file mode 100644 index 0000000..c30d6a7 --- /dev/null +++ b/containers/act_runner/tasks.yml @@ -0,0 +1,99 @@ +--- +- hosts: all + name: Gitea web server + tasks: + - name: Get containers UID + ansible.builtin.command: "id -u containers" + register: uid_containers + changed_when: uid_containers.rc != 0 + + - name: Stop running containers + become_user: containers + become: true + ansible.builtin.systemd: + scope: user + name: container-{{ item }}.service + state: stopped + loop: + - act_runner + failed_when: false + + - name: Create podman volumes + containers.podman.podman_volume: + state: present + name: "{{ item }}" + become_user: containers + become: true + loop: + - act_runner + + - name: Pull container images + become_user: containers + become: true + containers.podman.podman_image: + name: docker.io/{{ item }} + loop: + - gitea/act_runner:latest + + - name: Change permission to act_runner folder + become_user: root + become: true + ansible.builtin.file: + path: /etc/act_runner + owner: containers + group: containers + mode: "0700" + state: directory + + - name: Copy config directory + become_user: root + become: true + ansible.builtin.template: + src: "templates/{{ item }}.j2" + dest: "/etc/act_runner/{{ item }}" + owner: containers + group: containers + mode: "0600" + loop: + - configuration.yml + + - name: Create act_runner instance + become_user: containers + become: true + containers.podman.podman_container: + name: act_runner + image: gitea/act_runner:latest + state: present + security_opt: + # - label=type:container_runtime_t + - label=disable + device: + - /dev/fuse + publish: + - "8088:8088" + volume: + - act_runner:/data:Z + - /etc/act_runner:/config:Z + - /run/user/{{ uid_containers.stdout }}/podman/podman.sock:/var/run/docker.sock:z + env: + GITEA_INSTANCE_URL: "{{ vault_act_runner_host }}" + GITEA_RUNNER_REGISTRATION_TOKEN: "{{ vault_act_runner_token }}" + GITEA_RUNNER_NAME: "{{ inventory_hostname_short }}" + CONFIG_FILE: "/config/configuration.yml" + generate_systemd: + path: /home/containers/.config/systemd/user/ + restart_policy: on-failure + names: true + new: true + + - name: Start containers at boot + become_user: containers + become: true + ansible.builtin.systemd: + scope: user + name: container-{{ item }}.service + enabled: true + state: started + daemon_reload: true + loop: + - act_runner diff --git a/containers/act_runner/templates/configuration.yml.j2 b/containers/act_runner/templates/configuration.yml.j2 new file mode 100644 index 0000000..9b2b429 --- /dev/null +++ b/containers/act_runner/templates/configuration.yml.j2 @@ -0,0 +1,85 @@ +# Example configuration file, it's safe to copy this as the default config file without any modification. + +# You don't have to copy this file to your instance, +# just run `./act_runner generate-config > config.yaml` to generate a config file. + +log: + # The level of logging, can be trace, debug, info, warn, error, fatal + level: info + +runner: + # Where to store the registration result. + file: .runner + # Execute how many tasks concurrently at the same time. + capacity: {{ vault_act_runner_capacity }} + # Extra environment variables to run jobs. + #envs: + # Extra environment variables to run jobs from a file. + # It will be ignored if it's empty or the file doesn't exist. + #env_file: .env + # The timeout for a job to be finished. + # Please note that the Gitea instance also has a timeout (3h by default) for the job. + # So the job could be stopped by the Gitea instance if it's timeout is shorter than this. + timeout: 3h + # Whether skip verifying the TLS certificate of the Gitea instance. + insecure: false + # The timeout for fetching the job from the Gitea instance. + fetch_timeout: 5s + # The interval for fetching the job from the Gitea instance. + fetch_interval: 2s + # The labels of a runner are used to determine which jobs the runner can run, and how to run them. + # Like: ["macos-arm64:host", "ubuntu-latest:docker://node:16-bullseye", "ubuntu-22.04:docker://node:16-bullseye"] + # If it's empty when registering, it will ask for inputting labels. + # If it's empty when execute `deamon`, will use labels in `.runner` file. + labels: [linux,self-hosted] + +cache: + # Enable cache server to use actions/cache. + enabled: true + # The directory to store the cache data. + # If it's empty, the cache data will be stored in $HOME/.cache/actcache. + dir: "" + # The host of the cache server. + # It's not for the address to listen, but the address to connect from job containers. + # So 0.0.0.0 is a bad choice, leave it empty to detect automatically. + host: "" + # The port of the cache server. + # 0 means to use a random available port. + port: 8088 + # The external cache server URL. Valid only when enable is true. + # If it's specified, act_runner will use this URL as the ACTIONS_CACHE_URL rather than start a server by itself. + # The URL should generally end with "/". + external_server: "" + +container: + # Specifies the network to which the container will connect. + # Could be host, bridge or the name of a custom network. + # If it's empty, act_runner will create a network automatically. + network: "" + # Whether to use privileged mode or not when launching task containers (privileged mode is required for Docker-in-Docker). + privileged: false + # And other options to be used when the container is started (eg, --add-host=my.gitea.url:host-gateway). + options: + # The parent directory of a job's working directory. + # If it's empty, /workspace will be used. + workdir_parent: + # Volumes (including bind mounts) can be mounted to containers. Glob syntax is supported, see https://github.com/gobwas/glob + # You can specify multiple volumes. If the sequence is empty, no volumes can be mounted. + # For example, if you only allow containers to mount the `data` volume and all the json files in `/src`, you should change the config to: + # valid_volumes: + # - data + # - /src/*.json + # If you want to allow any volume, please use the following configuration: + # valid_volumes: + # - '**' + valid_volumes: [build_cache] + # overrides the docker client host with the specified one. + # If it's empty, act_runner will find an available docker host automatically. + # If it's "-", act_runner will find an available docker host automatically, but the docker host won't be mounted to the job containers and service containers. + # If it's not empty or "-", the specified docker host will be used. An error will be returned if it doesn't work. + docker_host: "-" + +host: + # The parent directory of a job's working directory. + # If it's empty, $HOME/.cache/act/ will be used. + workdir_parent: diff --git a/host_vars/chef.heaplab.deib.polimi.it.yml b/host_vars/chef.heaplab.deib.polimi.it.yml index 6e11bd9..b30a4be 100644 --- a/host_vars/chef.heaplab.deib.polimi.it.yml +++ b/host_vars/chef.heaplab.deib.polimi.it.yml @@ -1,86 +1,94 @@ $ANSIBLE_VAULT;1.1;AES256 -30663733363338333134613333316434633861386238613634303762653635326631353737323330 -6466356331313639613666616631633036376339343236660a323631613662313162316537366136 -62653630643732643735363136356230356333363232663632373730653264643563343061303930 -6530366261643938320a353264663234346465356666333233643533303962303134393331373137 -64316365363035346435613734656338333161613066393863363531646230346233633430623239 -61353437386434393135376234356464313533303861663662376434333838616437623132353438 -63333365353837313738313464306431313137356634323563356234356630316166303030313765 -61333134346237323261626662383833616236366132353333373532373130376332303664353164 -62363735613933626338376666353364366239353466646434373961623666663033363630306663 -32623132363836666365306161646631386631633966363034303932303361333834313931363034 -36643364353363323331643735636363323132336438383765363937356239666662336330653330 -32653364316363626636386232353334343337643163383435303339313937613965313963646666 -30356465653162336638313439613965316630656661333061663033643033653564353635386233 -38656636313137333464636431646239376661343833333239646161613838333131363031396233 -65326431323763336334613262363162643335656265326364383237386561366434656630666533 -63623037316264373865616230623465333638306561633332663366363461613935653462623863 -63346432383336333664346333623366323031316137313139303738306135636136346664376232 -65633030373838643363333839303432306632623437646331623336386264393439376139343464 -64346330623530663531653031316561646534663762653739363064353962386538666138323635 -66663639646264623765363763663030393564396335653864343061343036623135376463663565 -39343839333635636434336239353536363130396337633065643039316233666436623464633166 -64626461656634353239343239326130303935303663303464336633643961396664386265653339 -31343236376364316566363437653765373236653463623132626530626363373364353633376131 -37623831323334323439313563653734376361363361373431653862343561323133346532646161 -62633239363736643531623338353930396261303836646137393333373466363963336265656166 -37373631323836343833333263303037356435333961356466343438666663373965663563646533 -64366163366534333739366466656265326234333137313933663363653161393062363336393466 -30616635313737346133663163366331333161303163346239653266353862343564326434373935 -37626533646331346263333737633330373364396433323634313365343463373539626665343463 -39323635323161396238323439316334333362376561636565333939303562396534376337303662 -37373832386337326430386531623163353265303763363561353035653562666532316261323662 -33303536326437653065343464373261303062633930336564626539333163626530333363643033 -36383839386531613031383835623239366235393233373263373635656532646362343639356333 -62663934646237646134376238653265663539383039346138623065386564366138333461653639 -38363366386534663430636436613836383230663063326665636237656366376366653833396437 -66653162316138363037346165313235633935353038333465623238373337626134663531313135 -33666533396238306232366666666433653537643431363733643261663363336339633538386561 -64356161663737663566636361663038343331636437373462336665316337666232393135663563 -64323032343337626633356236356538366432643734383037336666366630633162386335363764 -34383035636639316362313962353439373062616165323163313963616464393866353638643930 -63633434366165306662383436643039653263386430623831623230616331333433346262636165 -62333863653634343530326335656666373731303236653636663739313031363334333038393662 -38616435646461646438303865666230636561643635626636393465313133646565356362643761 -62303565666132626534653734666237633762386266613330663237323631333562663232373731 -33353861313238363165626337363939376563343465306364373137623231313062633838303161 -66333038306666363030326566613966303036636563633862333738346233336335363238343966 -31656634376436366135643731663939353332633566323437653163323931393334633937656131 -34363133623865613061303338373038663165656230643030663037313934343231313233636236 -65623865623137333732303536393265353363393630343837656666616234393037316136343038 -39326466363836643937656163306661396239333665303133363133613066613034386162633361 -63353731393861396337313266633564396462393364643831333235366433303764303266613163 -30646630363862303965376636346133316135666535643135393935326138346162336436626533 -62346661333263636363313134336435323330646262303934346138663131333631326234353263 -38643165646131656639363235366530353366353464343361656536373639653238366438643335 -36376331316264333263613037636263386630306430623437383061383631366662633435643337 -37336236336164303839386536333630343363373066373534626330653532313335383863623866 -62376438616162343832613365333765306462636535346330373230333634383263323961363563 -62326363383464353536643035653966643239306338346238393838323363643134373363613231 -63653063333931303739623935626531376433333766666562633837623431313031653163373731 -39363238643064366133626662326335656331646238366565316463663265393630653839656331 -62323865346565323030396261316566656265346331316261393861303634363266323435303930 -37633765626637653666623663366664333837336166333464313865383234643531363438393837 -35656363396265666633316533376337323733363737633264326230663161623365653033376431 -38323332383635313339356339396535396263343036343861633530313537643766633432373336 -65316161316232326432623363633365326265653531613532396438623961326632636235396661 -37343939663837323864326237393632343537366166346537666136303961373436626663326463 -37376230646565343739376438633335613062633061333239326332656666623031393135376139 -66373665383935353830666535343965333637356561653066346364656665383134613931356261 -63623432353532373462613365326165643130393662366462303631396464306265363837306463 -37373262623864333833383463346233326130323662313763623861323430306163383538623331 -66366566626135623838656163373932386234333361383133623031663434373732356366303930 -30316662663534333765366531313162336361623065363061396135343837633962613165666435 -34653435353635653061656665363261613430623766333564343030326438343334363562373364 -36653034653631643566666562383663303434383238633033316330386664373764626330363837 -32313330373138386362366364326665373538613737343563343130623365373065363337353834 -35323935346466313564346261316633616133396532356131346635343038323434336535316633 -35613666323234633962313063333861643466643336386161623335386136663137643632623461 -30356665343234353061633163656230636233303634326663643336623739326639643735343237 -30633265386239306462643134323164393032363663353738633464313362666563303539326636 -61373738663932353137303639326435363062346234656561313039636365373133313331363634 -33336466373436663030623039306130346464356563303461633731316637336464353164356331 -32323764396431343763666363653430353232633563383436393533613234346237323735396435 -62666233366436333461626561613666643930626130623037643332386263366431376638623030 -31646538643130623261303662393338396338653939343066633863653439643263303364303334 -3666 +35393265373063353439653035346538396138393131373463643637303631623135383432613266 +3064313066393335656532343030356131313064333766640a333865363961363230323932373861 +38303336616631373862393537353536633733363434373064616138383565333334646432333037 +3434646561386239640a353036623935356632313766613737396635613032306364396139363265 +31343732303637373036303261643765326266643534623430623439393466663138616637643863 +31396531366636363730373532383139336531393438663866383936653365653030623039393962 +35363830636163653932633233306664613363326661336433353061326462376636376665303461 +37333563326130386565383035366333383835393736636561323066393933326261666363633436 +64303832356439386633353630653666373334393935633830376336636436656236663164323535 +63393866316538303766373966366336363132393863626434353035333838656535383438656362 +61623930313634636561633666623138656262393636323434613939396630313631383536653261 +39366434366566343361343761336565346465333239663338666662366234363662653330633566 +66363338336337646264633765303061353838636665346364316535333831326464373865613330 +62636630643937386137343431376239646434343035613261303037303861653336306331356231 +32663064613466613562656635336564356264643763653831306561313639666365396139313430 +38636336376230306338353966333533336164646132353666353735666531306538626237613565 +39643762333866313261666533316261343136303964636131313364653630616563353433363931 +63303634326532616561633963343463316565623938373335343066633465646263633334326433 +36396135646635376462336432663434613061303065653630663863323935643334343335656531 +36376165653062333138386366303339636433303633316435656263373431376636393139643734 +30323966303632303136636163363465396266313331623230373238633365653764646366666133 +37366263633834643763653338376664656438336461666230373937323031663031346533373735 +33316631666234646636373435363564343661633364333238653234316639623362383466646632 +33356630393438373636363066623466656663656364386132616563353231346136306661613030 +30656537323035333762656531333933393863393033613865386136636365333366643962393735 +31376137343663373638333261343064353633326431316638656335656466643431653866393736 +31333933383664626637636439633638366530373931356134343636636364623130616566326532 +32366635396165656261613666323464386261386165333761313265616234643036383431323739 +31346133363264626532666537303662653334363962623765383939333161376637313563636431 +62306230616338653936336364333635393839376631373965636631626432343535643532343437 +38626333363435623666643233663635613633626264666231613864313831613739653966373330 +35626462303339323930623164666663653738643531353661393036363936653134366633393866 +38353636363737613230633762316161636330646335316339313939303231636535386639353737 +35656530653066663638326432643538303263313739623439313439353532343739616162623163 +35636361336537303137396635643631393931653432656536326566383664333863363737323863 +32373733623862373162333330616431636565653964653831313638626431353139323138373331 +31333262396665303730633364393030346536623261363233376636356637646162313639376537 +39656261633764303561656132643133356539353835343632323935646161616366643764393234 +64313062643666323261623232613066353438336661326339306235626432366333663036666166 +37663233636366623439356632636438323637376164636564333064396563383231613933353665 +31613561316637383162333030353766396236616263396465323037326131636462373262346233 +31643064393538663263343433386430383539396233643739653039656266373434343930326530 +63373063323366313633626436303964643637666663636639396539653538356235336638636630 +65613666636239346337623461333264653735613066626366653238336165323662333538356333 +37323264363136613332663165306265363836633565353366366137306432363466666561646131 +61326336616461636633383366333838353262333339633331353863623963333462363430633364 +64363563316563613461373739663034663234633832306330316339316562643365393861623036 +32306634623263313334653432623266666165363236613939643539633930636539313364363866 +63366639343436303535653033303865666534613632363236656463666461333736663262643166 +61626135313566363733346165303931646462306337646366353533666439393138383362396638 +34356432303063396231393966333937663064323466643534353561643133393838626463386437 +33366164386339393661643334323462383333326230623862376464396137396136353339373762 +38393664623933356131323837353338303966326333316639633161376130666637333733363161 +64326536326664353663376338386361303063363964373330383633386238346331303531326630 +63653430366466323531633137616531333336333835303862363363373237303464396363353639 +37346364373737376135313162333335386439376538306166343937366337613030393933663861 +39333330653436633233343831623931383534346236646565356331353331373437333033386233 +64323966366536373566323934353030313235316430393138656564353538373439353236653638 +33623533366433666461633335303063383061393763663235336463393931393439303163663063 +37393663653438323232643439303061333263346161353065623632653537643839383865643534 +35653934396261323338343130653966396662626464643362363165333534336363346339363462 +36363032313465623936333861623530646465383136666138353935623630313939333338346334 +63663937363065343864373963373766376134623735303761623434626531656666343234316130 +66316265343964303339643334613763653864356131346366623664656130316132396438616434 +36353035336433383131376536646365316438313336613866613239363431373461663834313266 +63653764356237623436643333663861306339303835633931323830653465386662653234386630 +64366137633166336632376665616565333865306565353661653130626366346139326335653730 +62346133613931323466393934386463613663396234623166383861613936656164656665396435 +64643830613166366635623365623731643662366566653733313338333632626235383230313633 +34326430653630376661633066306464663435323234353566616363316466633366303434316432 +66646232636334386231623463326366316636636434303636643839636366616236323436393164 +62356537633237386130366161376264313661613136343261363338376661653330663130323336 +30396530643034623331666438383834666464303838353161653666393463386632633833663333 +31643232383666396666646639373464356639373762306538353333613239386437383530643662 +63303633376434303133376232306466323661393433386536313632353934386130346231333830 +63353733313866343735303233613165643263636338353432646238386332343339646439346237 +33326432633538616537636531386436353864653164393438646236343566313862636332633732 +31316464383531363563316536393634643431326362613334373037613930316630383939323739 +35336539343035633537653432636332646537393738313832373033326665393030373733646232 +37643036626461343563356431383730366361363636373063336136363137303236623165343331 +35303263383334316439346561373131363363306362343431663236376435373031306131643531 +39623561636637333066303431303961373236343539366237343234396539623631663762616262 +63363931376331663564616564623266636365373134343330636465346361626638373837663334 +38396135323164383334316165396338336666393239363535323764613063663365366261366531 +39343463326462376463336364376164373936656163366632636639643765653337303130613236 +61666433326632323763666563633232376566353165393562616166636634346433356431663463 +32366463356632653062633634303539336332326431396336616238623931336133363633653231 +37353837623166316135313730623963633663396463383339623336313139346464393731623835 +35316136366264326336333766653730636464373164666335643261343631346431356566656132 +31636466373039383335353839333538396539613864613039343630313335633164333438323033 +38626535396638336561363230633837653130633762363066653663363632376233623833623465 +31313835353765373934313763383736633837616238383063316564393462313533663764373533 +3161