agnosticd
agnosticd copied to clipboard
Etherpad pre-filled pages
Is your feature request related to a problem? Please describe.
In Ansible EDA & Dynatrace escape room we found etherpad good for simple "breakout rooms" feature. But for that to work, we would need to have number of pages pre-generated. Like one instruction page, and 15 team rooms. I'm writing here my findings for later what would it take.
Describe the solution you'd like
I'd like to have a task in ansible etherpad role that adds a page with given content. I checked from etherpad docs that it has an API to do this. To add pages we would need to:
- Add config/secret file and map it to file called APIKEY.txt at root of container:
Authentication Authentication works via a token that is sent with each request as a post parameter. There is a single token per Etherpad deployment. This token will be random string, generated by Etherpad at the first start. It will be saved in APIKEY.txt in the root folder of Etherpad. Only Etherpad and the requesting application knows this key. Token management will not be exposed through this API. - We could then create given pages via ansible http POST as described in the doc. A rough example with curl here:
#!/bin/bash # Configuration API_KEY="YOUR_API_KEY" PAD_NAME="welcomePad" ETHERPAD_URL="http://your-etherpad-instance" # Step 1: Create a new pad curl "${ETHERPAD_URL}/api/1/createPad?apikey=${API_KEY}&padID=${PAD_NAME}" # Step 2: Set the text of the new pad curl --data "apikey=${API_KEY}&padID=${PAD_NAME}&text=welcome%20to%20etherpad" "${ETHERPAD_URL}/api/1/setText"
Describe alternatives you've considered currently the lab organizer needs to copy paste several pages at lab start, and modify them according to lab details.
Additional context
@tonykay We discussed this at summit.
same example in ansible:
---
- name: Create a new pad in Etherpad
hosts: localhost
tasks:
- name: Create a new pad
uri:
url: "http://your-etherpad-instance/api/1/createPad"
method: GET
return_content: yes
status_code: 200
body_format: json
headers:
Content-Type: "application/json"
params:
apikey: "YOUR_API_KEY"
padID: "welcomePad"
- name: Set the text of the new pad
uri:
url: "http://your-etherpad-instance/api/1/setText"
method: POST
return_content: yes
status_code: 200
body_format: form-urlencoded
headers:
Content-Type: "application/x-www-form-urlencoded"
body:
apikey: "YOUR_API_KEY"
padID: "welcomePad"
text: "welcome to etherpad"
While looking into this, I noticed there is etherpad-lite, which is perhaps a bit newer. And such has kustomize for kube. Perhaps it would make sense to use that: https://github.com/gobengo/etherpad-lite
here's role I made for this: https://github.com/ikke-t/etherpads-lb1740
Just for backup, here's podman kube yaml that works with apikey. Note the added secret, apikey parameter and auth env variable. The latest etherpad requires that.
---
apiVersion: v1
kind: Secret
metadata:
name: apikey
data:
APIKEY.txt: aGVwcGE=
---
apiVersion: v1
kind: Pod
metadata:
labels:
app: etherped-lite-pod
name: etherped-lite-pod
spec:
containers:
- name: etherped-lite
args: [pnpm, run, prod, --apikey, /api/APIKEY.txt]
# args: [pnpm, run, prod]
env:
- name: DEFAULT_PAD_TEXT
value: Start editing here...
- name: DB_CHARSET
value: utf8mb4
- name: TERM
value: xterm
- name: DB_NAME
value: etherpad
- name: DB_PORT
value: '5432'
- name: no_proxy
value: localhost,127.0.0.0/8,::1
- name: DB_USER
value: admin
- name: DB_PASS
value: admin
- name: DB_HOST
value: 127.0.0.1
- name: ADMIN_PASSWORD
value: admin
- name: DB_TYPE
value: postgres
- name: NO_PROXY
value: localhost,127.0.0.0/8,::1
- name: DISABLE_IP_LOGGING
value: 'false'
- name: SOFFICE
value: 'null'
- name: TRUST_PROXY
value: 'true'
- name: AUTHENTICATION_METHOD
value: apikey
image: docker.io/etherpad/etherpad:latest
ports:
- containerPort: 9001
hostPort: 9001
securityContext:
runAsGroup: 0
runAsUser: 0
stdin: true
tty: true
volumeMounts:
- mountPath: /opt/etherpad-lite/src/plugin_packages
name: etherped-lite_plugins-pvc
- mountPath: /opt/etherpad-lite/var
name: etherped-lite_etherpad-var-pvc
- name: apikey
readOnly: true
mountPath: /api
- name: etherped-litepostgres
args: [postgres]
env:
- name: PGDATA
value: /var/lib/postgresql/data/pgdata
- name: NO_PROXY
value: localhost,127.0.0.0/8,::1
- name: no_proxy
value: localhost,127.0.0.0/8,::1
- name: POSTGRES_DB
value: etherpad
- name: POSTGRES_PASSWORD
value: admin
- name: POSTGRES_USER
value: admin
- name: POSTGRES_PORT
value: '5432'
image: docker.io/library/postgres:15-alpine
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: etherpad-lite_postgresql-pvc
- mountPath: /var/lib/postgresql/data/pgdata
name: etherped-lite_postgres_data-pvc
restartPolicy: Always
volumes:
- name: etherped-lite_plugins-pvc
persistentVolumeClaim:
claimName: etherped-lite_plugins
- name: etherped-lite_etherpad-var-pvc
persistentVolumeClaim:
claimName: etherped-lite_etherpad-var
- name: etherpad-lite_postgresql-pvc
persistentVolumeClaim:
claimName: etherpad-lite_postgresql-pvc
- name: etherped-lite_postgres_data-pvc
persistentVolumeClaim:
claimName: etherped-lite_postgres_data
- name: apikey
secret:
secretName: apikey
@wkulhanek if you have time can you take a look, otherwise I will, but always happy to defer to you on OCP - takes me back to our youth and Adv App Dev :)