diff --git a/defaults/main.yml b/defaults/main.yml index 22f19f90..630bf1a3 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -407,6 +407,20 @@ nova_discover_hosts_in_cells_interval: "{{ 300 if groups['nova_compute'] | lengt # Otherwise keys will be generated on the first run and not regenerated each run. nova_recreate_keys: False +# Define nfs information to enable nfs shares as mounted directories for +# nova. The ``nova_nfs_client`` value is a list of dictionaries that must +# be filled out completely to enable the persistent NFS mounts. +# +# Example of the expected dict structure: +# nova_nfs_client: +# - server: "127.0.0.1" ## Hostname or IP address of NFS Server +# remote_path: "/instances" ## Remote path from the NFS server's export +# local_path: "/var/lib/nova/instances" ## Local path on machine +# type: "nfs" ## This can be nfs or nfs4 +# options: "_netdev,auto" ## Mount options +# config_overrides: "{}" ## Override dictionary for unit file +nova_nfs_client: [] + # Nova Ceph rbd # Enble and define nova_libvirt_images_rbd_pool to use rbd as nova backend #nova_libvirt_images_rbd_pool: vms diff --git a/releasenotes/notes/add-nfs-support-5aacc81dbf3c2270.yaml b/releasenotes/notes/add-nfs-support-5aacc81dbf3c2270.yaml new file mode 100644 index 00000000..44e38d95 --- /dev/null +++ b/releasenotes/notes/add-nfs-support-5aacc81dbf3c2270.yaml @@ -0,0 +1,5 @@ +--- +features: + - It is now possible to use NFS mountpoints with the role by using the + nova_nfs_client variable, which is useful for using NFS for instance + data and saves. diff --git a/tasks/nova_compute.yml b/tasks/nova_compute.yml index c0bf7f5a..292d6270 100644 --- a/tasks/nova_compute.yml +++ b/tasks/nova_compute.yml @@ -24,3 +24,31 @@ - include_tasks: nova_compute_key_distribute.yml tags: - nova-config + +- name: Run the systemd mount role + include_role: + name: systemd_mount + private: true + vars: + systemd_mounts: + - config_overrides: "{{ mount_var.config_overrides | default({}) }}" + what: "{{ mount_var.server }}:{{ mount_var.remote_path }}" + where: "{{ mount_var.local_path }}" + type: "{{ mount_var.type }}" + options: "{{ mount_var.options }}" + unit: + After: + - network.target rpcbind.service rpc-statd.service + Conflicts: + - umount.target + Requires: + - rpcbind.service rpc-statd.service + Before: + - nova-compute.service + state: 'started' + enabled: true + with_items: "{{ nova_nfs_client }}" + loop_control: + loop_var: mount_var + tags: + - nova-config diff --git a/tasks/nova_pre_install.yml b/tasks/nova_pre_install.yml index f33967e4..1c540cab 100644 --- a/tasks/nova_pre_install.yml +++ b/tasks/nova_pre_install.yml @@ -52,6 +52,15 @@ - nova-key - nova-key-create +- name: Create Nova NFS mount point(s) + file: + path: "{{ item.local_path }}" + state: directory + mode: "0755" + with_items: "{{ nova_nfs_client }}" + tags: + - nova-dirs + - name: Create nova dir file: path: "{{ item.path }}" @@ -59,6 +68,8 @@ owner: "{{ item.owner|default(nova_system_user_name) }}" group: "{{ item.group|default(nova_system_group_name) }}" mode: "{{ item.mode|default('0755') }}" + when: + - "item.path not in nova_mount_points" with_items: - { path: "/openstack", owner: "root", group: "root" } - { path: "/etc/nova", mode: "0750" } diff --git a/vars/main.yml b/vars/main.yml index d2075dce..22ef2784 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -28,3 +28,13 @@ filtered_nova_services: |- {% endif %} {% endfor %} {{ services | sort(attribute='start_order') }} + +# Define all Nova mountpoints when using NFS. If defined +# the corresponding directory will only be created by the +# mount point task. +nova_mount_points: |- + {% set mps = [] %} + {% for mp in nova_nfs_client %} + {% set _ = mps.append(mp.local_path) %} + {% endfor %} + {{ mps }}