From e6c2b14c717568b6f6284e614d170081c4283cce Mon Sep 17 00:00:00 2001 From: Bjoern Teipel Date: Tue, 17 Jan 2017 15:54:19 -0600 Subject: [PATCH] Implement NFS multi backend support The NFS implementation based off cinder_nfs_client does not support per cinder backend configuration, separating NFS mounts per backend. This fix removes cinder_nfs_client in favor of fully supporting multi cinder backends over the cinder_backends stanza. Closes-Bug #1657203 Change-Id: I817ff372c2d58e999a89496fce3d25dc617216f0 --- defaults/main.yml | 10 --- doc/source/configure-cinder.rst | 62 +++++++++++++++---- ...der-nfs-multibackend-df133e8fff374da4.yaml | 5 ++ tasks/cinder_post_install.yml | 7 ++- templates/cinder.conf.j2 | 3 - templates/nfs_shares.j2 | 3 +- 6 files changed, 60 insertions(+), 30 deletions(-) create mode 100644 releasenotes/notes/cinder-nfs-multibackend-df133e8fff374da4.yaml diff --git a/defaults/main.yml b/defaults/main.yml index 1bf1e17b..d1e524bb 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -205,16 +205,6 @@ cinder_quota_backup_gigabytes: 1000 # cinder_backend_lvm_inuse: True if current host has an lvm backend cinder_backend_lvm_inuse: '{{ (cinder_backends|default("")|to_json).find("lvm") != -1 }}' -## Define nfs information for cinder. When the cinder_nfs_client dictionary is defined, -## it will enable nfs shares. The value ``nfs_shares_config`` is the path on the disk -## where the NFS export will live. The ``shares`` value is a list of dictionaries that -## must have the IP address of the NFS server and the location where the export will be. -# cinder_nfs_client: -# nfs_shares_config: /etc/cinder/nfs_shares -# shares: -# - ip: "127.0.0.1" -# share: "/vol/cinder" - ## Policy vars # Provide a list of access controls to update the default policy.json with. These changes will be merged # with the access controls in the default policy.json. E.g. diff --git a/doc/source/configure-cinder.rst b/doc/source/configure-cinder.rst index 48a28b44..82bf7ac6 100644 --- a/doc/source/configure-cinder.rst +++ b/doc/source/configure-cinder.rst @@ -30,15 +30,29 @@ Edit ``/etc/openstack_deploy/openstack_user_config.yml`` and configure the NFS client on each storage node if the NetApp backend is configured to use an NFS storage protocol. -#. Add the ``cinder_backends`` stanza (which includes - ``cinder_nfs_client``) under the ``container_vars`` stanza for - each storage node: +#. For each storage node, add one ``cinder_backends`` block underneath + the a new ``container_vars`` section. ``container_vars`` are used to + allow container/host individualized configuration. Each cinder back end + is defined with a unique key. For example, ``nfs-volume1``. + This later represents a unique cinder backend and volume type. .. code-block:: yaml container_vars: cinder_backends: - cinder_nfs_client: + nfs-volume1: + +#. Configure the appropriate cinder volume backend name: + + .. code:: + + volume_backend_name: NFS_VOLUME1 + +#. Configure the appropriate cinder NFS driver: + + .. code:: + + volume_driver: cinder.volume.drivers.nfs.NfsDriver #. Configure the location of the file that lists shares available to the block storage service. This configuration file must include @@ -46,21 +60,43 @@ an NFS storage protocol. .. code-block:: yaml - nfs_shares_config: SHARE_CONFIG + nfs_shares_config: FILENAME_NFS_SHARES - Replace ``SHARE_CONFIG`` with the location of the share - configuration file. For example, ``/etc/cinder/nfs_shares``. + Replace ``FILENAME_NFS_SHARES`` with the location of the share + configuration file. For example, ``/etc/cinder/nfs_shares_volume1``. + +#. Define mount options for the NFS mount. For example: + + .. code:: + + nfs_mount_options: "rsize=65535,wsize=65535,timeo=1200,actimeo=120" #. Configure one or more NFS shares: .. code-block:: yaml shares: - - { ip: "NFS_HOST", share: "NFS_SHARE" } + - { ip: "HOSTNAME", share: "PATH_TO_NFS_VOLUME" } - Replace ``NFS_HOST`` with the IP address or hostname of the NFS - server, and the ``NFS_SHARE`` with the absolute path to an existing - and accessible NFS share. + Replace ``HOSTNAME`` with the IP address or hostname of the NFS + server, and the ``PATH_TO_NFS_VOLUME`` with the absolute path to an + existing and accessible NFS share (excluding the IP address or hostname). + +The following is a full configuration example of a cinder NFS backend +named NFS1. The cinder playbooks will automatically add a custom +``volume-type`` and ``nfs-volume1`` as in this example: + + .. code:: + + container_vars: + cinder_backends: + nfs-volume1: + volume_backend_name: NFS_VOLUME1 + volume_driver: cinder.volume.drivers.nfs.NfsDriver + nfs_shares_config: /etc/cinder/nfs_shares_volume1 + nfs_mount_options: "rsize=65535,wsize=65535,timeo=1200,actimeo=120" + shares: + - { ip: "1.2.3.4", share: "/vol1" } Backup ~~~~~~ @@ -407,9 +443,9 @@ each storage node that will use it. .. code-block:: yaml - nfs_shares_config: SHARE_CONFIG + nfs_shares_config: FILENAME_NFS_SHARES - Replace ``SHARE_CONFIG`` with the location of the share + Replace ``FILENAME_NFS_SHARES`` with the location of the share configuration file. For example, ``/etc/cinder/nfs_shares``. #. Configure the server: diff --git a/releasenotes/notes/cinder-nfs-multibackend-df133e8fff374da4.yaml b/releasenotes/notes/cinder-nfs-multibackend-df133e8fff374da4.yaml new file mode 100644 index 00000000..b32ec2b6 --- /dev/null +++ b/releasenotes/notes/cinder-nfs-multibackend-df133e8fff374da4.yaml @@ -0,0 +1,5 @@ +--- +upgrade: + - The global override ``cinder_nfs_client`` is replaced + in favor of fully supporting multi backends + configuration via the cinder_backends stanza. diff --git a/tasks/cinder_post_install.yml b/tasks/cinder_post_install.yml index 33cd71c3..c96f4cc3 100644 --- a/tasks/cinder_post_install.yml +++ b/tasks/cinder_post_install.yml @@ -68,10 +68,13 @@ - name: Create nfs shares export file template: src: nfs_shares.j2 - dest: "{{ cinder_nfs_client.nfs_shares_config }}" + dest: "{{ item.value.nfs_shares_config }}" + with_dict: "{{ cinder_backends }}" when: - - cinder_nfs_client is defined + - item.value.nfs_shares_config is defined - inventory_hostname in groups['cinder_volume'] + tags: + - cinder-nfs - name: Drop sudoers file template: diff --git a/templates/cinder.conf.j2 b/templates/cinder.conf.j2 index 090f6a78..7ac77dbd 100644 --- a/templates/cinder.conf.j2 +++ b/templates/cinder.conf.j2 @@ -102,9 +102,6 @@ enabled_backends={% for backend in cinder_backends|dictsort %}{{ backend.0 }}{% {% for key, value in backend_section.1.items() if key != 'extra_volume_types' %} {{ key }}={{ value }} {% endfor %} -{% if cinder_nfs_client is defined %} -nfs_shares_config={{ cinder_nfs_client.nfs_shares_config }} -{% endif %} {% endfor %} {% endif %} diff --git a/templates/nfs_shares.j2 b/templates/nfs_shares.j2 index a421319b..31f04dbe 100644 --- a/templates/nfs_shares.j2 +++ b/templates/nfs_shares.j2 @@ -1,5 +1,4 @@ # {{ ansible_managed }} - -{% for share in cinder_nfs_client.shares %} +{% for share in item.value.shares %} {{ share.ip }}:{{ share.share }} {% endfor %}