- name: create nfsd data directory file: path: "{{ nfsd_data_dir }}" owner: 0 group: 0 mode: 0700 state: directory - name: create hosts directories file: path: "{{ nfsd_data_dir }}/{{ item }}" owner: 0 group: 0 mode: 0777 state: directory loop: "{{ nfsd_shared_dirs }}" - name: generate nfsd configuration template: src: exports.j2 dest: /etc/exports owner: root mode: 0640 register: result - name: enable and start nfsd service service: &nfsd_service name: nfsd state: "{{ 'restarted' if result.changed else 'started' }}" enabled: true - name: enable and restart mountd service: <<: *nfsd_service name: mountd