diff --git a/docker/openstack-base/Dockerfile.j2 b/docker/openstack-base/Dockerfile.j2
index 6a041d947e8f5bc6a1690b2f7302d5990a3f9f00..41b3099456026b85becb90539ff3f8f41858d0aa 100644
--- a/docker/openstack-base/Dockerfile.j2
+++ b/docker/openstack-base/Dockerfile.j2
@@ -1,12 +1,16 @@
 FROM {{ namespace }}/{{ image_prefix }}base:{{ tag }}
 MAINTAINER {{ maintainer }}
 
+{% import "macros.j2" as macros with context %}
+
 {% if base_distro in ['fedora', 'centos', 'oraclelinux', 'rhel'] %}
-RUN yum -y install \
-        git \
-        iproute \
-        openssl \
-    && yum clean all
+    {% set openstack_base_packages = [
+        'git',
+        'iproute',
+        'openssl'
+    ] %}
+
+RUN {{ macros.install_packages(openstack_base_packages) }}
 
 {% endif %}
 {% if install_type == 'binary' %}
@@ -14,209 +18,207 @@ RUN yum -y install \
 
 # TODO(Allen) Remove python-dogpile-cache after the requirement of
 # python-ironicclient is fixed.
-RUN yum -y install \
-        avahi-libs \
-        cups-libs \
-        fontconfig \
-        fontpackages-filesystem \
-        freetype \
-        initscripts \
-        libjpeg-turbo \
-        libpng \
-        libtomcrypt \
-        libtommath \
-        libX11 \
-        libX11-common \
-        libXau \
-        libxcb \
-        libXext \
-        libXi \
-        libxslt \
-        libyaml \
-        MySQL-python \
-        Percona-Server-shared-56 \
-        pyOpenSSL \
-        pyparsing \
-        python2-cffi \
-        python2-crypto \
-        python2-cryptography \
-        python2-debtcollector \
-        python2-eventlet \
-        python2-fasteners \
-        python2-funcsigs \
-        python2-futurist \
-        python2-greenlet \
-        python2-iso8601 \
-        python2-msgpack \
-        python2-oslo-concurrency \
-        python2-oslo-config \
-        python2-oslo-context \
-        python2-oslo-db \
-        python2-oslo-i18n \
-        python2-oslo-log \
-        python2-oslo-messaging \
-        python2-oslo-middleware \
-        python2-oslo-policy \
-        python2-oslo-serialization \
-        python2-oslo-service \
-        python2-oslo-utils \
-        python2-pika \
-        python2-pika_pool \
-        python2-positional \
-        python2-pyasn1 \
-        python2-PyMySQL \
-        python-alembic \
-        python-amqp \
-        python-anyjson \
-        python-barbicanclient \
-        python-beaker \
-        python-cachetools \
-        python-ceilometerclient \
-        python-cliff \
-        python-cmd2 \
-        python-congressclient \
-        python-contextlib2 \
-        python-dateutil \
-        python-decorator \
-        python-designateclient \
-        python-dogpile-cache \
-        python-editor \
-        python-enum34 \
-        python-extras \
-        python-fixtures \
-        python-futures \
-        python-glanceclient \
-        python-heatclient \
-        python-httplib2 \
-        python-idna \
-        python-inotify \
-        python-ipaddress \
-        python-ironicclient \
-        python-jsonpatch \
-        python-jsonpointer \
-        python-jsonschema \
-        python-keyring \
-        python-keystoneauth1 \
-        python-keystoneclient \
-        python-keystonemiddleware \
-        python-kombu \
-        python-linecache2 \
-        python-lxml \
-        python-magnumclient \
-        python-mako \
-        python-manilaclient \
-        python-memcached \
-        python-migrate \
-        python-mimeparse \
-        python-mistralclient \
-        python-monotonic \
-        python-muranoclient \
-        python-netaddr \
-        python-netifaces \
-        python-neutronclient \
-        python-novaclient \
-        python-openstackclient \
-        python-paste \
-        python-paste-deploy \
-        python-pbr \
-        python-pip \
-        python-ply \
-        python-posix_ipc \
-        python-prettytable \
-        python-pycparser \
-        python-PyMySQL \
-        python-repoze-lru \
-        python-requests \
-        python-retrying \
-        python-routes \
-        python-saharaclient \
-        python-simplejson \
-        python-sqlalchemy \
-        python-sqlparse \
-        python-stevedore \
-        python-swiftclient \
-        python-tempita \
-        python-testtools \
-        python-traceback2 \
-        python-troveclient \
-        python-unicodecsv \
-        python-unittest2 \
-        python-urllib3 \
-        python-warlock \
-        python-webob \
-        python-wrapt \
-        python-zaqarclient \
-        PyYAML \
-        systemd-sysv \
-        sysvinit-tools \
-        tcp_wrappers-libs \
-    && yum clean all
-
+        {% set openstack_base_packages = [
+            'avahi-libs',
+            'cups-libs',
+            'fontconfig',
+            'fontpackages-filesystem',
+            'freetype',
+            'initscripts',
+            'libjpeg-turbo',
+            'libpng',
+            'libtomcrypt',
+            'libtommath',
+            'libX11',
+            'libX11-common',
+            'libXau',
+            'libxcb',
+            'libXext',
+            'libXi',
+            'libxslt',
+            'libyaml',
+            'MySQL-python',
+            'Percona-Server-shared-56',
+            'pyOpenSSL',
+            'pyparsing',
+            'python2-cffi',
+            'python2-crypto',
+            'python2-cryptography',
+            'python2-debtcollector',
+            'python2-eventlet',
+            'python2-fasteners',
+            'python2-funcsigs',
+            'python2-futurist',
+            'python2-greenlet',
+            'python2-iso8601',
+            'python2-msgpack',
+            'python2-oslo-concurrency',
+            'python2-oslo-config',
+            'python2-oslo-context',
+            'python2-oslo-db',
+            'python2-oslo-i18n',
+            'python2-oslo-log',
+            'python2-oslo-messaging',
+            'python2-oslo-middleware',
+            'python2-oslo-policy',
+            'python2-oslo-serialization',
+            'python2-oslo-service',
+            'python2-oslo-utils',
+            'python2-pika',
+            'python2-pika_pool',
+            'python2-positional',
+            'python2-pyasn1',
+            'python2-PyMySQL',
+            'python-alembic',
+            'python-amqp',
+            'python-anyjson',
+            'python-barbicanclient',
+            'python-beaker',
+            'python-cachetools',
+            'python-ceilometerclient',
+            'python-cliff',
+            'python-cmd2',
+            'python-congressclient',
+            'python-contextlib2',
+            'python-dateutil',
+            'python-decorator',
+            'python-designateclient',
+            'python-dogpile-cache',
+            'python-editor',
+            'python-enum34',
+            'python-extras',
+            'python-fixtures',
+            'python-futures',
+            'python-glanceclient',
+            'python-heatclient',
+            'python-httplib2',
+            'python-idna',
+            'python-inotify',
+            'python-ipaddress',
+            'python-ironicclient',
+            'python-jsonpatch',
+            'python-jsonpointer',
+            'python-jsonschema',
+            'python-keyring',
+            'python-keystoneauth1',
+            'python-keystoneclient',
+            'python-keystonemiddleware',
+            'python-kombu',
+            'python-linecache2',
+            'python-lxml',
+            'python-magnumclient',
+            'python-mako',
+            'python-manilaclient',
+            'python-memcached',
+            'python-migrate',
+            'python-mimeparse',
+            'python-mistralclient',
+            'python-monotonic',
+            'python-muranoclient',
+            'python-netaddr',
+            'python-netifaces',
+            'python-neutronclient',
+            'python-novaclient',
+            'python-openstackclient',
+            'python-paste',
+            'python-paste-deploy',
+            'python-pbr',
+            'python-pip',
+            'python-ply',
+            'python-posix_ipc',
+            'python-prettytable',
+            'python-pycparser',
+            'python-PyMySQL',
+            'python-repoze-lru',
+            'python-requests',
+            'python-retrying',
+            'python-routes',
+            'python-saharaclient',
+            'python-simplejson',
+            'python-sqlalchemy',
+            'python-sqlparse',
+            'python-stevedore',
+            'python-swiftclient',
+            'python-tempita',
+            'python-testtools',
+            'python-traceback2',
+            'python-troveclient',
+            'python-unicodecsv',
+            'python-unittest2',
+            'python-urllib3',
+            'python-warlock',
+            'python-webob',
+            'python-wrapt',
+            'python-zaqarclient',
+            'PyYAML',
+            'systemd-sysv',
+            'sysvinit-tools',
+            'tcp_wrappers-libs'
+        ] %}
     {% elif base_distro in ['ubuntu'] %}
 
 # This will prevent questions from being asked during the install
 ENV DEBIAN_FRONTEND noninteractive
-RUN apt-get -y install --no-install-recommends \
-        python-barbicanclient \
-        python-ceilometerclient \
-        python-congressclient \
-        python-designateclient \
-        python-heatclient \
-        python-ironicclient \
-        python-magnumclient \
-        python-manilaclient \
-        python-memcache \
-        python-mistralclient \
-        python-muranoclient \
-        python-pip \
-        python-saharaclient \
-        python-swiftclient \
-        python-troveclient \
-        python-zaqarclient \
-        python-openstackclient \
-        python-pymysql \
-        python-keystoneclient \
-        python-oslo.log \
-        openssl \
-        patch \
-    && apt-get clean
-
+        {% set openstack_base_packages = [
+            'python-barbicanclient',
+            'python-ceilometerclient',
+            'python-congressclient',
+            'python-designateclient',
+            'python-heatclient',
+            'python-ironicclient',
+            'python-magnumclient',
+            'python-manilaclient',
+            'python-memcache',
+            'python-mistralclient',
+            'python-muranoclient',
+            'python-pip',
+            'python-saharaclient',
+            'python-swiftclient',
+            'python-troveclient',
+            'python-zaqarclient',
+            'python-openstackclient',
+            'python-pymysql',
+            'python-keystoneclient',
+            'python-oslo.log',
+            'openssl',
+            'patch'
+        ] %}
     {% endif %}
-{% elif install_type == 'source' %}
-    {% if base_distro in ['fedora', 'centos', 'oraclelinux', 'rhel'] %}
 
-RUN yum -y install \
-        gcc \
-        gcc-c++ \
-        libffi-devel \
-        libxml2-devel \
-        libxslt-devel \
-        MariaDB-devel \
-        openldap-devel \
-        openssl-devel \
-        postgresql \
-        postgresql-devel \
-        python-devel \
-        sqlite-devel \
-    && yum clean all
+RUN {{ macros.install_packages(openstack_base_packages | customizable("packages")) }}
 
+{% elif install_type == 'source' %}
+    {% if base_distro in ['fedora', 'centos', 'oraclelinux', 'rhel'] %}
+        {% set openstack_base_packages = [
+            'gcc',
+            'gcc-c++',
+            'libffi-devel',
+            'libxml2-devel',
+            'libxslt-devel',
+            'MariaDB-devel',
+            'openldap-devel',
+            'openssl-devel',
+            'postgresql',
+            'postgresql-devel',
+            'python-devel',
+            'sqlite-devel'
+        ] %}
     {% elif base_distro in ['ubuntu', 'debian'] %}
-
-RUN apt-get -y install --no-install-recommends \
-        ca-certificates \
-        build-essential \
-        python-dev \
-        libssl-dev \
-        libmariadbclient-dev \
-        libxslt1-dev \
-        libffi-dev \
-        libyaml-dev \
-        pkg-config \
-        git \
-    && apt-get clean
-
+        {% set openstack_base_packages = [
+            'ca-certificates',
+            'build-essential',
+            'python-dev',
+            'libssl-dev',
+            'libmariadbclient-dev',
+            'libxslt1-dev',
+            'libffi-dev',
+            'libyaml-dev',
+            'pkg-config',
+            'git'
+        ] %}
     {% endif %}
 
+RUN {{ macros.install_packages(openstack_base_packages | customizable("packages")) }}
 ADD openstack-base-archive /openstack-base-source
 RUN ln -s openstack-base-source/* /requirements \
     && mkdir -p /var/lib/kolla \
@@ -330,3 +332,6 @@ RUN ln -s openstack-base-source/* /requirements \
 ENV PATH /var/lib/kolla/venv/bin:$PATH
 
 {% endif %}
+
+{% block openstack_base_footer %}{% endblock %}
+{% block footer %}{% endblock %}