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à !

  • Richard Phillips

    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!

    • what

      So can you more specific about what problem you have? or is that resolved already?

    • Christophe Romain

      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.

  • Pingback: ejabberd joins the Elixir revolution | ProcessOne — Blog()

  • Daryl Tucker

    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 ‘-‘.