From dce3be313327f077a941ddf3d2a004023cf1dee5 Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Wed, 13 May 2026 02:13:49 +0200 Subject: [PATCH] several improvements --- ansible/host_vars/iotstuff/main.yml | 2 + ansible/host_vars/iotstuff/vault.yaml | 64 ++++++++++----------- ansible/roles/iotscripts/defaults/main.yml | 7 ++- ansible/roles/iotscripts/files/ledpipe_restart.sh | 3 +- ansible/roles/iotscripts/handlers/main.yml | 3 +- ansible/roles/iotscripts/tasks/build_go_local.yml | 32 ++++++++--- ansible/roles/iotscripts/tasks/main.yml | 4 -- 7 files changed, 64 insertions(+), 51 deletions(-) diff --git a/ansible/host_vars/iotstuff/main.yml b/ansible/host_vars/iotstuff/main.yml index 628ccae..0946601 100644 --- a/ansible/host_vars/iotstuff/main.yml +++ b/ansible/host_vars/iotstuff/main.yml @@ -1,4 +1,6 @@ --- is_lxc_container: true +base_managed_ntpd: false + realraum_member_count: 82 diff --git a/ansible/host_vars/iotstuff/vault.yaml b/ansible/host_vars/iotstuff/vault.yaml index 7afa9d4..2c1d15b 100644 --- a/ansible/host_vars/iotstuff/vault.yaml +++ b/ansible/host_vars/iotstuff/vault.yaml @@ -1,33 +1,33 @@ $ANSIBLE_VAULT;1.1;AES256 -34633133633836363765333563633034323131306134356236633764386230613261326465363864 -3438356633313232656338376538656336313838393130620a313232336633343439353438646532 -30333330643266313036376565346539316633646135343135363865643138656532653364343666 -3338363831303639620a643965366433363831646630656539383738356165343839646531343266 -61343432646563333565333234666634356137613830616664356362323961316335356231386561 -62356433653761373136386236663066376166613435386436653633393662306164663631666337 -62353034323339666537366662316234613337646538393065656534363330323162346338656134 -32376136373663313764626361373939656663393561393562366232656266343962313766613639 -63626330313564313733636634366633353533343336363064366639616364346333666233353832 -66333362333632633530353564333263333463303366356439303237373163373466343532373932 -36353537656630393335316333386663633737303965373635376434383134386230303765613633 -63663830356230336536663064653334386537653062653030636430393137373961373937666637 -30663634303565376236376563643631366233346231663439343039663064643261623133646237 -38633535343533386231366661323130666636356663626166303030313034326438363733363539 -38633664613233346339313630373965613962343861343636393138363839656464653533303066 -61333036643636333939373164363663346561393334623639323966636237616332306564356163 -37323139653164366236643239303838326466623263626337613337376530616161376432623063 -35666339363762316563653831613135366365643535396633383835313163616662366633343933 -36386631353934613334383031623061303664616162376135663535623363663161666639623635 -61383236653063323732623530633338663964656362396636626630363436343163393730316631 -33643866363535666363353364623732386436643861306131653163346432656165353965346630 -64396361353765363231383832656635623438333932373138353161643937346536323038613336 -34643234323436333238393163303434313337616463666537616437363364346331376632616662 -35613736346537336436383063663563323866393364373430356666326233353139396138386432 -62326631613639633663643261393362346661336335643062336430363433386639613339633236 -33383336633639326633346437633236613363353462326265656665633963623938663236633035 -36623334303432623633623030343937373134393731396539336163653231396532326234643966 -31383362383639363538646665326465356632363062303336336533656331346236393462363261 -37393166616139656161366463326265356564656264336565366333393332626134353439386466 -37353866653237663538633632663138336463303062396538613863303631383438656666313165 -32386535313633313461646266383939393939343930316666653438653061383962346665663963 -62343164393935376235 +32306234653735623830346364613535396335343962313661333962643335613430306631616561 +3738623233363939383964623064656336633734623032650a346432313538633361356365376163 +66313663343830376334376533653231333537373561626332643562636461303237633736646363 +3132643932323562370a313330393966323739393565383034343966353231306563396135323965 +64636365343964376564333131633762613930373965323730353932386665386233613939373333 +36346264333733373463626434343763363663353763303037666362643065313461373561393266 +63313431346339376230396135623636353236383263373562313134383639333631333139666133 +35646437323161373338333930316263643033363665383738313664386361353139616334353338 +65653564376562613930306235353934333932303936646332666139343833386162613739343362 +31653738626435363663613263666535383032346233656237343166643132393435343233666461 +33343165643063323138663966393763636333616232383530656539336632653131326336316336 +64633439353233386164393861336162636334383365653331363762363264393739656432383834 +63363337366531393561653766343730623233333731623636393634663030626630323834623934 +31376432376536656334303233303939343466666230663230623831633731343164643565343763 +30333635623537663363376339376166623963393337663731363465633133653863363734613639 +63623037383138373038663465396432353730653931623861663764346365623036313865626233 +36343063303536366230386133363165653835363235643035396637316464353536623231366137 +62333237373838316163313561633363613031313937616636373564336631336532663063646234 +65653034306466396230666133393539343962623337366534373133633533643638616239653961 +36633638663937363965626339636236633130343936383532653336663465393534623361353734 +66623831313638633166663666366532333038373738353764616539356439396638666239356334 +66396536373439613031643338633432343636323137383238386237636630373533626532366662 +36623136386533633435623135333533363762353439373365393537653964636437616136363539 +61383838366634663537663566613666366562323462313461656639333166393862313539613139 +33353134643435353766623365376463656439663333356630386563643262346163643334316436 +65393730616266616361666164613561613235636665336163333832393736313239653834376262 +61353837666263363938336362393561353965643332616265313831386331633337366634323835 +62656364353137633164353239346236613437353834366134316464643531653664373861613365 +32376137623435323566663963623863386161663637376136323434316439383961383534346639 +32336664393562356236646335386336643164316233396137356262623336656332366163363839 +36373362393831343632616432323733363633666165386239613533656437376564633530633033 +32323032353331623661 diff --git a/ansible/roles/iotscripts/defaults/main.yml b/ansible/roles/iotscripts/defaults/main.yml index f96c23e..d539af2 100644 --- a/ansible/roles/iotscripts/defaults/main.yml +++ b/ansible/roles/iotscripts/defaults/main.yml @@ -5,9 +5,6 @@ realraum_bin: /home/realraum/bin realraum_config_dir: /home/realraum/.config/realraum realraum_systemd_user_dir: /home/realraum/.local/share/systemd/user -door_and_sensors_repo: "https://github.com/realraum/door_and_sensors" -door_and_sensors_ref: "master" - # Architecture of the target host go_target_goarch: "amd64" go_target_goos: "linux" @@ -24,8 +21,12 @@ python_scripts: go_binaries: - name: r3-metaevt-maker subdir: r3-metaevt-maker + repo: "https://github.com/realraum/door_and_sensors" + ref: "master" - name: r3-spaceapistatus subdir: r3-spaceapistatus + repo: "https://github.com/realraum/door_and_sensors" + ref: "master" systemd_user_services: - dostuff_switch_lights diff --git a/ansible/roles/iotscripts/files/ledpipe_restart.sh b/ansible/roles/iotscripts/files/ledpipe_restart.sh index 47f7a4b..e58c7be 100644 --- a/ansible/roles/iotscripts/files/ledpipe_restart.sh +++ b/ansible/roles/iotscripts/files/ledpipe_restart.sh @@ -1,2 +1,3 @@ #!/bin/zsh -nc r3lothrpipeleds.iot.realraum.at 23 <<< '_G.node.restart()' +timeout 7 nc r3lothrpipeleds.iot.realraum.at 23 <<< '_G.node.restart()' +exit 0 diff --git a/ansible/roles/iotscripts/handlers/main.yml b/ansible/roles/iotscripts/handlers/main.yml index e9afc15..e74b2ab 100644 --- a/ansible/roles/iotscripts/handlers/main.yml +++ b/ansible/roles/iotscripts/handlers/main.yml @@ -1,9 +1,8 @@ --- + - name: Reload systemd user daemon ansible.builtin.systemd: daemon_reload: true scope: user become: true become_user: "{{ realraum_user }}" - environment: - XDG_RUNTIME_DIR: "/run/user/{{ ansible_facts['getent_passwd'][realraum_user][1] }}" diff --git a/ansible/roles/iotscripts/tasks/build_go_local.yml b/ansible/roles/iotscripts/tasks/build_go_local.yml index e9b08ad..7533dd5 100644 --- a/ansible/roles/iotscripts/tasks/build_go_local.yml +++ b/ansible/roles/iotscripts/tasks/build_go_local.yml @@ -8,23 +8,30 @@ become: false run_once: true # shared across all binaries; repo cloned once -- name: "Clone door_and_sensors repo locally" +- name: "Clone repo locally" ansible.builtin.git: - repo: "{{ door_and_sensors_repo }}" - dest: "{{ local_build_dir }}/door_and_sensors" - version: "{{ door_and_sensors_ref }}" + repo: "{{ go_binary.repo }}" + dest: "{{ local_build_dir }}/{{go_binary.name}}_repo" + version: "{{ go_binary.ref }}" force: false delegate_to: localhost become: false run_once: true +- name: "Run go get ." + ansible.builtin.command: + cmd: > + go get . + chdir: "{{ local_build_dir }}/{{go_binary.name}}_repo/{{ go_binary.subdir }}" + delegate_to: localhost + become: false + changed_when: true # always rebuild to pick up upstream changes + - name: "Build {{ go_binary.name }} locally (cross-compile)" ansible.builtin.command: cmd: > - go build - -o {{ local_build_dir }}/{{ go_binary.name }} - ./{{ go_binary.subdir }} - chdir: "{{ local_build_dir }}/door_and_sensors" + go build -o {{ go_binary.name }} + chdir: "{{ local_build_dir }}/{{go_binary.name}}_repo/{{ go_binary.subdir }}" delegate_to: localhost become: false environment: @@ -35,8 +42,15 @@ - name: "Copy {{ go_binary.name }} to target host" ansible.builtin.copy: - src: "{{ local_build_dir }}/{{ go_binary.name }}" + src: "{{ local_build_dir }}/{{go_binary.name}}_repo/{{ go_binary.subdir }}/{{ go_binary.name }}" dest: "{{ realraum_bin }}/{{ go_binary.name }}" owner: "{{ realraum_user }}" group: "{{ realraum_user }}" mode: "0755" + +- name: "Clean up local build directory for {{ go_binary.name }}" + ansible.builtin.file: + path: "{{ local_build_dir }}/{{go_binary.name}}_repo/" + state: absent + delegate_to: localhost + become: false diff --git a/ansible/roles/iotscripts/tasks/main.yml b/ansible/roles/iotscripts/tasks/main.yml index 4430e91..ef55c79 100644 --- a/ansible/roles/iotscripts/tasks/main.yml +++ b/ansible/roles/iotscripts/tasks/main.yml @@ -112,8 +112,6 @@ scope: user become: true become_user: "{{ realraum_user }}" - environment: - XDG_RUNTIME_DIR: "/run/user/{{ ansible_facts['getent_passwd'][realraum_user][1] }}" loop: "{{ systemd_user_services }}" - name: Enable and start systemd user timers @@ -124,6 +122,4 @@ scope: user become: true become_user: "{{ realraum_user }}" - environment: - XDG_RUNTIME_DIR: "/run/user/{{ ansible_facts['getent_passwd'][realraum_user][1] }}" loop: "{{ systemd_user_timers }}" -- 1.7.10.4