Switch ejabberd configuration to YAML

Jérôme Sautret
· 1 min read
Send by email

Ejabberd Community 13.10 supports YAML format for configuration file. Ejabberd newcomers were often frighten editing Erlang term file (ejabberd.cfg) and the YAML support is a way to help configuring ejabberd using a more familiar text format. It’s possible to convert ejabberd configuration to YAML using convert_to_yaml command from ejabberdctl.

After installing ejabberd 13.10 from binary installer, which comes by default with Erlang terms based configuration, just create your YAML configuration this way:

cd /Application/ejabberd-13.10
bin/ejabberdctl start
bin/ejabberdctl convert_to_yaml $PWD/conf/ejabberd.cfg $PWD/conf/ejabberd.yml

You can check/edit your new configuration. Default configuration looks like this:

hosts: 
  - "localhost"
access: 
  announce: 
    admin: allow
  c2s: 
    blocked: deny
    all: allow
  c2s_shaper: 
    admin: none
    all: normal
  configure: 
    admin: allow
  local: 
    local: allow
  max_user_sessions: 
    all: 10
  muc: 
    all: allow
  muc_admin: 
    admin: allow
  muc_create: 
    local: allow
  pubsub_createnode: 
    local: allow
  register: 
    all: allow
  s2s_shaper: 
    all: fast
acl: 
  admin: 
    user: 
      - 
        "admin": "localhost"
  local: 
    user_regexp: 
      - []
auth_method: internal
language: "en"
listen: 
  - 
    port: 5222
    module: ejabberd_c2s
    max_stanza_size: 65536
    shaper: c2s_shaper
    access: c2s
    starttls: true
    certfile: "/Applications/ejabberd-13.10/conf/server.pem"
  - 
    port: 5269
    module: ejabberd_s2s_in
  - 
    port: 5280
    module: ejabberd_http
    web_admin: true
    http_poll: true
    http_bind: true
    captcha: true
loglevel: 3
modules: 
  mod_adhoc: []
  mod_announce: 
    access: announce
  mod_caps: []
  mod_configure: []
  mod_disco: []
  mod_http_bind: []
  mod_last: []
  mod_muc: 
    access: muc
    access_create: muc_create
    access_persistent: muc_create
    access_admin: muc_admin
  mod_offline: []
  mod_privacy: []
  mod_private: []
  mod_pubsub: 
    access_createnode: pubsub_createnode
    ignore_pep_from_offline: true
    last_item_cache: false
    plugins: 
      - "flat"
      - "hometree"
      - "pep"
  mod_register: 
    welcome_message: 
      subject: "Welcome!"
      body: "Welcome to this Jabber server."
    access: register
  mod_roster: []
  mod_shared_roster: []
  mod_time: []
  mod_vcard: []
  mod_version: []
shaper: 
  normal: 1000
  fast: 50000

How to let ejabberd use the YAML configuration file?

  • If you installed ejabberd from binary installer, you must edit ejabberdctl script to change configuration file extension on the EJABBERD_CONFIG_PATH environment variable, at line 95.EJABBERD_CONFIG_PATH="$RUNDIR/conf/ejabberd.yml"
  • If you installed ejabberd from sources or any other packaging system, ejabberdctl should already be configured to use YAML file, with following environment definitionEJABBERD_CONFIG_PATH=$ETCDIR/ejabberd.yml

Then, just restart ejabberd.

Et voilà !