summaryrefslogtreecommitdiffstats
path: root/xci/playbooks/roles/configure-nfs/tasks/main.yml
diff options
context:
space:
mode:
Diffstat (limited to 'xci/playbooks/roles/configure-nfs/tasks/main.yml')
-rw-r--r--xci/playbooks/roles/configure-nfs/tasks/main.yml74
1 files changed, 40 insertions, 34 deletions
diff --git a/xci/playbooks/roles/configure-nfs/tasks/main.yml b/xci/playbooks/roles/configure-nfs/tasks/main.yml
index c52da0bf..51a2d43a 100644
--- a/xci/playbooks/roles/configure-nfs/tasks/main.yml
+++ b/xci/playbooks/roles/configure-nfs/tasks/main.yml
@@ -7,37 +7,43 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-# TODO: this is for xenial and needs to be adjusted for different distros
-- block:
- - 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: "{{ item }}"
- with_items:
- - "nfs 2049/tcp"
- - "nfs 2049/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)"
- # TODO: the service name might be different on other distros and needs to be adjusted
- - name: restart ubuntu xenial NFS service
- service:
- name: nfs-kernel-server
- state: restarted
- when: ansible_distribution_release == "xenial"
+
+- 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: restart ubuntu xenial NFS service
+ service:
+ name: "{{ nfs_server_service }}"
+ state: restarted