summaryrefslogtreecommitdiffstats
path: root/roles/publish
diff options
context:
space:
mode:
Diffstat (limited to 'roles/publish')
-rw-r--r--roles/publish/defaults/main.yml9
-rw-r--r--roles/publish/tasks/emacs.yml38
-rw-r--r--roles/publish/tasks/main.yml94
-rw-r--r--roles/publish/templates/emacsconf-config.el21
4 files changed, 162 insertions, 0 deletions
diff --git a/roles/publish/defaults/main.yml b/roles/publish/defaults/main.yml
new file mode 100644
index 0000000..4de7445
--- /dev/null
+++ b/roles/publish/defaults/main.yml
@@ -0,0 +1,9 @@
+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/emacs.yml b/roles/publish/tasks/emacs.yml
new file mode 100644
index 0000000..8d75979
--- /dev/null
+++ b/roles/publish/tasks/emacs.yml
@@ -0,0 +1,38 @@
+- name: Install dependencies
+ apt:
+ name:
+ - build-essential
+ - libncurses5-dev
+ - git
+ - gnutls-bin
+ - pkg-config
+ - libjansson-dev
+ - libgnutls28-dev
+ - automake
+ - texinfo
+ state: present
+- name: Create directory
+ file:
+ path: "{{ emacs_build_parent }}"
+ state: directory
+- name: Download Emacs
+ unarchive:
+ src: https://ftp.gnu.org/gnu/emacs/emacs-{{emacs_version}}.tar.gz
+ remote_src: yes
+ dest: "{{ emacs_build_parent }}"
+ creates: "{{ emacs_build_dir }}"
+- name: Configure
+ command: ./configure --with-x-toolkit=no
+ args:
+ chdir: "{{ emacs_build_dir }}"
+ creates: '{{ emacs_build_dir }}/Makefile'
+- name: Build
+ command: make -j{{ cpus }}
+ args:
+ chdir: "{{ emacs_build_dir }}"
+ creates: '{{ emacs_build_dir }}/src/emacs'
+- name: Install
+ command: make install
+ args:
+ chdir: "{{ emacs_build_dir }}"
+ creates: '/usr/local/bin/emacs'
diff --git a/roles/publish/tasks/main.yml b/roles/publish/tasks/main.yml
new file mode 100644
index 0000000..28566a5
--- /dev/null
+++ b/roles/publish/tasks/main.yml
@@ -0,0 +1,94 @@
+---
+- name: Set up SSH directory
+ ansible.builtin.file:
+ path: "/home/{{ emacsconf_user }}/.ssh"
+ state: directory
+ mode: '0700'
+- 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"
+ mode: '0600'
+- name: Install the SSH key for orga
+ template:
+ src: id_rsa
+ dest: "/home/{{ emacsconf_user }}/.ssh/id_rsa"
+ mode: '0600'
+- name: Change ownership of SSH directory
+ file:
+ path: "/home/{{ emacsconf_user }}/.ssh"
+ recurse: true
+ owner: "{{ emacsconf_user }}"
+
+- name: Set up Emacs
+ include: emacs.yml
+- name: Ensure configuration directory exists
+ file:
+ path: "{{ emacs_config_dir }}"
+ state: directory
+- name: Set up Emacs configuration for non-interactive publishing
+ template:
+ src: emacsconf-config.el
+ dest: "{{ emacs_config_dir }}/emacsconf-config.el"
+
+- 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\")"
+ create: yes
+- name: Set up or update repositories
+ become: false
+ tags: publish
+ block:
+ - name: Check out wiki repository
+ ansible.builtin.git:
+ repo: git://git.emacsconf.org/emacsconf-wiki
+ dest: "{{ emacsconf_edit_wiki_dir }}"
+ 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: Check out emacsconf-el
+ ansible.builtin.git:
+ repo: git@git.emacsconf.org:pub/emacsconf-el
+ 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
+ - name: Check out emacsconf-2022-private
+ ansible.builtin.git:
+ repo: git@git.emacsconf.org:emacsconf-2022-private
+ dest: "{{ emacsconf_private_dir }}"
+ register: private
+ failed_when:
+ - private.failed
+ - not 'Local modifications exist in repository' in private.msg
+ - not 'Failed to checkout branch' in private.msg
+- name: Change ownership
+ file:
+ path: "{{ item }}"
+ owner: "{{ emacsconf_user }}"
+ recurse: true
+ with_items:
+ - "{{ emacsconf_config_dir }}"
+ - "{{ emacsconf_el_dir }}"
+ - "{{ emacsconf_private_dir }}"
+ - "{{ emacsconf_edit_wiki_dir }}"
+- name: Publish
+ tags: publish
+ 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)
+ - 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))'
+ 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
diff --git a/roles/publish/templates/emacsconf-config.el b/roles/publish/templates/emacsconf-config.el
new file mode 100644
index 0000000..cfb554e
--- /dev/null
+++ b/roles/publish/templates/emacsconf-config.el
@@ -0,0 +1,21 @@
+;; {{ 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 }}")
+(setq emacsconf-directory "{{ emacsconf_edit_wiki_dir }}")
+{% if emacsconf_streaming_nick is defined %}
+(setq emacsconf-streaming-nick "{{ emacsconf_streaming_nick }}")
+{% endif %}
+{% if emacsconf_org_tag is defined %}
+(setq emacsconf-org-tag "{{ emacsconf_org_tag }}")
+{% endif %}
+{% if emacsconf_ansible_directory is defined %}
+(setq emacsconf-ansible-directory "{{ emacsconf_ansible_directory }}")
+{% endif %}
+(setq emacsconf-pad-api-key "{{ etherpad_api_key }}")
+(setq emacsconf-publishing-phase '{{ emacsconf_publishing_phase }})