CentOS repos (both official and EPEL) does not provide an up to date version of Ejabberd, installing from source is the only way if one want or need a version from this century.
Problem is that doing things manually is a never ever a good idea, luckily Ansible and a bit of Python love come to rescue.
Supposing Ejabberd is already installed and configured (I wrote a post on the subject a couple of years ago: https://uwot.eu/ejabberd-xmpp-server-configuration-guide//) the following Ansible script will take care of all the steps needed to upgrade to a newer version of Ejabberd

centos7-upgrade-ejabberd.yml

- hosts: ejabberd
  vars:
    local_conf_path: /home/user/ansible-playbook-scripts/
    remote_src_path: /home/user/binaries/ejabberd/
    remote_etc_path: /usr/local/etc/ejabberd/
  user: root
  tasks:
      - fetch:
          src: "{{ remote_etc_path }}ejabberd.yml"
          flat: yes
          dest: "{{ local_conf_path }}"
      - name: Create directory structure
        command: mkdir -p {{ remote_src_path }}
      - name: Rotate directories
        command: chdir={{ remote_src_path }} {{ item }} 
        with_items:
            - rm -rf ejabberd_old
            - cp -r ejabberd ejabberd_old
        ignore_errors: True      
      - name: Upload git script
        template: owner=root group=root mode=755 src={{ local_conf_path }}ejabberd-git.sh dest={{ remote_src_path }}
      - name: Run upgrade script
        command: /usr/bin/sh /{{ remote_src_path }}ejabberd/ejabberd-git.sh
      - name: Compile latest
        command: chdir={{ remote_src_path }}ejabberd/ {{ item }}
        with_items:
            - sh autogen.sh
            - ./configure --enable-user=ejabberd --disable-graphics
            - make distclean
            - sh autogen.sh
            - ./configure --enable-user=ejabberd --disable-graphics
            - make
      - name: Stop ejabberd service CentOS 7
        command: "{{ item }}"
        with_items: 
            - systemctl stop ejabberd
            - /bin/sleep 20
        ignore_errors: True
      - name: Uninstall old
        command: chdir={{ remote_src_path }}ejabberd_old/ {{ item }}
        with_items:
            - ./configure --enable-user=ejabberd --disable-graphics
            - make uninstall
            - rm -rf /usr/local/lib/*
        ignore_errors: True
      - name: Install latest
        command: chdir={{ remote_src_path }}ejabberd/ make install
        #notify:
        #    - enable ejabberd
      - name: Create ejabberd-0.0 directory
        command: chdir=/usr/local/lib/ cp -r ejabberd* ejabberd-0.0
        ignore_errors: True
      - name: Start ejabberd service 
        command: systemctl start ejabberd

  handlers:
      - name: enable ejabberd
        service: name=ejabberd.service enabled=yes

ejabberd-git.sh

The easiest method of fetching the latest version of Ejabberd is via git tags, I could not make it directly in Ansible (there might be a way tho) I wrote a small bash script to do it for me.

#!/bin/sh

cd /home/fabio/binaries/ejabberd/ejabberd/
make distclean
git fetch --tags
latestTag=$(git describe --tags $(git rev-list --tags --max-count=1))
echo $latestTag > ./version.txt
git checkout $latestTag

To execute an Ansible playbook simply run:

ansible-playbook centos7-upgrade-ejabberd.yml