summaryrefslogtreecommitdiffstats
path: root/xci/playbooks/roles/configure-nfs/tasks/main.yml
blob: 25e8149659b10b05f5c3bf89e7924c3944cd8ee1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
---
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2017 Ericsson AB and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

- name: Gather variables for each operating system
  include_vars: "{{ item }}"
  with_first_found:
    - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml"
    - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
    - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
    - "{{ ansible_distribution | lower }}.yml"
    - "{{ ansible_os_family | lower }}.yml"
- name: make NFS directories
  file:
    dest: "{{ item }}"
    mode: 0777
    state: directory
  with_items:
    - "/images"
    - "/volumes"
- name: configure NFS service
  lineinfile:
    dest: /etc/services
    state: present
    create: yes
    line: "nfs    2049/{{ item }}"
    regexp: "^[[:space:]]*nfs[[:space:]]*2049/{{ item }}"
  with_items:
    - "tcp"
    - "udp"
- name: configure NFS exports
  lineinfile:
    dest: /etc/exports
    state: present
    create: yes
    line: "{{ item }}"
  with_items:
    - "/images         *(rw,sync,no_subtree_check,no_root_squash)"
    - "/volumes        *(rw,sync,no_subtree_check,no_root_squash)"

- name: Install the NFS server package
  package:
    name: "{{ nfs_server_package }}"
    state: latest

- name: restart NFS service
  service:
    name: "{{ nfs_server_service }}"
    state: restarted