diff --git a/roles/nfs-client/tasks/main.yml b/roles/nfs-client/tasks/main.yml index 799e9da45e6d31d25825c14cdee90641bb0bdd54..b08ac76f7fb9f047f97ce6cfe609e8d4d7b46c5a 100644 --- a/roles/nfs-client/tasks/main.yml +++ b/roles/nfs-client/tasks/main.yml @@ -5,7 +5,13 @@ with_items: - libnfsidmap - nfs-utils - - nfs-utils-lib when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "7" +- name: install dependencies + yum: name={{ item }} state=installed + sudo: true + with_items: + - nfs-utils-lib + when: ansible_os_family == "RedHat" and ansible_distribution_major_version < "7" + - include: mountFileSystem.yml diff --git a/roles/nfs-client/tasks/mountFileSystem.yml b/roles/nfs-client/tasks/mountFileSystem.yml index 1e5c7e99c52baa0e02405e22c1510bfc05f08eac..76506d50b7aca86aade2223e878aa49dde71c8f3 100644 --- a/roles/nfs-client/tasks/mountFileSystem.yml +++ b/roles/nfs-client/tasks/mountFileSystem.yml @@ -10,7 +10,7 @@ when: nfsMounts is defined - name: "Mounting NFS mounts" - mount: name={{ item.name }} src="{{ item.ipv4 }}:{{ item.src }} " fstype={{ item.fstype }} opts={{ item.opts }} state=mounted + mount: name={{ item.name }} src="{{ item.ipv4 }}:{{ item.src }}" fstype={{ item.fstype }} opts={{ item.opts }} state=mounted with_items: "{{ nfsMounts }}" notify: "restart rpcbind" notify: "restart idmap" @@ -25,7 +25,7 @@ when: firstMount | failed - name: "Mounting NFS mounts after failure" - mount: name={{ item.name }} src=" {{ item.ipv4 }}:{{ item.src }} " fstype={{ item.fstype }} opts={{ item.opts }} state=mounted + mount: name={{ item.name }} src="{{ item.ipv4 }}:{{ item.src }}" fstype={{ item.fstype }} opts={{ item.opts }} state=mounted with_items: "{{ nfsMounts }}" notify: "restart idmap" notify: "restart rpcbind" diff --git a/roles/nfs-server/tasks/startServer.yml b/roles/nfs-server/tasks/startServer.yml index 9e836f317895c4dccdbb7ac12b4aa7b875e5c033..ed33daf0f037fadfe5bc421bd1f6cf0a5c1ff598 100644 --- a/roles/nfs-server/tasks/startServer.yml +++ b/roles/nfs-server/tasks/startServer.yml @@ -3,6 +3,7 @@ file: dest={{ item.src }} state=directory mode=755 owner=root group=root sudo: true with_items: "{{ exportList }}" + ignore_errors: true - name: "Starting rpcbind" service: "name=rpcbind state=started enabled=true" @@ -10,10 +11,19 @@ when: ansible_os_family == "RedHat" - name: "Start the Server" - service: "name=nfs state=started enabled=true" + service: "name=nfs state=started" sudo: true when: ansible_os_family == "RedHat" +- name: "Enable the Server at boot" + service: "name=nfs enabled=true" + sudo: true + when: ansible_os_family == "RedHat" and ansible_distribution_major_version < "7" +- name: "Enable the Server at boot" + service: "name=nfs-server.service enabled=true" + sudo: true + when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "7" + - name: "Start the Server" service: "name=nfs-kernel-server state=started enabled=true" sudo: true