From a16721e01096ec31064057abd9e6ce23266a8267 Mon Sep 17 00:00:00 2001 From: CVL-GitHub <jupiter.hu@monash.edu> Date: Thu, 15 Jan 2015 01:33:31 +0000 Subject: [PATCH] restore export template --- playbook/cvl2.yml | 8 +++++--- roles/installPackage/tasks/main.yml | 4 ++-- roles/syncExports/tasks/addExports.yml | 5 +++-- scripts/makeexports.py | 27 -------------------------- 4 files changed, 10 insertions(+), 34 deletions(-) delete mode 100755 scripts/makeexports.py diff --git a/playbook/cvl2.yml b/playbook/cvl2.yml index 20d1bb2..90654e5 100644 --- a/playbook/cvl2.yml +++ b/playbook/cvl2.yml @@ -31,7 +31,7 @@ - { role: slurm-build } - { role: nfs-server, configDiskDevice: false } - { role: slurm, slurm_use_vpn: true} - - { role: installPackage, cliAction: "{'command': 'cp -r /usr/local/Modules/modulefiles/cvl /usr/local/Modules/modulefiles/massive', 'check': '/usr/local/Modules/modulefiles/massive' }" + - { role: installPackage, cliCopy: {'run': 'cp -r /usr/local/Modules/modulefiles/cvl /usr/local/Modules/modulefiles/massive', 'check': '/usr/local/Modules/modulefiles/massive'} } tasks: setup: @@ -53,11 +53,13 @@ slurmqueues: - {name: batch, group: ComputeNodes, default: true} nfs_server: "{{ groups['OpenvpnServer'][0] }}" + groupList: + - { name : 'ComputeNodes', interface : 'tun0' } roles: - { role: OpenVPN-Client, x509_ca_server: "cvl23server" } - { role: ntp } - { role: openLdapClient } - - { role: syncExports, nfs_server: "cvl23server", nfsExportFile: "/etc/exports", nfsClientIp: "{{ ansible_tun0.ipv4.address }}", nfsServerOption: "ro,fsid=0,sync" } + - { role: syncExports, nfs_server: "cvl23server", exportList: [{ name: '/', src: '/usr/local', fstype: 'nfs4', opts: 'defaults,ro,nofail', nfsServerIp: "{{ hostvars['cvl23server']['ansible_tun0']['ipv4']['address'] }}", srvopts: 'ro,fsid=0,sync' }] } - { role: nfs-client, exportList: "[{ 'name': '/home', 'src': '/', 'fstype': 'nfs4', 'opts': 'defaults,nofail', 'nfsServerIp': '{{ nfsServerIpAddress }}', 'nfsClientIp': '{{ ansible_tun0.ipv4.address }}', 'srvopts': 'rw,root_squash,fsid=0,sync' }]" } - { role: nfs-client, exportList: "[ { 'name': '/usr/local', 'src': '/', 'fstype': 'nfs4', 'opts': 'defaults,ro,nofail', 'nfsServerIp': '{{ hostvars[nfs_server]['ansible_tun0']['ipv4']['address'] }}', 'srvopts': 'ro,fsid=0,sync' }]" } - { role: slurm, slurm_use_vpn: true} @@ -88,5 +90,5 @@ - { role: openLdapClient } - { role: nfs-client, exportList: "[{ 'name': '/home', 'src': '/', 'fstype': 'nfs4', 'opts': 'defaults,nofail', 'nfsServerIp': '{{ nfsServerIpAddress }}', 'nfsClientIp': '{{ ansible_tun0.ipv4.address }}', 'srvopts': 'rw,root_squash,fsid=0,sync' }]" } - { role: slurm, slurm_use_vpn: true} - - { role: installPackage, importRepo: { command: "wget http://cvlrepo.massive.org.au/repo/cvl.repo -O", destination: "/etc/yum.repos.d/cvl.repo" }, yumGroupPackageList: ['CVL Pre-installation', 'CVL Base Packages', 'CVL System', 'CVL System Extension'], cliAction: {'run': 'cp -r /usr/local/Modules/modulefiles/cvl /usr/local/Modules/modulefiles/massive', 'check': '/usr/local/Modules/modulefiles/massive'} } + - { role: installPackage, importRepo: { command: "wget http://cvlrepo.massive.org.au/repo/cvl.repo -O", destination: "/etc/yum.repos.d/cvl.repo" }, yumGroupPackageList: ['CVL Pre-installation', 'CVL Base Packages', 'CVL System', 'CVL System Extension'], cliCopy: {'run': 'cp -r /usr/local/Modules/modulefiles/cvl /usr/local/Modules/modulefiles/massive', 'check': '/usr/local/Modules/modulefiles/massive'} } diff --git a/roles/installPackage/tasks/main.yml b/roles/installPackage/tasks/main.yml index c9baab4..b3d91bd 100644 --- a/roles/installPackage/tasks/main.yml +++ b/roles/installPackage/tasks/main.yml @@ -30,11 +30,11 @@ when: ansible_distribution == 'CentOS' and postInstallation is defined - name: conditional shell copy command - shell: "{{ cliAction.run }}" + shell: "{{ cliCopy.run }}" sudo: true run_once: true args: - creates: "{{ cliAction.check }}" + creates: "{{ cliCopy.check }}" when: ansible_distribution == 'CentOS' and cliAction is defined diff --git a/roles/syncExports/tasks/addExports.yml b/roles/syncExports/tasks/addExports.yml index c35aa9f..d3723e7 100644 --- a/roles/syncExports/tasks/addExports.yml +++ b/roles/syncExports/tasks/addExports.yml @@ -1,6 +1,7 @@ --- -- name: "Add hosts to /etc/exports" - script: ./scripts/makeexports.py "{{ nfsExportFile }}" "{{ nfsClientIp }}" "{{ nfsServerOption }}" "/usr/local" +- 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 notify: "Reload exports" diff --git a/scripts/makeexports.py b/scripts/makeexports.py deleted file mode 100755 index bbc131b..0000000 --- a/scripts/makeexports.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/python - -import sys, os - -def config(source, host, option, input = None): - content = None - if input: - if not host in input: - content = input + " " + host + "(" + option + ")" - else: - content = source + " " + host + "(" + option + ")" - return content - -path = sys.argv[1] -host = sys.argv[2] -option = sys.argv[3] -source = sys.argv[4] - -io = open(path, 'r') -input = io.read() -io.close() -content = config(source, host, option, input) -if content: - io = open(path, 'w') - io.write(content) - io.close() - -- GitLab