From ff6a360b44e05bf79bdd3b9601ffdabfeea3dc37 Mon Sep 17 00:00:00 2001 From: ab77 Date: Tue, 25 May 2021 11:40:20 -0700 Subject: [PATCH] Initial commit * balenaCloud application used to configure balenaOS from supported metadata services * attempts to retrieve config.json payload from user-data and runs os-config * typically used with preload workflow * tested in AWS/EC2 * deployments orchestrated using balenaCI "docker" repository type/workflow * uses balenaCloud builders to push releases to both staging and production environments * all secrets encrypted at rest using git-secret(.io) workflow Change-Type: patch --- .balena/balena.yml | 5 +++ .balena/secrets/id_ed25519.pub | 1 + .balena/secrets/id_ed25519.secret | Bin 0 -> 1538 bytes .../production/balena_api_token.txt.secret | Bin 0 -> 1311 bytes .../staging/balena_api_token.txt.secret | Bin 0 -> 1311 bytes .gitignore | 5 +++ .gitsecret/keys/pubring.kbx | Bin 0 -> 5935 bytes .gitsecret/keys/pubring.kbx~ | Bin 0 -> 3476 bytes .gitsecret/keys/trustdb.gpg | Bin 0 -> 1200 bytes .gitsecret/paths/mapping.cfg | 3 ++ .resinci.yml | 23 ++++++++++++ Dockerfile | 18 ++++++++++ Dockerfile.template | 10 ++++++ README.md | 33 ++++++++++++++++++ balena.sh | 33 ++++++++++++++++++ repo.yml | 2 ++ 16 files changed, 133 insertions(+) create mode 100644 .balena/balena.yml create mode 100644 .balena/secrets/id_ed25519.pub create mode 100644 .balena/secrets/id_ed25519.secret create mode 100644 .balena/secrets/production/balena_api_token.txt.secret create mode 100644 .balena/secrets/staging/balena_api_token.txt.secret create mode 100644 .gitignore create mode 100644 .gitsecret/keys/pubring.kbx create mode 100644 .gitsecret/keys/pubring.kbx~ create mode 100644 .gitsecret/keys/trustdb.gpg create mode 100644 .gitsecret/paths/mapping.cfg create mode 100644 .resinci.yml create mode 100644 Dockerfile create mode 100644 Dockerfile.template create mode 100644 README.md create mode 100755 balena.sh create mode 100644 repo.yml diff --git a/.balena/balena.yml b/.balena/balena.yml new file mode 100644 index 0000000..cb5c31a --- /dev/null +++ b/.balena/balena.yml @@ -0,0 +1,5 @@ +--- +build-secrets: + global: + - source: id_ed25519 + dest: id_ed25519 diff --git a/.balena/secrets/id_ed25519.pub b/.balena/secrets/id_ed25519.pub new file mode 100644 index 0000000..202df67 --- /dev/null +++ b/.balena/secrets/id_ed25519.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK2R77+XZKfO0NnZGA0SPEZeGimopF/q4wJOwRxauM3F os-config diff --git a/.balena/secrets/id_ed25519.secret b/.balena/secrets/id_ed25519.secret new file mode 100644 index 0000000000000000000000000000000000000000..eea04c58015443c359c14f61b3253eb3df832622 GIT binary patch literal 1538 zcmV+d2L1Vk0gMAL;%QPN+%}8>3;?Bb>WhU&9jT8ii4x1U8ScucWkXKa1TwmnF^HMH zF@OgJ$~R$pVabYp++xE&Eaqd!R2tLxSQ*}x8E{+J_}m$y#YP8uFa5G4QPh~ZI~}OJ zY$UnS^JgUsR2KD?m-M{Ac1x@)4h-)GFUy<#1jAyNriL))7kXcv&=8S7NZ;vd^X>i49v2_t)y ztY1JiJ%3SpS&$Qo02Y#XJ!ITGNy}Lf4#NtZE)|~EzvnO54dbDT&a~%1p5e`lDhq-U zcZC8A18r3&b(*#IECCPpI$gHSvn;d8WrsL+g0P`~dWj)^USXqZKGD;-bItUP4W>)t zmnFJ8Pb_e#6DTLhOP<`TsDCDBl&$RiG+~Ot<9N2=Gp^-id#rxzXtlk&*_|!)*rapz z?W$W;62Kf-H8&P;PI88UMRT{w1C@>015C%CO{#p%TGU70MZw}k>OS(Vq0KF+J77^b zD4aU9*VR#`>e|H#RP0aGN=sE#at?K-=KI`=3J4S=HtZdfLWfpy;FhNN!fwBv(xBa*tmER--hs6Hqb+5F zbqfcv;_W52M&gL*8ElH5b^?CZo?ZWgrPeJ(`m{c6y6Q@%=6ejCz`}XF zKHq$>6vt@-ks$b$F`HD2@^$o^SKVr{a)-XjBLYgBQV%Zc9_`v$g*^3EF^18QYW|U8 zJvC3HaIB|JK^%wp3;01m{kEcFTTiJUS1wLVeDEg$m0x z1yB-CP6Xtvz*qZR;WWlaWC4tkg`(X1J&bl&&jL<0KZ-Uy)o05#aF&H3Rz2^7^vR70 z1b+R;*V#_ez>@*1`Ce#vnoSqER^`Glx#}7tzjNe@B>uhpriTb5&ty@gLYL*3SYXh0 zgMH!!Vv7N?=+{aupvtQ9Zb;BUz*hq^kmg&RR z#)_k#3f}=Za>Cd*XNR18NFOGhb{`HuALgJl2h*p5`lJOCXDm2@dZ%9V@Y#p|gIQf_ zI{eHRtQYFW()!4c3I^2!Jn0Y0d2eh~!P{k?38u*Mq--2J{JisxY_zHJ6i8D&r3jBE zvL}92!kS+pvd1|M;Q&~Mh79t3SL!}4hEYPm;{%mk| z?pHn!)Ed|_wZyGJBT7&Z#5B5wnNk|!TH&aq!kKVof(Fsn^_M+{$3}S$?qkd8h2!pkL<0jiTn!WPgGaGaES^xk5 literal 0 HcmV?d00001 diff --git a/.balena/secrets/production/balena_api_token.txt.secret b/.balena/secrets/production/balena_api_token.txt.secret new file mode 100644 index 0000000000000000000000000000000000000000..bb367ee0f506533174371fe7b80d0640aacb5312 GIT binary patch literal 1311 zcmV+)1>pLH0gMAL;%QPN+%}8>3;>;TM6=->iq8B7f=1#3$V#XhGIV=FW49jF$==|# zwA2ePq{B}~Y}|yD5U%cm=a*Fp(hx4>J8k)`v#nN6=N|RI(jcheb~RP~H0;TcsWSFm zzlEe)mIZpWJ!~5OymGxLUpn@eq7)MEX-~&mIb?sjHeJn-I_2s#CWgAFO*i^*4$mO6 zM0DKT7@hJl#H58-pxsyBt!Y$tyXi9OoVAVX)c5^W^MuyqBIr9}8+E7yPYQzLZi}$%Z zSNoF(C7eQjChaoW>=b*f=pgU7GEF?!x5leBdP~3Nnhop~oECQ2eq1PRUD_XZ;$tgX zy>{MLnhk;7;)5MsM#1*V4z+Uyr4+TtoQ;{dAg*3H9Is)ZL&fZ2+{EwQmzlE}^xMGO z0du)tx{ETSl@EjB3mbfJdqS|E1S1*{l;(E(0Y8kkd(F3Wr@cq>f`Ekq33Q_wOz z`yI<9f30}-JwCznJ%#RBSb4FDgtt*)X{h&!H^<=aC@9rTithG&Z##lamy;q^}RMXC;XV#ZoZ`fmp9}(@c5@Ow!+Z_TGp6ZoFWC>4UoqE zTemfRAje{du9^u6(=;-jZJ4zSJRoMco`u~*ykhP7?OFbgpUkST2?p{@VA6pFv_$q{ z%N)KCh%Dq>MKP@pm&pf&HpSZ5YY4GmrAjyKgF_mptsBB@S|+Q~*J!og#U5aNM3u&< z?S%pi18r3&b(*#IECCPycKli+fmL`QrSDTqsFuUoi7Ht(V4S0)n^ok!7AVUiyjnL0 z#o&h_{S~1IvH-{HWd*sgkrRsL=nJwY{We&4c0_Yo_zV@S02X>U#q(7ZL*ma|)|~_e zTR)n=>cpZ8!yq&!H|2)yth8YJSflsE{=1~XRpK+5>R_I&>%b`J zjJ7&?bk1U0N55(+#U1UMbNZ|;?Lw=BaL93Lu&)S7l90H4*@^;4Z-ampc36U*FfCVU1sWmB? z2lgH}@Y&}ebrb1-t#`ibI%h2>ng41=+2ySH7pX{#aIZPf`X+H@x=K8MWA9K#I>M~L{i=ZnV=fEbbh!98 zwpgt0`i{M-(r^L6Iw{+6dAPJ-hS7fjh|+Bxv+xC=%ICpP2C~n78Q-wz^-$}wR>Km# zRMS%UE(;QbaO9}@Zr;m=f9TQ%zf0Y(9Xj}*#?r5*Fbc}}J*7Zcs|pI8yu(cx2Vn4X VyM;9os%> literal 0 HcmV?d00001 diff --git a/.balena/secrets/staging/balena_api_token.txt.secret b/.balena/secrets/staging/balena_api_token.txt.secret new file mode 100644 index 0000000000000000000000000000000000000000..329f1dbfe748bea978ccf4099c7f220b76295023 GIT binary patch literal 1311 zcmV+)1>pLH0gMAL;%QPN+%}8>3;r$gd<7v5m9!K}km-=u->jQVR2}ayD0Uc3f_mZw z__ym~BDqs&dyFm{c+u%GpT}Hz&PWN#*Un`4?3EP9_ZBGLRF3?)#{z}m0}2}h=h_D?! zT^ny~9*T8*aB4yxpAUl-;Sb9UV6jPUCRfZ@Nzd1j{!FiE{lp!JzZL_rz{Z`4N^U{_ zKZd*9yL5qQmsYx;P4g-yAifcQ!>aJ_C)Ew39TWyU3>Fj(7tKcMq+x(7t`owiygZJiM zS-3O?S{cbRrlO&yZ$j^Fx$t{RMyq-qRkyiYl3 zwIta`0q!)qZ9cPqaYWLll&?~Jkl^|7NKIw@JqaWvm~4>5L$xKunyAc`-4TXZ_F&{{ ziG>0T18r3&b(*#IECCPyTuPG(Ta~VuZ3r|YRJDX_l0-7+{8*KXETpjJQwJTGNYs4| zHPVR7sw@}SR?AwR*x~?KB-RV4J^Wu701oP3k`nh6y5-Yg)$Dl*nj3quWIOKQzv$3Y)3SVN zpveRCuVyX&?MdJS&oarq?e{*S38$ zaczAQ#8c{qo!gorCS|AubxQU%j}_GE`{U!J38UzJv%y6L@ON1k)vMt&>3o_V9?gAj zQE`64!&)9E7Y<2G>VUHQI7rFc0_Y%$1%oi+YYdszk+$n}o z!>u8(8klHY(r^I=rM&@vTosdO9t!pho3I)g>6ZUR3tARKyWQV1Kk^shzF8zaRJ&2& zP`AugLijXwOaSk3KKg(ft^%&K6scE1tz>yyvhOGbq literal 0 HcmV?d00001 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9301a1a --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.gitsecret/keys/random_seed +!*.secret +.balena/secrets/staging/balena_api_token.txt +.balena/secrets/production/balena_api_token.txt +.balena/secrets/id_ed25519 diff --git a/.gitsecret/keys/pubring.kbx b/.gitsecret/keys/pubring.kbx new file mode 100644 index 0000000000000000000000000000000000000000..a39a8a985e5c6271db3042b52a4a3e7bfe25c47b GIT binary patch literal 5935 zcmai11yodRx1JfgOG2pu1VMV}?(Pmjx_f4j7U^zj0R^N>q)R|jgprUTRQPC+1_6h< zpug+8|6SjI|97o(&U^OW?^$P^_ldIs000;W1c20JjqL$9!?M~k?)JEy{~lQLAmFdr zQvd)<1porjh#ek>t_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--git a/.gitsecret/keys/pubring.kbx~ b/.gitsecret/keys/pubring.kbx~ new file mode 100644 index 0000000000000000000000000000000000000000..e402a7453a0a1e05bd683846e4896f55e5760850 GIT binary patch literal 3476 zcmai#2UJtZ8pm%!D4{AyQHr66AUz;G1R}k65J737lRy$Wh``dDh=_oS6e&VPSwa;A zr7I#us)Z#|rK6$&Fu66c8&x~w`bp$RT9Hw6t*M;dFV`fEYR`ZlfBvT6p-`3+dH;p^ zhx(UFGm#w4VrJU`+mb6~te_$-;v zCSg+2R;eCMd=FE1SuffmF7%rPPWmkjV9fn>PP#=8*_{2+_NLjPe|re71=e6 z6-@MA*cp^5y?WE5w#7c}b#(~bAar%JI$iehvfZ#aNzZS+`j#UKuBNwQV9_2qC-9&? z`j&hCHSn^J=Xz$1@b#=DkujIp>EI{p7fM<~A_A;LAIBv^CFj|LF=B%=eg5xXzY2x6 zlq*d>4g3sEzxfcUcE39>NKGC#|t+^`roY!D8QhUs||^n+Ys zICKCO?@g@;6Njn)Ow#KlPFfdI{kGF#yV3f{?!xB`x?+JYZfLS|%t1 zJ(!M@5z4>>hH!ytKwtq7nEMLA2tD#k!EG;@fx5T9%i>)kIOOpl=Sz>yE9wGlY=z@1n~im)*$Z#%8bfYk zH1sZQWMBqQjihD!I*>#y%83+b=4JKF+g(*bcUzvj#n2Q=rFysYft}O5GT+GBy&R`A zHxLh6okTivZswT24RS{3V#ks?japO zL)911^q21!mK7xf9Uee>{V%^+eDYfxnGC(XP*tRVo-Qv`(Xq`)f_VLjM~qjv(7_fz zNqkG<{2%G?bOzdrUO+MTo8A?P zGRjMOL%v~i6qrbxUtTMa&zKjGvM(1pAlJ^s_IrNT?8O6rRX7_5o!*1Zs;+Da;<<9} z9^x~_=?Z?8>@GzsDZ(EU8I-_aZ$eu=My0rHM23)g59E*Ch@te2n6Yv}kU|Ocu_=Ad zFQl81(sp+$}s8wz`6C);WnYuPh?GX!np-Dl3{V~lX ziWfQZbq!$1*_NGG}s5sQZC!6 z@Pv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N^u_tLRC9 z>S&LCd=7Y(w$<=Rj0NM#n&c@C0jYOerm|V?M_;A1X${y69!u12s8=`Db*+8R!pMV> zJ4sfC#+!m4qJok%lX8(a7p&+SJZ!%YC>$5+Rp#B31qW>T_=AUvq1j8>`L5&%Je0N3* zGnOi4#!ZX6iOQmtTHhx(5n;!`;VrvYe1*AEIaFYc$4(&5#j)S)2)1*&UYy({D2^y# zuAIAO`tmt{zifK#R7HpUb~FOgxq5G?vJ#0gep<7Z7c#bfQEx~%(N`+tYk8C$-_u7r zok>d{SGIi$c#CI3=jsJ%S0yff0cu)Cjt^v~zyxN5qG924zVDW2g#B#2zk^?hpF23J zmee%39M7F0SjuCrv3AcezvIRYqkaER2bEh&=!mQ40Z#HWK54w}lumXcF7Q$OT;`GZ zaYggNw`j0iIq(w6`L literal 0 HcmV?d00001 diff --git a/.gitsecret/keys/trustdb.gpg b/.gitsecret/keys/trustdb.gpg new file mode 100644 index 0000000000000000000000000000000000000000..9009cffdaf382878663e4774593c54e697753c78 GIT binary patch literal 1200 zcmZQfFGy!*W@Ke#Vqi#Eo6yaG9WZiX7sn7CRfiEIV1dza84VXu2#lr!%F+P /root/.ssh/id_ed25519) \ + && ([ -f /root/.ssh/id_ed25519 ] && chmod 600 /root/.ssh/id_ed25519) + +COPY balena.sh /usr/local/bin/ + +CMD [ "balena.sh" ] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..10a08cf --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +# cloud-config +> balenaCloud app which is usually preloaded into a balenaOS image to automatically join devices to the cloud using `config.json` data passed in from supported provider metadata service + +## create keys +> [update](https://github.com/product-os/balena-concourse/tree/master/provision/app/console) local GPG keyring with public keys from GitHub + + git secret whoknows && git secret reveal -f + + [ -f .balena/secrets/id_ed25519 ] \ + || ssh-keygen -o -a 100 -t ed25519 -f .balena/secrets/id_ed25519 -C 'os-config' -N '' + + PRIKEY_ED25519=$(cat .balena/secrets/id_ed25519 | openssl base64 | tr -d '\n') + + PUBKEY_ED25519=$(cat .balena/secrets/id_ed25519.pub) + + git secret add .balena/secrets/id_ed25519 + + git secret hide + + +## deploy (manually) +> (e.g) staging + + git secret reveal -f + + image="$(yq e '.docker.builds[] | select(.args[]=="*staging*").docker_repo' .resinci.yml)" + + for ev in "$(yq e '.docker.builds[] | select(.args[]=="*staging*").args[]' .resinci.yml | sed 's/"/\\"/g')"; do eval export "${ev}"; done + + docker build -t ${image} \ + --build-arg "BALENA_APPS=${BALENA_APPS}" \ + --build-arg RESINRC_RESIN_URL \ + --secret id=balena-api-token,src=.balena/secrets/staging/balena_api_token.txt . diff --git a/balena.sh b/balena.sh new file mode 100755 index 0000000..9d0cbef --- /dev/null +++ b/balena.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +set -e + +metadata_urls=( \ + 'http://169.254.169.254/latest/user-data' \ + 'http://169.254.169.254/metadata/v1/user-data' \ + 'https://metadata.platformequinix.com/userdata' \ +) + +curl_with_opts() { + curl --fail --silent --connect-timeout 3 "$@" +} + +ssh_with_opts() { + ssh -p 22222 \ + "root@$(ip route | awk '/balena0|br-[0-9a-fA-F]/ { print $7 }' | head -n 1)" \ + -o 'StrictHostKeyChecking=no' \ + -o 'UserKnownHostsFile=/dev/null' \ + "$@" +} + +config_from_metadata() { + #shellcheck disable=SC2034,SC2039 # /bin/sh is a symbolic link to bash on balenaOS + for url in "${metadata_urls[@]}"; do + user_data="$(curl_with_opts "${url}")" + [ -n "${user_data}" ] && echo "${user_data}" && break + done +} + +ssh_with_opts "os-config join '$(config_from_metadata)'" + +exec balena-idle "$@" diff --git a/repo.yml b/repo.yml new file mode 100644 index 0000000..545c520 --- /dev/null +++ b/repo.yml @@ -0,0 +1,2 @@ +--- +type: "docker"