diff options
author | Sacha Chua <sacha@sachachua.com> | 2022-11-02 13:08:03 -0400 |
---|---|---|
committer | Sacha Chua <sacha@sachachua.com> | 2022-11-02 13:08:03 -0400 |
commit | c569e02d8ab5ebcbb5a44e10c14799fa097c9bc7 (patch) | |
tree | 05528005f12160fd505696cb5d89f22d30249f32 /roles/publish | |
parent | 4696aa1fed214fe1084d7c3deecaaa289bc0a1fd (diff) | |
download | emacsconf-ansible-c569e02d8ab5ebcbb5a44e10c14799fa097c9bc7.tar.xz emacsconf-ansible-c569e02d8ab5ebcbb5a44e10c14799fa097c9bc7.zip |
OBS overlays, starting to get publish and edit on res
Diffstat (limited to 'roles/publish')
-rw-r--r-- | roles/publish/defaults/main.yml | 4 | ||||
-rw-r--r-- | roles/publish/tasks/main.yml | 93 | ||||
-rw-r--r-- | roles/publish/templates/emacsconf-config.el | 28 | ||||
-rw-r--r-- | roles/publish/templates/git-config | 8 |
4 files changed, 101 insertions, 32 deletions
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 |