--- # 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: Install NFS packages ansible.builtin.package: name: "{{ nfs_package }}" state: present - name: Create the system group for nfs ansible.builtin.group: name: "nfs-user" gid: "10000" state: "present" system: "yes" - name: Create the system user for nfs ansible.builtin.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 ansible.builtin.file: path: "{{ item }}" state: "directory" owner: "nfs-user" group: "nfs-user" mode: "0755" with_items: - "/srv/nfs/glance" - "/srv/nfs/cinder" - name: Create exports file ansible.builtin.lineinfile: path: /etc/exports line: '{{ item }} {{ storage_network }}(rw,sync,no_subtree_check,insecure,all_squash,anonuid=10000,anongid=10000)' owner: root group: root mode: "0644" create: true with_items: - "/srv/nfs/glance" - "/srv/nfs/cinder" register: nfs_exportfs - name: Restart nfs-server # noqa: no-handler ansible.builtin.systemd: daemon_reload: true name: "nfs-server" enabled: true state: "restarted" when: - nfs_exportfs is changed - name: Export NFS ansible.builtin.command: exportfs -rav changed_when: false