diff --git a/tests/roles/bootstrap-host/defaults/main.yml b/tests/roles/bootstrap-host/defaults/main.yml index 17b917f4f9..9c71bae7af 100644 --- a/tests/roles/bootstrap-host/defaults/main.yml +++ b/tests/roles/bootstrap-host/defaults/main.yml @@ -86,6 +86,11 @@ bootstrap_host_loopback_zfs: yes # Size of the zfs loopback disk in gigabytes (GB). bootstrap_host_loopback_zfs_size: 1024 # +# Boolean option to deploy the loopback disk for nfs +bootstrap_host_nfs: "{{ 'nfs' in bootstrap_host_scenarios_expanded }}" +# Size of the nfs loopback disk in gigabytes (GB). +bootstrap_host_loopback_nfs_size: 1024 +# # Boolean option to deploy the OSD loopback disks and cluster UUID for Ceph bootstrap_host_ceph: "{{ 'ceph' in bootstrap_host_scenarios_expanded }}" # Size of the Ceph OSD loopbacks diff --git a/tests/roles/bootstrap-host/tasks/main.yml b/tests/roles/bootstrap-host/tasks/main.yml index a3003f0a2e..1c83d05508 100644 --- a/tests/roles/bootstrap-host/tasks/main.yml +++ b/tests/roles/bootstrap-host/tasks/main.yml @@ -137,6 +137,13 @@ tags: - prepare-ceph +# Prepare the NFS server and loopback disks +- include: prepare_nfs.yml + when: + - bootstrap_host_nfs | bool + tags: + - prepare-nfs + # Ensure hostname/ip is consistent with inventory - include: prepare_hostname.yml tags: diff --git a/tests/roles/bootstrap-host/tasks/prepare_aio_config.yml b/tests/roles/bootstrap-host/tasks/prepare_aio_config.yml index a2810a42d3..c9b5fd44a9 100644 --- a/tests/roles/bootstrap-host/tasks/prepare_aio_config.yml +++ b/tests/roles/bootstrap-host/tasks/prepare_aio_config.yml @@ -167,6 +167,9 @@ - src: user_variables_murano.yml.j2 dest: user_variables_murano.yml condition: "{{ 'murano' in bootstrap_host_scenarios_expanded }}" + - src: user_variables_nfs.yml.j2 + dest: user_variables_nfs.yml + condition: "{{ 'nfs' in bootstrap_host_scenarios_expanded }}" - src: user_variables_calico.yml.j2 dest: user_variables_calico.yml condition: "{{ 'calico' in bootstrap_host_scenarios_expanded }}" diff --git a/tests/roles/bootstrap-host/tasks/prepare_nfs.yml b/tests/roles/bootstrap-host/tasks/prepare_nfs.yml new file mode 100644 index 0000000000..5ca558fd29 --- /dev/null +++ b/tests/roles/bootstrap-host/tasks/prepare_nfs.yml @@ -0,0 +1,99 @@ +--- +# Copyright 2021, City Network International AB +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Create sparse NFS volume + command: "truncate -s {{ bootstrap_host_loopback_nfs_size }}G /openstack/nfs.img" + args: + creates: /openstack/nfs.img + tags: + - nfs-file-create + +- name: Format the NFS file + filesystem: + fstype: xfs + dev: /openstack/nfs.img + opts: "{{ bootstrap_host_format_options['xfs'] | default(omit) }}" + tags: + - nfs-format-file + +- name: Run the systemd mount role + include_role: + name: systemd_mount + vars: + systemd_mounts: + - what: "/openstack/nfs.img" + where: "/srv/nfs" + options: "loop,{{ bootstrap_host_data_mount_options['xfs'] }}" + type: "xfs" + state: 'started' + enabled: true + tags: + - nfs-config + +- name: Install NFS packages + package: + name: "{{ nfs_package }}" + state: present + +- name: create the system group for nfs + group: + name: "nfs-user" + gid: "10000" + state: "present" + system: "yes" + +- name: Create the system user for nfs + user: + name: "nfs-user" + uid: "10000" + group: "nfs-user" + comment: "nfs-user" + shell: "/bin/false" + system: "yes" + createhome: "yes" + home: "/srv/nfs" + +- name: Create base directories + file: + path: "{{ item }}" + state: "directory" + owner: "nfs-user" + group: "nfs-user" + with_items: + - "/srv/nfs/glance" + +- name: Create exports file + lineinfile: + path: /etc/exports + line: '{{ item }} {{ storage_range }}.0/{{ netmask }}(rw,sync,no_subtree_check,insecure,all_squash,anonuid=10000,anongid=10000)' + owner: root + group: root + mode: 0644 + create: yes + with_items: + - "/srv/nfs/glance" + register: nfs_exportfs + +- name: Restart nfs-server + systemd: + daemon_reload: yes + name: "nfs-server" + enabled: "yes" + state: "restarted" + when: + - nfs_exportfs is changed + +- name: Export NFS + command: exportfs -rav diff --git a/tests/roles/bootstrap-host/templates/user_variables_nfs.yml.j2 b/tests/roles/bootstrap-host/templates/user_variables_nfs.yml.j2 new file mode 100644 index 0000000000..2c39a75894 --- /dev/null +++ b/tests/roles/bootstrap-host/templates/user_variables_nfs.yml.j2 @@ -0,0 +1,9 @@ +--- + +glance_default_store: file +glance_nfs_client: + - server: "172.29.244.100" + remote_path: "/srv/nfs/glance" + local_path: "/var/lib/glance/images" + type: "nfs" + options: "_netdev,auto" diff --git a/tests/roles/bootstrap-host/vars/debian.yml b/tests/roles/bootstrap-host/vars/debian.yml index 842d46fa90..9fa5d8b837 100644 --- a/tests/roles/bootstrap-host/vars/debian.yml +++ b/tests/roles/bootstrap-host/vars/debian.yml @@ -44,3 +44,5 @@ packages_remove: rc_local: /etc/rc.local rc_local_insert_before: "^exit 0$" + +nfs_package: nfs-kernel-server diff --git a/tests/roles/bootstrap-host/vars/redhat-8.yml b/tests/roles/bootstrap-host/vars/redhat-8.yml index ad045b2d36..c9e9b8afda 100644 --- a/tests/roles/bootstrap-host/vars/redhat-8.yml +++ b/tests/roles/bootstrap-host/vars/redhat-8.yml @@ -33,3 +33,5 @@ packages_remove: [] rc_local: /etc/rc.d/rc.local rc_local_insert_before: "^touch /var/lock/subsys/local$" + +nfs_package: nfs-utils diff --git a/tests/roles/bootstrap-host/vars/redhat.yml b/tests/roles/bootstrap-host/vars/redhat.yml index dba8d4d1ef..f2c60e6e06 100644 --- a/tests/roles/bootstrap-host/vars/redhat.yml +++ b/tests/roles/bootstrap-host/vars/redhat.yml @@ -33,3 +33,5 @@ packages_remove: [] rc_local: /etc/rc.d/rc.local rc_local_insert_before: "^touch /var/lock/subsys/local$" + +nfs_package: nfs-utils diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index ff85d1a304..87caec4eae 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -276,6 +276,11 @@ parent: openstack-ansible-deploy-aio nodeset: ubuntu-focal +- job: + name: openstack-ansible-deploy-aio_nfs-ubuntu-focal + parent: openstack-ansible-deploy-aio + nodeset: ubuntu-focal + - job: name: openstack-ansible-deploy-aio_proxy-ubuntu-focal parent: openstack-ansible-deploy-aio @@ -434,6 +439,11 @@ parent: openstack-ansible-deploy-aio nodeset: centos-8-stream +- job: + name: openstack-ansible-deploy-aio_nfs-centos-8-stream + parent: openstack-ansible-deploy-aio + nodeset: centos-8-stream + - job: name: openstack-ansible-deploy-aio_distro_ceph-centos-8-stream parent: openstack-ansible-deploy-aio-distro diff --git a/zuul.d/project-templates.yaml b/zuul.d/project-templates.yaml index 2c20eea053..c413bae35e 100644 --- a/zuul.d/project-templates.yaml +++ b/zuul.d/project-templates.yaml @@ -204,6 +204,15 @@ jobs: - openstack-ansible-deploy-aio_distro_metal-debian-bullseye +- project-template: + name: openstack-ansible-deploy-nfs-jobs + check: + jobs: + - openstack-ansible-deploy-aio_nfs-ubuntu-focal + gate: + jobs: + - openstack-ansible-deploy-aio_nfs-ubuntu-focal + - project-template: name: openstack-ansible-deploy-ceph-jobs check: