Skip to content
Snippets Groups Projects
Commit 46a18edc authored by Chris Hines's avatar Chris Hines
Browse files

separate the exportList used on the server from the mount list used on the clients

parent 5f5e7b43
No related branches found
No related tags found
No related merge requests found
......@@ -4,16 +4,18 @@
sudo: true
- name: "Mounting NFS mounts"
mount: name={{ item.name }} src={{ item.ipv4 }}:{{ item.src }} fstype={{ item.fstype }} opts={{ item.opts }} state=mounted
with_items: exportList
mount: name={{ item.mntpt }} src={{ item.src }} fstype={{ item.fstype }} opts={{ item.opts }} state=mounted
with_items: nfsMounts
notify: "restart authentication"
notify: "restart rpcbind"
notify: "restart idmap"
sudo: true
ignore_errors: true
register: firstMount
when: exportList is defined
when: nfsMounts is defined
- name: "Wait for nfs to stabailse"
command: sleep 60
......@@ -21,13 +23,13 @@
when: firstMount | failed
- name: "Mounting NFS mounts"
mount: name={{ item.name }} src={{ item.ipv4 }}:{{ item.src }} fstype={{ item.fstype }} opts={{ item.opts }} state=mounted
with_items: exportList
mount: name={{ item.name }} src=" {{ item.ipv4 }}:{{ item.src }} " fstype={{ item.fstype }} opts={{ item.opts }} state=mounted
with_items: nfsMounts
notify: "restart authentication"
notify: "restart idmap"
notify: "restart rpcbind"
sudo: true
when: exportList is defined and firstMount | failed
when: nfsMounts is defined and firstMount | failed
- name: "restart fail2ban"
service: name=fail2ban state=started
......
......@@ -2,26 +2,18 @@
- name: "Create exports if necessary"
file: dest={{ item.src }} state=directory mode=755 owner=root group=root
sudo: true
delegate_to: "{{ nfs_server }}"
run_once: true
with_items: exportList
- name: "Templating /etc/exports"
template: src=exports.j2 dest=/etc/exports owner=root group=root mode=644
delegate_to: "{{ nfs_server }}"
run_once: true
sudo: true
# Do not do this as a handler, instead do this here as a task so that it happens imediatly after the exports file is created before any clients
# attempt a mount
- name : "Reload exports"
command: exportfs -ra
delegate_to: "{{ nfs_server }}"
run_once: true
sudo: true
- name : "Pause ... clients sometimes have errors"
command: sleep 60
delegate_to: "{{ nfs_server }}"
run_once: true
sudo: true
{% set iplist = [] %}
{% for export in exportList %}
{% for group in groupList %}
{% for node in groups[group.name] %}
{% if hostvars[node]['ansible_'+group.interface] is defined %}
{% if iplist.append(hostvars[node]['ansible_'+group.interface]['ipv4']['address']) %}
{% for node in groups[export.group] %}
{% if hostvars[node]['ansible_'+export.interface] is defined %}
{% if iplist.append(hostvars[node]['ansible_'+export.interface]['ipv4']['address']) %}
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
{{ export.src }} {% for ip in iplist|unique %}{{ ip }}({{ export.srvopts }}) {% endfor %}
{% endfor %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment