From 887a59256eeba7a346b63d5c0db6d1f909d6b26c Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Tue, 12 Apr 2022 12:56:38 +0200 Subject: [PATCH] Use systemd_mount native syntax for mounts Currently we have bunch of limitations related to the format of ``glance_nfs_client``. While systemd_mount role is flexible enough to allow mount cephfs or s3fs, variable format has weird assumptions that we want to change for better flexability. Since keys of variable are changing, new name for it was picked to reflect purpose of the variable better. Change-Id: Ic0d91a3a873b4253255beac79becf01b4a304695 --- defaults/main.yml | 15 +++++++-------- .../glance_remote_client-78e5d426cb55717f.yaml | 13 +++++++++++++ tasks/glance_install.yml | 2 +- tasks/glance_post_install.yml | 10 +++++----- templates/glance-api.conf.j2 | 2 +- tests/overrides-nfs.yml | 7 +++---- vars/main.yml | 4 ++-- 7 files changed, 32 insertions(+), 21 deletions(-) create mode 100644 releasenotes/notes/glance_remote_client-78e5d426cb55717f.yaml diff --git a/defaults/main.yml b/defaults/main.yml index e3a875aa..cc200532 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -207,17 +207,16 @@ glance_policy_dirs: policy.d # Define nfs information to enable nfs shares as mounted directories for -# glance. The ``glance_nfs_client`` value is a list of dictionaries that must -# be filled out completely to enable the persistent NFS mounts. -glance_nfs_local_directory: "images" -glance_nfs_client: [] +# glance. The ``glance_remote_client`` value is a list of dictionaries that must +# be filled out completely to enable the persistent remote FS mounts (like NFS). +glance_images_local_directory: "{{ glance_nfs_local_directory | default('images') }}" +glance_remote_client: "{{ glance_nfs_client | default([]) }}" # Example of the expected dict structure: # -# glance_nfs_client: -# - server: "127.0.0.1" ## Hostname or IP address of NFS Server -# remote_path: "/images" ## Remote path from the NFS server's export -# local_path: "/var/lib/glance/images" ## Local path on machine +# glance_remote_client: +# - what: "127.0.0.1:/images" ## Hostname or IP address of Server and path on it +# where: "/var/lib/glance/images" ## Local path on machine # type: "nfs" ## This can be nfs or nfs4 # options: "_netdev,auto" ## Mount options # config_overrides: "{}" ## Override dictionary for unit file diff --git a/releasenotes/notes/glance_remote_client-78e5d426cb55717f.yaml b/releasenotes/notes/glance_remote_client-78e5d426cb55717f.yaml new file mode 100644 index 00000000..2e67441e --- /dev/null +++ b/releasenotes/notes/glance_remote_client-78e5d426cb55717f.yaml @@ -0,0 +1,13 @@ +--- +features: +deprecations: + - | + Variable ``glance_nfs_local_directory`` has been renamed to + ``glance_images_local_directory`` to better reflect purpose of + the variable. ``glance_nfs_local_directory`` remains for backwards + compatability but will be removed in Zed release. + - | + Variable ``glance_nfs_client`` has been replaced with + ``glance_remote_client``. New variable has new keys for defining mounts + to cover wider range of supported filesystems. + Compatability for ``glance_nfs_client`` has been kept until Zed release. diff --git a/tasks/glance_install.yml b/tasks/glance_install.yml index 3da06c77..441f7dcd 100644 --- a/tasks/glance_install.yml +++ b/tasks/glance_install.yml @@ -101,7 +101,7 @@ - path: "{{ glance_system_user_home }}/cache/api" mode: "0700" - path: "{{ glance_system_user_home }}/scrubber" - - path: "{{ glance_system_user_home }}/{{ glance_nfs_local_directory }}" + - path: "{{ glance_system_user_home }}/{{ glance_images_local_directory }}" mode: "0755" - name: Install distro packages diff --git a/tasks/glance_post_install.yml b/tasks/glance_post_install.yml index 0f64a578..82d2d352 100644 --- a/tasks/glance_post_install.yml +++ b/tasks/glance_post_install.yml @@ -170,8 +170,8 @@ vars: systemd_mounts: - config_overrides: "{{ mount_var.config_overrides | default({}) }}" - what: "{{ mount_var.server }}:{{ mount_var.remote_path }}" - where: "{{ mount_var.local_path }}" + what: "{{ mount_var.what | default(mount_var.server ~ ':' ~ mount_var.remote_path) }}" + where: "{{ mount_var.where | default(mount_var.local_path) }}" type: "{{ mount_var.type }}" options: "{{ mount_var.options }}" unit: @@ -183,9 +183,9 @@ - rpcbind.service rpc-statd.service Before: - glance-api.service - state: 'started' - enabled: true - with_items: "{{ glance_nfs_client }}" + state: "{{ mount_var.state | default('started') }}" + enabled: "{{ mount_var.enabled | default(True) }}" + with_items: "{{ glance_remote_client }}" loop_control: loop_var: mount_var tags: diff --git a/templates/glance-api.conf.j2 b/templates/glance-api.conf.j2 index 4235eec1..573c5a40 100644 --- a/templates/glance-api.conf.j2 +++ b/templates/glance-api.conf.j2 @@ -79,7 +79,7 @@ default_backend = {{ glance_default_store }} {% if 'file' in _glance_available_stores %} [file] -filesystem_store_datadir = {{ glance_system_user_home }}/{{ glance_nfs_local_directory }}/ +filesystem_store_datadir = {{ glance_system_user_home }}/{{ glance_images_local_directory }}/ {% endif %} {% if 'swift' in _glance_available_stores %} diff --git a/tests/overrides-nfs.yml b/tests/overrides-nfs.yml index 7a56a1ac..f4921052 100644 --- a/tests/overrides-nfs.yml +++ b/tests/overrides-nfs.yml @@ -15,9 +15,8 @@ # Force glance to use file by default which will be an NFS mount point. glance_default_store: file -glance_nfs_client: - - server: "10.1.0.1" - remote_path: "/srv/nfs/glance" - local_path: "/var/lib/glance/images" +glance_remote_client: + - what: "10.1.0.1:/srv/nfs/glance" + where: "/var/lib/glance/images" type: "nfs" options: "_netdev,auto" diff --git a/vars/main.yml b/vars/main.yml index 47564313..fac82652 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -60,8 +60,8 @@ uwsgi_glance_services: |- # mount point task. glance_mount_points: |- {% set mps = [] %} - {% for mp in glance_nfs_client %} - {% set _ = mps.append(mp.local_path) %} + {% for mp in glance_remote_client %} + {% set _ = mps.append(mp.where | default(mount_var.local_path)) %} {% endfor %} {{ mps }}