From c569e02d8ab5ebcbb5a44e10c14799fa097c9bc7 Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Wed, 2 Nov 2022 13:08:03 -0400 Subject: OBS overlays, starting to get publish and edit on res --- README.org | 27 ++- common-playbook.yml | 4 +- group_vars/all.yml | 5 + roles/caption/templates/process-captions.py | 12 +- roles/edit/defaults/main.yml | 3 + roles/edit/tasks/main.yaml | 11 - roles/edit/tasks/main.yml | 32 +++ roles/edit/templates/emacsconf-edit.el | 52 ++++- roles/obs/overlay.svg | 301 ++++++++++++++++++++++++++++ roles/obs/tasks/main.yml | 14 +- roles/obs/tasks/obs-setup.yml | 32 ++- roles/obs/tasks/track.yml | 15 +- roles/obs/tasks/user.yml | 3 +- roles/obs/templates/mpv.conf | 2 +- roles/obs/templates/scenes.json | 77 +++---- roles/publish/defaults/main.yml | 4 - roles/publish/tasks/main.yml | 93 ++++++--- roles/publish/templates/emacsconf-config.el | 28 ++- roles/publish/templates/git-config | 8 + roles/user/tasks/main.yml | 31 +++ 20 files changed, 641 insertions(+), 113 deletions(-) delete mode 100644 roles/edit/tasks/main.yaml create mode 100644 roles/edit/tasks/main.yml create mode 100644 roles/obs/overlay.svg create mode 100644 roles/publish/templates/git-config create mode 100644 roles/user/tasks/main.yml diff --git a/README.org b/README.org index 31a24af..2c53f3e 100644 --- a/README.org +++ b/README.org @@ -57,8 +57,24 @@ git remote add docker ssh://ikiwiki@127.0.0.1:2222/var/www/wiki.git Debugging ssh wiki 'cd /var/www/wiki.git; git update-ref refs/heads/master HEAD^' && git push docker 2022-pages -** Publishing -*** Prod +* Publishing + +Goals: +- [X] Set up Emacs 28.2 or a newer one +- [X] Check out the repositories +- [X] Load the configuration +- [X] Publish the backstage index +- [X] Publish the watchpages +- [X] Publish schedule to the wiki and push +- [ ] Have nice interactive setup +- [ ] Publish backstage index on a hook +- [ ] Connect to IRC and announce talks +- [ ] Push talk info the text files on the stream +- [ ] Start mpv in the right display +- [ ] Publish the prerec files +- [ ] Publish the prerec on the page + +** Prod To run the playbook and publish the main schedule: #+begin_src sh @@ -76,7 +92,7 @@ ansible-playbook playbook.yml -e '{"slug": "wayland"}' -i inventory.yml --tags p Force-publish the schedule: ansible-playbook -i inventory.yml prod-playbook.yml --tags publish -e force_publish=true -*** Docker +** Docker Creating: ansible-playbook -i docker-inventory.yml docker-playbook.yml --tags wiki,publish @@ -193,5 +209,10 @@ xrandr -s 1280x720 Firefox profiles like to be created in an X environment firefox -no-remote -CreateProfile "{{ emacsconf_id }}-{{ item.item.id }} +Update scenes from the gen copy: +ssh emacsconf-gen@res.emacsconf.org "cat ~/.config/obs-studio/basic/scenes/gen.json" | jq 'walk(if type == "string" then gsub("emacsconf"; "{{ emacsconf_id }}") | gsub("gen"; "{{ item.id }}") else . end)' > roles/obs/templates/scenes.json +ansible-playbook -i inventory.yml prod-playbook.yml --tags obs-scene + + Update scenes from the dev copy: ssh emacsconf-dev@res.emacsconf.org "cat ~/.config/obs-studio/basic/scenes/dev.json" | jq 'walk(if type == "string" then gsub("emacsconf"; "{{ emacsconf_id }}") | gsub("dev"; "{{ item.id }}") else . end)' > scenes.json diff --git a/common-playbook.yml b/common-playbook.yml index 5c6cf83..a3377ea 100644 --- a/common-playbook.yml +++ b/common-playbook.yml @@ -5,7 +5,7 @@ - wiki - name: Set up publishing hosts: res - tags: wiki-publish + tags: publish roles: - publish - name: Set up interactive editing @@ -53,6 +53,6 @@ - media - name: Set up OBS hosts: obs - tags: obs, wip + tags: obs roles: - obs diff --git a/group_vars/all.yml b/group_vars/all.yml index 360c7af..925a944 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -24,3 +24,8 @@ emacsconf_tracks: icecast_emacsconf_user: emacsconf emacsconf_home: /home/{{ emacsconf_user }} emacsconf_font: "Sans Serif" +emacsconf_email: emacsconf-org@gnu.org +emacs_config_dir: ~{{ emacsconf_user }}/.emacs.d +emacsconf_el_dir: ~{{ emacsconf_user }}/emacsconf-el +emacsconf_edit_wiki_dir: ~{{ emacsconf_user }}/emacsconf-wiki +emacsconf_private_dir: ~{{ emacsconf_user }}/emacsconf-2022-private diff --git a/roles/caption/templates/process-captions.py b/roles/caption/templates/process-captions.py index 50c62d1..223531b 100755 --- a/roles/caption/templates/process-captions.py +++ b/roles/caption/templates/process-captions.py @@ -95,7 +95,7 @@ def get_files_to_work_on(directory): else: val['base'] = os.path.join(os.path.dirname(val['video'] or val['audio']), base_name(val['video'] or val['audio'])) - if ALWAYS or (not 'vtt' in val or (DO_SRV2 and not 'srv2' in val)): + if ALWAYS or (not 'vtt' in val or (DO_SRV2 and not 'srv2' in val) or (not 'txt' in val)): if not 'audio' in val and 'video' in val: # No audio, need to convert it val = extract_audio(val) @@ -142,12 +142,18 @@ def generate_captions(work): result = clean_up_timestamps(result) with open(new_file, 'w') as vtt: whisper.utils.write_vtt(result['segments'], file=vtt) - with open(work['base'] + '.txt'): + with open(work['base'] + '.txt') as txt: whisper.utils.write_txt(result['segments'], file=txt) work['vtt'] = new_file if 'srv2' in work: del work['srv2'] return work +def generate_text(work): + with open(work['base'] + '.txt') as txt: + for i, caption in enumerate(webvtt.read(work['vtt'])): + txt.write(caption.text) + work['text'] = work['base'] + '.txt' + def generate_srv2(work): """Generate a SRV2 file.""" log("Generating SRV2") @@ -218,6 +224,8 @@ if len(needs_work) > 0: # word_cuts = align_words(cuts) # convert_cuts_to_word_timing(audio_file, word_cuts) log("Done %s" % str(work['base'])) + if not 'txt' in work: + work = generate_text(work) needs_work = get_files_to_work_on(directory) else: log("No work needed.") diff --git a/roles/edit/defaults/main.yml b/roles/edit/defaults/main.yml index ea0fbdb..d57c511 100644 --- a/roles/edit/defaults/main.yml +++ b/roles/edit/defaults/main.yml @@ -5,3 +5,6 @@ emacsconf_edit_packages: - vertico - magit - modus-themes + - hydra + - orderless + - projectile diff --git a/roles/edit/tasks/main.yaml b/roles/edit/tasks/main.yaml deleted file mode 100644 index f77535f..0000000 --- a/roles/edit/tasks/main.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -- name: Set up Emacs configuration for interactive editing - template: - src: emacsconf-edit.el - dest: "{{ emacs_config_dir }}/emacsconf-edit.el" -- name: Check if Emacs base configuration already exists - lineinfile: - dest: "{{ emacs_config_dir }}/init.el" - state: present - regexp: "emacsconf-edit" - line: "(load-file \"emacsconf-edit.el\")" diff --git a/roles/edit/tasks/main.yml b/roles/edit/tasks/main.yml new file mode 100644 index 0000000..f864b23 --- /dev/null +++ b/roles/edit/tasks/main.yml @@ -0,0 +1,32 @@ +--- +- name: Check if Emacs is already set up for publishing + stat: + path: "{{ emacs_config_dir }}/emacsconf-config.el" + register: publish_config +- name: Set up for publishing + include_role: + name: publish + when: not publish_config.stat.exists +- name: Install Emacs packages + shell: | + emacs --batch --exec "(progn (require 'package) + (let ((packages (seq-remove #'package-installed-p '({% for package in emacsconf_edit_packages %}{{ package }} {% endfor %})))) + (when packages + (package-refresh-contents) + (mapc #'package-install packages))))" + +- name: Set up Emacs configuration for interactive editing + template: + src: emacsconf-edit.el + dest: "{{ emacs_config_dir }}/emacsconf-edit.el" + owner: "{{ emacsconf_user }}" + group: "{{ emacsconf_group }}" +- name: Check if Emacs base configuration already exists + lineinfile: + dest: "{{ emacs_config_dir }}/init.el" + state: present + regexp: "emacsconf-edit" + line: "(load-file \"{{ emacs_config_dir }}/emacsconf-edit.el\")" + owner: "{{ emacsconf_user }}" + group: "{{ emacsconf_group }}" + create: yes diff --git a/roles/edit/templates/emacsconf-edit.el b/roles/edit/templates/emacsconf-edit.el index 2e360c7..481892b 100644 --- a/roles/edit/templates/emacsconf-edit.el +++ b/roles/edit/templates/emacsconf-edit.el @@ -1,7 +1,10 @@ ;; {{ ansible_managed }} -(let ((packages '({% for package in emacsconf_edit_packages %}{{ package }}{% endfor %}))) - (mapc (lambda (package) (unless (package-installed-p package) (package-install package))) packages)) +(progn (require 'package) + (let ((packages (seq-remove #'package-installed-p '({% for package in emacsconf_edit_packages %}{{ package }} {% endfor %})))) + (when packages + (package-refresh-contents) + (mapc #'package-install packages)))) ;; Configuration (vertico-mode) (show-paren-mode) @@ -19,16 +22,45 @@ (split-window-horizontally) (magit-status "{{ emacsconf_edit_wiki_dir }}") (global-auto-revert-mode 1) -(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map) -(projectile-mode +1) -(setq projectile-completion-system 'default) -(setq projectile-enable-caching t) -(setq projectile-indexing-method 'alien) -(add-to-list 'projectile-globally-ignored-files "node_modules") -(add-to-list 'projectile-globally-ignored-files ".cache") -(add-to-list 'projectile-globally-ignored-files "_cache") +(with-eval-after-load 'projectile + (projectile-mode +1) + (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map) + (setq projectile-completion-system 'default) + (setq projectile-enable-caching t) + (setq projectile-indexing-method 'alien) + (add-to-list 'projectile-globally-ignored-files "node_modules") + (add-to-list 'projectile-globally-ignored-files ".cache") + (add-to-list 'projectile-globally-ignored-files "_cache")) (setq completion-styles '(orderless)) (setq completion-category-defaults nil) (setq completion-category-overrides '((file (styles orderless)))) + +(defhydra hydra-emacsconf () + ("e" embark-act "embark") + ("t" emacsconf-go-to-talk "talk") + ("c" + (find-file emacsconf-org-file) "conf.org") + ("C" + (let ((default-directory (file-name-directory emacsconf-org-file))) + (call-interactively #'projectile-find-file)) + "org dir") + ("w" + (let ((default-directory emacsconf-directory)) + (call-interactively #'projectile-find-file)) + "wiki") + ("o" (find-file (expand-file-name (concat emacsconf-year "/organizers-notebook/index.org") emacsconf-directory)) + "org notes") + ("a" (let ((default-directory emacsconf-ansible-directory)) + (call-interactively #'projectile-find-file)) + "ansible") + ("i" (switch-to-buffer (erc-get-buffer "#emacsconf-org"))) + ("l" (let ((default-directory "{{ emacsconf_el_dir }}")) + (call-interactively #'projectile-find-file)) + "lisp") + ("b" emacsconf-backstage-dired "backstage") + ("u" emacsconf-upload-dired "upload")) +(global-set-key (kbd "C-c e") #'hydra-emacsconf/body) + (require 'ox-md) +(server-start) diff --git a/roles/obs/overlay.svg b/roles/obs/overlay.svg new file mode 100644 index 0000000..73a7e6f --- /dev/null +++ b/roles/obs/overlay.svg @@ -0,0 +1,301 @@ + +image/svg+xmlInitializing...Initializing...Initializing... diff --git a/roles/obs/tasks/main.yml b/roles/obs/tasks/main.yml index 36e14c3..bf856ec 100644 --- a/roles/obs/tasks/main.yml +++ b/roles/obs/tasks/main.yml @@ -1,5 +1,5 @@ - name: Load icecast vars - tags: wip + tags: obs-profile, wip include_vars: file: ../../stream/defaults/main.yml - name: Add repo @@ -53,5 +53,13 @@ regexp: '(AllowUsers(?!.*\b{{ emacsconf_id }}-{{ item.id }}\b).*)$' replace: \1 {{ emacsconf_id }}-{{ item.id }} loop: "{{ emacsconf_tracks }}" - - +- name: Allow sudo from {{ emacsconf_user }} to the stream users + tags: wip + become: true + become_user: root + copy: + content: | + {% for item in emacsconf_tracks %} + {{ emacsconf_user }} ALL=({{ emacsconf_id }}-{{ item.id }}) NOPASSWD: ALL + {% endfor %} + dest: /etc/sudoers.d/50_emacsconf diff --git a/roles/obs/tasks/obs-setup.yml b/roles/obs/tasks/obs-setup.yml index 1da678a..59170f1 100644 --- a/roles/obs/tasks/obs-setup.yml +++ b/roles/obs/tasks/obs-setup.yml @@ -6,13 +6,12 @@ state: directory - name: Create profile directories file: - path: "~{{ emacsconf_user }}/.config/obs-studio/basic/{{ item.name }}" + path: "~{{ emacsconf_user }}/.config/obs-studio/basic/profiles/{{ item.name }}" state: directory owner: "{{ emacsconf_user }}" group: "{{ emacsconf_group }}" mode: 0775 - name: Install OBS global profile - tags: wip template: src: global.ini owner: "{{ emacsconf_user }}" @@ -23,7 +22,7 @@ src: profile.ini owner: "{{ emacsconf_user }}" group: "{{ emacsconf_group }}" - dest: "~{{ emacsconf_user }}/.config/obs-studio/basic/{{ item.name }}/basic.ini" + dest: "~{{ emacsconf_user }}/.config/obs-studio/basic/profiles/{{ item.name }}/basic.ini" mode: 0664 - name: Install OBS scenes tags: obs-scene @@ -32,17 +31,33 @@ owner: "{{ emacsconf_user }}" group: "{{ emacsconf_group }}" dest: "~{{ emacsconf_user }}/.config/obs-studio/basic/scenes/{{ item.id }}.json" +- name: Copy overlay template for video + tags: obs-scene + copy: + src: overlay.svg + dest: "~{{ emacsconf_user }}/video.svg" + owner: "{{ emacsconf_user }}" + group: "{{ emacsconf_group }}" +- name: Copy overlay template for video + tags: obs-scene + copy: + src: overlay.svg + dest: "~{{ emacsconf_user }}/other.svg" + owner: "{{ emacsconf_user }}" + group: "{{ emacsconf_group }}" - name: Create text files for OBS sources copy: content: "Initializing..." owner: "{{ emacsconf_user }}" group: "{{ emacsconf_group }}" - dest: "~{{ emacsconf_user }}/{{ item }}.txt" + dest: "~{{ emacsconf_user }}/{{ filename }}.txt" mode: 0664 loop: - news - url - bottom + loop_control: + loop_var: filename - name: Create OBS scripts for tracks template: src: obs-track @@ -50,4 +65,11 @@ owner: "{{ emacsconf_user }}" group: "{{ emacsconf_group }}" mode: 0775 - +- name: Fix permissions + become: true + become_user: root + file: + path: "~{{ emacsconf_user }}" + owner: "{{ emacsconf_user }}" + group: "{{ emacsconf_group }}" + recurse: true diff --git a/roles/obs/tasks/track.yml b/roles/obs/tasks/track.yml index 93b789d..a0acf16 100644 --- a/roles/obs/tasks/track.yml +++ b/roles/obs/tasks/track.yml @@ -1,5 +1,5 @@ - name: Set vars - tags: wip, obs-scene, mpv + tags: obs-scene, obs-profile, mpv, wip set_fact: old_emacsconf_user: "{{ emacsconf_user }}" old_emacsconf_home: "{{ emacsconf_home }}" @@ -10,7 +10,7 @@ - name: Set up user include: user.yml - name: Set up user-related things - become: "{{ emacsconf_user }}" + become_user: "{{ emacsconf_user }}" block: - name: Set up track bins for addition to paths file: @@ -27,6 +27,7 @@ group: "{{ emacsconf_group }}" state: directory - name: Add MPV profile + tags: mpv-conf template: src: mpv.conf dest: "~{{ emacsconf_user }}/.config/mpv/mpv.conf" @@ -40,8 +41,12 @@ group: "{{ emacsconf_group }}" mode: 0775 - name: Set up OBS profiles and scenes - tags: obs-profile - include: obs-setup.yml + tags: obs-profile, obs-scene + include_tasks: + file: obs-setup.yml + apply: + tags: + - obs-profile - name: Add FFMPEG script for streaming template: src: stream-desktop-with-ffmpeg.sh @@ -75,7 +80,7 @@ owner: "{{ emacsconf_user }}" group: "{{ emacsconf_group }}" - name: Reset vars - tags: wip, obs-scene, mpv + tags: obs-scene, obs-profile, mpv, wip set_fact: old_emacsconf_user: "{{ emacsconf_user }}" old_emacsconf_home: "{{ emacsconf_home }}" diff --git a/roles/obs/tasks/user.yml b/roles/obs/tasks/user.yml index a941d7f..caaf2d9 100644 --- a/roles/obs/tasks/user.yml +++ b/roles/obs/tasks/user.yml @@ -2,7 +2,6 @@ group: name: "{{ emacsconf_group }}" - name: Add user - tags: wip user: name: "{{ emacsconf_user }}" group: "{{ emacsconf_group }}" @@ -15,10 +14,10 @@ state: directory mode: 700 - name: Set up SSH key access + tags: wip template: src: authorized_keys dest: "/home/{{ emacsconf_user }}/.ssh/authorized_keys" - force: no - name: Change ownership of SSH directory file: path: "/home/{{ emacsconf_user }}/.ssh" diff --git a/roles/obs/templates/mpv.conf b/roles/obs/templates/mpv.conf index 9aff3ee..b1bd1ca 100644 --- a/roles/obs/templates/mpv.conf +++ b/roles/obs/templates/mpv.conf @@ -15,7 +15,7 @@ sub-use-margins=yes sub-scale-by-window=yes sub-pos=103 sub-margin-x=120 -sub-margin-y=40 +sub-margin-y=20 sub-align-x=left # Style sub-font="{{ emacsconf_font }}" diff --git a/roles/obs/templates/scenes.json b/roles/obs/templates/scenes.json index 4e6e4bd..a92f29e 100644 --- a/roles/obs/templates/scenes.json +++ b/roles/obs/templates/scenes.json @@ -1,6 +1,6 @@ { - "current_program_scene": "All track audio and screen", - "current_scene": "All track audio and screen", + "current_program_scene": "Video audio and screen", + "current_scene": "Video audio and screen", "current_transition": "Fade", "groups": [ { @@ -30,8 +30,8 @@ "push-to-talk-delay": 0, "settings": { "custom_size": true, - "cx": 103, - "cy": 507, + "cx": 494, + "cy": 715, "id_counter": 0, "items": [ { @@ -56,11 +56,11 @@ "locked": false, "name": "News", "pos": { - "x": 22, - "y": 390 + "x": 12, + "y": 0 }, "private_settings": {}, - "rot": -90, + "rot": 0, "scale": { "x": 1, "y": 1 @@ -93,11 +93,11 @@ "locked": false, "name": "URL", "pos": { - "x": 55, - "y": 389 + "x": 114, + "y": 691 }, "private_settings": {}, - "rot": -90, + "rot": 0, "scale": { "x": 1, "y": 1 @@ -131,7 +131,7 @@ "name": "Logo", "pos": { "x": 0, - "y": 404 + "y": 603 }, "private_settings": {}, "rot": 0, @@ -236,6 +236,8 @@ "push-to-talk": false, "push-to-talk-delay": 0, "settings": { + "color2": 4294967295, + "drop_shadow": false, "font": { "face": "Sans Serif", "flags": 0, @@ -243,6 +245,7 @@ "style": "" }, "from_file": true, + "outline": true, "text_file": "/home/{{ emacsconf_id }}-{{ item.id }}/news.txt" }, "sync": 0, @@ -271,7 +274,7 @@ "font": { "face": "Sans Serif", "flags": 0, - "size": 24, + "size": 20, "style": "" }, "from_file": true, @@ -346,14 +349,14 @@ "OBSBasic.SelectScene": [], "libobs.hide_scene_item.Bottom": [], "libobs.hide_scene_item.Screen Capture (XSHM)": [], - "libobs.hide_scene_item.dev-qa": [], - "libobs.hide_scene_item.dev-vid": [], "libobs.hide_scene_item.emacsconf base": [], + "libobs.hide_scene_item.gen-qa": [], + "libobs.hide_scene_item.gen-vid": [], "libobs.show_scene_item.Bottom": [], "libobs.show_scene_item.Screen Capture (XSHM)": [], - "libobs.show_scene_item.dev-qa": [], - "libobs.show_scene_item.dev-vid": [], - "libobs.show_scene_item.emacsconf base": [] + "libobs.show_scene_item.emacsconf base": [], + "libobs.show_scene_item.gen-qa": [], + "libobs.show_scene_item.gen-vid": [] }, "id": "scene", "mixers": 0, @@ -503,11 +506,11 @@ "locked": false, "name": "News", "pos": { - "x": 31, - "y": 595 + "x": 21, + "y": 6 }, "private_settings": {}, - "rot": -90, + "rot": 0, "scale": { "x": 1, "y": 1 @@ -540,11 +543,11 @@ "locked": false, "name": "URL", "pos": { - "x": 64, - "y": 594 + "x": 123, + "y": 697 }, "private_settings": {}, - "rot": -90, + "rot": 0, "scale": { "x": 1, "y": 1 @@ -615,7 +618,7 @@ "name": "{{ emacsconf_id }} base", "pos": { "x": 9, - "y": 205 + "y": 6 }, "private_settings": {}, "rot": 0, @@ -734,11 +737,11 @@ "hotkeys": { "OBSBasic.SelectScene": [], "libobs.hide_scene_item.Screen Capture (XSHM)": [], - "libobs.hide_scene_item.dev-vid": [], "libobs.hide_scene_item.emacsconf base": [], + "libobs.hide_scene_item.gen-vid": [], "libobs.show_scene_item.Screen Capture (XSHM)": [], - "libobs.show_scene_item.dev-vid": [], - "libobs.show_scene_item.emacsconf base": [] + "libobs.show_scene_item.emacsconf base": [], + "libobs.show_scene_item.gen-vid": [] }, "id": "scene", "mixers": 0, @@ -851,11 +854,11 @@ "locked": false, "name": "News", "pos": { - "x": 31, - "y": 580 + "x": 12, + "y": 0 }, "private_settings": {}, - "rot": -90, + "rot": 0, "scale": { "x": 1, "y": 1 @@ -888,11 +891,11 @@ "locked": false, "name": "URL", "pos": { - "x": 64, - "y": 579 + "x": 114, + "y": 691 }, "private_settings": {}, - "rot": -90, + "rot": 0, "scale": { "x": 1, "y": 1 @@ -925,8 +928,8 @@ "locked": false, "name": "Logo", "pos": { - "x": 9, - "y": 594 + "x": 0, + "y": 603 }, "private_settings": {}, "rot": 0, @@ -962,8 +965,8 @@ "locked": false, "name": "{{ emacsconf_id }} base", "pos": { - "x": 9, - "y": 190 + "x": 0, + "y": 0 }, "private_settings": {}, "rot": 0, diff --git a/roles/publish/defaults/main.yml b/roles/publish/defaults/main.yml index 4de7445..6416e25 100644 --- a/roles/publish/defaults/main.yml +++ b/roles/publish/defaults/main.yml @@ -1,9 +1,5 @@ emacsconf_org_file: "{{ emacsconf_private_dir }}/conf.org" emacsconf_publishing_phase: schedule -emacsconf_el_dir: ~{{ emacsconf_user }}/emacsconf-el -emacsconf_edit_wiki_dir: ~{{ emacsconf_user }}/emacsconf-wiki -emacsconf_private_dir: ~{{ emacsconf_user }}/emacsconf-2022-private -emacs_config_dir: ~{{ emacsconf_user }}/.emacs.d emacs_version: 28.2 emacs_build_parent: /usr/src/emacs emacs_build_dir: "{{ emacs_build_parent }}/emacs-{{ emacs_version }}" diff --git a/roles/publish/tasks/main.yml b/roles/publish/tasks/main.yml index 28566a5..ddee975 100644 --- a/roles/publish/tasks/main.yml +++ b/roles/publish/tasks/main.yml @@ -1,66 +1,106 @@ --- -- name: Set up SSH directory - ansible.builtin.file: - path: "/home/{{ emacsconf_user }}/.ssh" - state: directory - mode: '0700' +- name: Set up user + include_role: + name: user - name: Install SSH key for EmacsConf wiki ansible.builtin.get_url: url: https://emacsconf.org/id_rsa_anon_git_emacsconf dest: "/home/{{ emacsconf_user }}/.ssh/id_rsa_anon_git_emacsconf" + owner: "{{ emacsconf_user }}" + group: "{{ emacsconf_group }}" mode: '0600' -- name: Install the SSH key for orga - template: - src: id_rsa - dest: "/home/{{ emacsconf_user }}/.ssh/id_rsa" +- name: Check SSH config for line + blockinfile: + path: /home/{{ emacsconf_user }}/.ssh/config mode: '0600' -- name: Change ownership of SSH directory - file: - path: "/home/{{ emacsconf_user }}/.ssh" - recurse: true owner: "{{ emacsconf_user }}" - + group: "{{ emacsconf_group }}" + create: yes + block: | + Host anon-emacsconf + Hostname git.emacsconf.org + Port 22 + User anon + IdentityFile ~/.ssh/id_rsa_anon_git_emacsconf +- name: Install the SSH key for orga + copy: + src: "{{ item }}" + dest: "/home/{{ emacsconf_user }}/.ssh" + owner: "{{ emacsconf_user }}" + group: "{{ emacsconf_group }}" + mode: '0600' + loop: + - id_rsa + - id_rsa.pub +- name: Check if local Emacs already exists + stat: + path: "/usr/local/bin/emacs" + register: emacs - name: Set up Emacs + become: yes include: emacs.yml + when: not emacs.stat.exists +- name: Configure git + template: + src: git-config + dest: "~{{ emacsconf_user }}/.gitconfig" + owner: "{{ emacsconf_user }}" + group: "{{ emacsconf_group }}" - name: Ensure configuration directory exists file: path: "{{ emacs_config_dir }}" + owner: "{{ emacsconf_user }}" + group: "{{ emacsconf_group }}" state: directory - name: Set up Emacs configuration for non-interactive publishing template: src: emacsconf-config.el dest: "{{ emacs_config_dir }}/emacsconf-config.el" - + owner: "{{ emacsconf_user }}" + group: "{{ emacsconf_group }}" - name: Check if Emacs base configuration already exists - become: true lineinfile: dest: "{{ emacs_config_dir }}/init.el" state: present regexp: "emacsconf-config" - line: "(load-file \"emacsconf-config.el\")" + line: "(load-file \"{{ emacs_config_dir }}/emacsconf-config.el\")" + owner: "{{ emacsconf_user }}" + group: "{{ emacsconf_group }}" create: yes +- name: Set up compile-media + become_user: "{{ emacsconf_user }}" + git: + repo: https://github.com/sachac/compile-media.git + dest: "~{{ emacsconf_user }}/compile-media" - name: Set up or update repositories - become: false + become_user: "{{ emacsconf_user }}" tags: publish block: - name: Check out wiki repository ansible.builtin.git: - repo: git://git.emacsconf.org/emacsconf-wiki + repo: git@anon-emacsconf:/emacsconf-wiki dest: "{{ emacsconf_edit_wiki_dir }}" + key_file: "~{{ emacsconf_user }}/.ssh/id_rsa_anon_git_emacsconf" register: wiki_clone failed_when: - wiki_clone.failed - not 'Local modifications exist in repository' in wiki_clone.msg - not 'Failed to checkout branch' in wiki_clone.msg + - name: Configure git to use + shell: git config core.sshCommand "ssh -i ~{{ emacsconf_user }}/.ssh/id_rsa_anon_git_emacsconf -F /dev/null" + args: + chdir: "{{ emacsconf_edit_wiki_dir }}" - name: Check out emacsconf-el ansible.builtin.git: repo: git@git.emacsconf.org:pub/emacsconf-el + key_file: "~{{ emacsconf_user }}/.ssh/id_rsa" dest: "{{ emacsconf_el_dir }}" register: elisp failed_when: - elisp.failed - not 'Local modifications exist in repository' in elisp.msg - not 'Failed to checkout branch' in elisp.msg + debugger: on_failed - name: Check out emacsconf-2022-private ansible.builtin.git: repo: git@git.emacsconf.org:emacsconf-2022-private @@ -75,20 +115,23 @@ path: "{{ item }}" owner: "{{ emacsconf_user }}" recurse: true - with_items: - - "{{ emacsconf_config_dir }}" + loop: + - "{{ emacs_config_dir }}" - "{{ emacsconf_el_dir }}" - "{{ emacsconf_private_dir }}" - "{{ emacsconf_edit_wiki_dir }}" - name: Publish - tags: publish + tags: publish, publish-only block: - name: Publish the schedule - command: emacs -l "{{ emacsconf_config_dir }}/emacsconf-config.el" --batch --exec '(emacsconf-generate-main-schedule)' - when: (force_publish|d(false)) or ((private.changed or elisp.changed) and slug is not defined) + command: emacs -l "{{ emacs_config_dir }}/emacsconf-config.el" --batch --exec '(emacsconf-publish-schedule)' + when: ((publish|d("")) == "schedule") or (((private is defined and private.changed) or (elisp is defined and elisp.changed)) and slug is not defined) - name: Update a specific talk's nav page tags: publish-talk - command: emacs -l "{{ emacsconf_config_dir }}/emacsconf-config.el" --batch --exec '(emacsconf-with-talk-heading "{{ slug }}" (emacsconf-update-talk))' + command: emacs -l "{{ emacs_config_dir }}/emacsconf-config.el" --batch --exec '(emacsconf-with-talk-heading "{{ slug }}" (emacsconf-update-talk))' when: slug is defined - name: Commit the wiki and push shell: cd {{ emacsconf_edit_wiki_dir }}; git commit -m 'Update from ansible' -a; git push + - name: Publish the backstage index + command: emacs -l "{{ emacs_config_dir }}/emacsconf-config.el" --batch --exec '(emacsconf-publish-backstage-index)' + when: (publish|d("")) == "backstage" diff --git a/roles/publish/templates/emacsconf-config.el b/roles/publish/templates/emacsconf-config.el index cfb554e..e9e4fcc 100644 --- a/roles/publish/templates/emacsconf-config.el +++ b/roles/publish/templates/emacsconf-config.el @@ -1,9 +1,6 @@ ;; {{ ansible_managed }} (add-to-list 'load-path "{{ emacsconf_el_dir }}") -(require 'emacsconf) -(require 'emacsconf-publish) -(require 'emacsconf-schedule) (org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t) (shell . t))) (setq emacsconf-year "{{ emacsconf_year }}") (setq emacsconf-org-file "{{ emacsconf_org_file }}") @@ -19,3 +16,28 @@ {% endif %} (setq emacsconf-pad-api-key "{{ etherpad_api_key }}") (setq emacsconf-publishing-phase '{{ emacsconf_publishing_phase }}) +(setq emacsconf-backstage-password "{{ emacsconf_backstage_password }}") + +(setq emacsconf-backstage-dir "/ssh:orga@media.emacsconf.org:/var/www/media.emacsconf.org/2022/backstage") +(setq emacsconf-upload-dir "/ssh:orga@media.emacsconf.org:/srv/upload") +{% if ansible_host == "res.emacsconf.org" %} +(setq emacsconf-res-dir (format "/ssh:orga@res.emacsconf.org:/data/emacsconf/%s" emacsconf-year)) +(setq emacsconf-cache-dir "/data/{{ emacsconf_id }}/cache") +(setq emacsconf-stream-host "localhost") +{% else %} +(setq emacsconf-res-dir "/data/{{ emacsconf_id }}/{{ emacsconf_year}}") +{% endif %} +(add-to-list 'load-path "~/compile-media") +(require 'compile-media) +(require 'emacsconf) +(require 'emacsconf-publish) +(require 'emacsconf-schedule) +(require 'emacsconf-erc) +(require 'emacsconf-stream) + +(setq emacsconf-tracks + '((:name "General" :color "peachpuff" :id "gen" :channel "emacsconf-gen" + :tramp "/ssh:gen:") + (:name "Development" :color "skyblue" :id "dev" :channel "emacsconf-dev" + :tramp "/ssh:dev:"))) + diff --git a/roles/publish/templates/git-config b/roles/publish/templates/git-config new file mode 100644 index 0000000..e03358d --- /dev/null +++ b/roles/publish/templates/git-config @@ -0,0 +1,8 @@ +# {{ ansible_managed }} +# This is Git's per-user configuration file. +[user] +# Please adapt and uncomment the following lines: + name = {{ emacsconf_name }} + email = {{ emacsconf_email }} +[push] + default = simple diff --git a/roles/user/tasks/main.yml b/roles/user/tasks/main.yml new file mode 100644 index 0000000..11c0a74 --- /dev/null +++ b/roles/user/tasks/main.yml @@ -0,0 +1,31 @@ +- name: Add group + become: yes + group: + name: "{{ emacsconf_group }}" +- name: Add user + become: yes + user: + name: "{{ emacsconf_user }}" + group: "{{ emacsconf_group }}" + shell: /bin/bash +# password: "{{ emacsconf_unix_password }}" +- name: Create SSH folder + file: + path: "/home/{{ emacsconf_user }}/.ssh" + owner: "{{ emacsconf_user }}" + group: "{{ emacsconf_group }}" + state: directory + mode: 0700 +- name: Set up SSH key access + template: + src: authorized_keys + dest: "/home/{{ emacsconf_user }}/.ssh/authorized_keys" + owner: "{{ emacsconf_user }}" + group: "{{ emacsconf_group }}" + force: no +- name: Change ownership of SSH directory + file: + path: "/home/{{ emacsconf_user }}/.ssh" + recurse: true + owner: "{{ emacsconf_user }}" + mode: "u+rwX,g-rwx,o-rwx" -- cgit v1.2.3