diff options
author | Romain Gonçalves <me@rgoncalves.se> | 2021-12-07 20:23:00 +0000 |
---|---|---|
committer | Romain Gonçalves <me@rgoncalves.se> | 2021-12-07 20:24:51 +0000 |
commit | ee9a624949497a4a3944b24e1b3d9c192dd3d444 (patch) | |
tree | bb4cb0bdd284368e8d3ea31f67b926274c3656a6 /roles/nfsd/tasks | |
parent | 9bd2c8c17a22c84da9a6ba6407c5b928d77fb469 (diff) | |
download | rules-ee9a624949497a4a3944b24e1b3d9c192dd3d444.tar.gz |
roles: Add nfsd role for virtual machines
Diffstat (limited to 'roles/nfsd/tasks')
-rw-r--r-- | roles/nfsd/tasks/_freebsd.yml | 20 | ||||
-rw-r--r-- | roles/nfsd/tasks/main.yml | 35 |
2 files changed, 55 insertions, 0 deletions
diff --git a/roles/nfsd/tasks/_freebsd.yml b/roles/nfsd/tasks/_freebsd.yml new file mode 100644 index 0000000..2cae34a --- /dev/null +++ b/roles/nfsd/tasks/_freebsd.yml @@ -0,0 +1,20 @@ + +# nfsd ~~ roles/nfsd/tasks/_freebsd.yml + +--- + +- name: ensure daemons flag + lineinfile: + path: /etc/rc.conf + regexp: "^{{ item[0] }}=" + line: "{{ item[0] }}=\"{{ item[1] }}\"" + loop: + - ["nfs_server_flags", "-tun {{ nfsd_nb_process }}"] + - ["rpcbind_enable=", "YES"] + - ["mountd_flags", "-r"] + +- name: ensure rpcbind is enabled and restarted + service: + name: rpcbind + state: restarted + enabled: true diff --git a/roles/nfsd/tasks/main.yml b/roles/nfsd/tasks/main.yml new file mode 100644 index 0000000..7be5f2a --- /dev/null +++ b/roles/nfsd/tasks/main.yml @@ -0,0 +1,35 @@ +- 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 |