# Copyright 2022 OCF Ltd. All Rights Reserved. # # 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. # -*- coding: utf-8 -*- # vim: ft=yaml --- ######## runtime vars - name: get exports to be served set_fact: _serve_exports: "{{ serve_exports }}" vars: serve_exports: "{{ exports | selectattr('action', '==', 'exporter' ) }}" ######## run disk_management to ensure mountpoints in place # If you do not have a second VM disk to put LVM onto use this to test # - name: Configure NFS exports directories # file: # path: "{{ path }}" # state: directory # mode: '0755' # loop: "{{ _serve_exports }}" # loop_control: # loop_var: entry # vars: # path: "{{ entry['export'] }}" - name: Configure NFS storage include_role: name: disk_management ######## configure nfsd - name: Configure NFS exports ansible.builtin.template: src: templates/exports.j2 dest: "{{ file_name }}" owner: root group: root mode: 0644 # trim_blocks: False loop: "{{ _serve_exports }}" loop_control: loop_var: entry vars: path: "{{ entry['export'] }}" name: "{{ entry['export'].split('/')[-1] }}" file_name: "/etc/exports.d/ansible_{{ name }}.exports" opts: "{{ entry['opts'] }}" network_name: "{{ entry['network'] }}" network_range: "{{ vars[config_namespace]['xcat_networks'][network_name]['network'] }}" network_mask: "{{ vars[config_namespace]['xcat_networks'][network_name]['netmask'] }}" network_cidr: "{{ network_range }}/{{ (network_range + '/' + network_mask) | ansible.utils.ipaddr('prefix') }}" notify: - Export all NFS directories - name: Configure NFS server ansible.builtin.template: src: templates/nfs.conf.j2 dest: /etc/nfs.conf owner: root group: root mode: 0644 trim_blocks: false notify: - Restart NFS server - name: Enable NFS server and start ansible.builtin.service: name: nfs-server state: started enabled: true