Switch ejabberd configuration to YAML

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 definition

    EJABBERD_CONFIG_PATH=$ETCDIR/ejabberd.yml

Then, just restart ejabberd.

Et voilà !


Let us know what you think 💬


7 thoughts on “Switch ejabberd configuration to YAML

  1. Installed from source, both erlang and ejabberd – then…

    /sbin/ejabberdctl convert_to_yaml ejabberdctl.cfg ejabberd.yml

    Problem ‘exit “Problem loading ejabberd config file /etc/ejabberd/ejabberdctl.cfg approximately in the line 2: syntax error before: ‘#'”‘ occurred executing the command.

    Stacktrace: [{ejabberd_config,exit_or_halt,1,

    [{file,”src/ejabberd_config.erl”},{line,302}]},

    {ejabberd_config,read_file,2,

    [{file,”src/ejabberd_config.erl”},{line,101}]},

    {ejabberd_config,convert_to_yaml,2,

    [{file,”src/ejabberd_config.erl”},{line,131}]},

    {ejabberd_ctl,call_command,3,

    [{file,”src/ejabberd_ctl.erl”},{line,294}]},

    {ejabberd_ctl,try_call_command,3,

    [{file,”src/ejabberd_ctl.erl”},{line,270}]},

    {ejabberd_ctl,process2,3,

    [{file,”src/ejabberd_ctl.erl”},{line,219}]},

    {ejabberd_ctl,process,1,

    [{file,”src/ejabberd_ctl.erl”},{line,204}]},

    {rpc,’-handle_call_call/6-fun-0-‘,5,

    [{file,”rpc.erl”},{line,205}]}]

    Any thoughts?

    Thanks!

    • you try to convert ejabberdctl.cfg, which is not ejabberd.cfg. that’s the reason of your error cause ejabberdctl.cfg is not an erlang term based configuration file.

  2. I noticed an issue showing up as “no function clause matching ejabberd_c2s” in my logs. It seems that some values are not converted from the old .cfg to the new .yml configuration. Check your yml configuration file for entries that show up as “val01,val02”, break them out onto newlines, pre-pended with ‘-‘.

    • As explained in the post, it is just a matter of changing environment variable EJABBERD_CONFIG_PATH.

  3. I’m following following steps to configure ejabbed server on local system, but when open server URL on port number 5280, it’s not loading. ‘Page Not Found’.

    I’m using Ubuntu 15.10. and following steps as suggest:

    sudo apt-get install ejabberd
    sudo echo “192.168.10.120 myexample.com” >> /etc/hosts
    ejabberdctl register admin localhost password
    ejabberdctl register admin myexample.com password

    In
    /etc/ejabberd/ejabberd.yml

    acl:
    admin:
    user:
    – “admin”: “localhost”
    – “admin”: “im.myexample.com”

    hosts:
    – “localhost”
    – “myexample.com”

    and then “sudo service ejabberd restart”
    I checked even status with “ejabberdctl status” and it show:

    “The node ‘ejabberd@ova-All-Series’ is started with status: started
    ejabberd 15.03 is running in that node”

    Am I missing anything here, Please suggest.

Leave a Reply to Daryl Tucker Cancel Reply


This site uses Akismet to reduce spam. Learn how your comment data is processed.