aboutsummaryrefslogtreecommitdiffstats
path: root/roles/nfsclient/tasks/main.yml
blob: 0c1f75ee6b3ec1f46fd109f3f7f76985ae3ae1cf (plain) (blame)
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
- name: translate server string to server dict
  set_fact:
    nfsclient_server_ip: "{{ hostvars[nfsclient_server].__ip.external }}"
  when: not nfsclient_server_ip

- name: include distribution specific prerequisites
  include_tasks: "os_{{ ansible_distribution | lower }}.yml"
  ignore_errors: true

- name: create directory on client
  file:
    path: "{{ nfsclient_dir }}"
    owner: 0
    group: 0
    mode: 0755
    state: directory

- name: cleanup fstab with previous nfs setup
  lineinfile:
    path: "{{ nfsclient_fstab_path }}"
    regexp: ^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:/.* {{ nfsclient_dir }} nfs
    state: absent
  register: result

- name: complete fstab with nfs
  lineinfile:
    path: "{{ nfsclient_fstab_path }}"
    line: "{{ nfsclient_server_ip }}:{{ nfsclient_server_dir }}/{{ inventory_hostname }} {{ nfsclient_dir }} nfs rw,nodev,nosuid 0 0"
  notify: reload fstab
remember that computers suck.