diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9dc64a6 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,23 @@ +# EditorConfig is awesome: http://EditorConfig.org + +root = true + +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[Makefile] +indent_style = tab + +[**.php] +indent_style = space +indent_size = 4 + +[**.{js,coffee,html,less,css,json}] +indent_style = space +indent_size = 2 + +[**.md] +trim_trailing_whitespace = false diff --git a/libreschool-nfs.spec b/libreschool-nfs.spec index ea31e00..791138c 100644 --- a/libreschool-nfs.spec +++ b/libreschool-nfs.spec @@ -1,7 +1,7 @@ Summary: LibreSchool NFS home profiles configuration Name: libreschool-nfs -Version: 6.9 -Release: 1 +Version: 1.0 +Release: 1.ns7 License: GPL BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-root @@ -9,9 +9,14 @@ Source0: %{name}-%{version}.tar.gz Source1: COPYING URL: %{url_prefix}/%{name} Requires: libreschool-release -Requires: nethserver-directory +Requires: libreschool-client-manager +Requires: nethserver-directory oppure nfs quell'altro Requires: nfs-utils +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd BuildRequires: nethserver-devtools +BuildRequires: systemd %description LibreSchool NFS home profiles configuration @@ -43,8 +48,9 @@ chkconfig rpcbind on UDPPort 111 \ access private /sbin/e-smith/expand-template /etc/exports -/sbin/service nfs start >/dev/null 2>&1 || : -/sbin/service rpcbind start >/dev/null 2>&1 || : +/sbin/e-smith/expand-template /etc/ansible/reconfigure_clients.yml +/usr/bin/systemctl --no-block start nfs >/dev/null 2>&1 || : +/usr/bin/systemctl --no-block start rpmbind >/dev/null 2>&1 || : /usr/sbin/exportfs -r /sbin/e-smith/signal-event firewall-adjust /usr/bin/ldapmodify -Y EXTERNAL -f /usr/share/libreschool-nfs/patch.ldif >/dev/null 2>&1 || : @@ -55,10 +61,11 @@ chkconfig rpcbind on #fi if [ "$1" = 0 ]; then #uninstallation - /sbin/e-smith/expand-template /etc/exports + echo > /etc/exports + /sbin/e-smith/expand-template /etc/ansible/reconfigure_clients.yml /usr/sbin/exportfs -r fi %changelog -* Sat Nov 4 2017 Paolo Asperti - 6.9-1 -- First release +* Sun Apr 28 2019 Paolo Asperti - 1.0-1.ns7 +- First release for NethServer 7 diff --git a/root/etc/ansible/roles/nfs-client/handlers/main.yml b/root/etc/ansible/roles/nfs-client/handlers/main.yml new file mode 100644 index 0000000..bc9b3d9 --- /dev/null +++ b/root/etc/ansible/roles/nfs-client/handlers/main.yml @@ -0,0 +1,3 @@ +--- +- name: restart libnss-ldap + service: name=libnss-ldap state=restarted diff --git a/root/etc/ansible/roles/nfs-client/tasks/main.yml b/root/etc/ansible/roles/nfs-client/tasks/main.yml new file mode 100644 index 0000000..8fe5837 --- /dev/null +++ b/root/etc/ansible/roles/nfs-client/tasks/main.yml @@ -0,0 +1,154 @@ +--- + +- name: Installing nfs client packages + apt: + name: [ 'nfs-common' ] + state: latest + +- name: Create directory for user homes + file: path=/var/lib/nethserver/home state=directory owner=root group=root mode=0755 + +- name: Add mount to fstab + mount: + path: /var/lib/nethserver/home + src: "{{ esmith.SystemName }}.{{ esmith.DomainName }}:/var/lib/nethserver/home" + fstype: nfs4 + opts: rw,async,_netdev + passno: 1 + dump: 0 + state: mounted + +- name: Check if lightdm is installed + shell: dpkg-query -W -f='${Status}' lightdm | grep 'install ok installed' + register: lightdm_installed + failed_when: no + changed_when: no + +- name: Check if gdm3 is installed + shell: dpkg-query -W -f='${Status}' gdm3 | grep 'install ok installed' + register: gdm3_installed + failed_when: no + changed_when: no + +- name: Adjusting lightdm settings + template: + src: 'lightdm.conf' + dest: '/usr/share/lightdm/lightdm.conf.d/50-libreschool.conf' + owner: 'root' + group: 'root' + mode: 0644 + when: lightdm_installed.rc == 0 + +- name: Adjust gdm3 settings + ini_file: + path: /etc/gdm3/greeter.dconf-defaults + section: org/gnome/login-screen + option: disable-user-list + value: "true" + no_extra_spaces: yes + when: gdm3_installed.rc == 0 + +- name: Set bind DN + debconf: + name: ldap-auth-config + question: ldap-auth-config/binddn + value: cn=ldapservice,dc=directory,dc=nh + vtype: string + +- name: Set root bind DN + debconf: + name: ldap-auth-config + question: ldap-auth-config/rootbinddn + value: cn=ldapservice,dc=directory,dc=nh + vtype: string + +- name: Set base DN + debconf: + name: ldap-auth-config + question: ldap-auth-config/ldapns/base-dn + value: dc=directory,dc=nh + vtype: string + +- name: Set login required + debconf: + name: ldap-auth-config + question: ldap-auth-config/dblogin + value: true + vtype: boolean + +- name: Set root login required + debconf: + name: ldap-auth-config + question: ldap-auth-config/dbrootlogin + value: true + vtype: boolean + +- name: Set ldap override + debconf: + name: ldap-auth-config + question: ldap-auth-config/override + value: true + vtype: boolean + +- name: Set move-to-debconf + debconf: + name: ldap-auth-config + question: ldap-auth-config/move-to-debconf + value: true + vtype: boolean + + + + +- name: Set pam password + debconf: + name: ldap-auth-config + question: ldap-auth-config/pam_password + value: md5 + vtype: select + + + + +# TODO: use ansible variables +- name: Set LDAP server + debconf: + name: ldap-auth-config + question: ldap-auth-config/ldapns/ldap-server + value: ldap://pdc.test.domain:389/ + vtype: string + +- name: Set LDAP server version + debconf: + name: ldap-auth-config + question: ldap-auth-config/ldapns/ldap_version + value: 3 + vtype: select + +- name: Set bind password + debconf: + name: ldap-auth-config + question: ldap-auth-config/bindpw + value: {{ lookup('file', '/var/lib/nethserver/secrets/ldapservice') }} + vtype: password + +- name: Set root bind password + debconf: + name: ldap-auth-config + question: ldap-auth-config/rootbindpw + value: {{ lookup('file', '/var/lib/nethserver/secrets/ldapservice') }} + vtype: password + +# - name: ldap configuration +# template: +# src: 'ldap.secret' +# dest: '/etc/ldap.secret' +# owner: 'root' +# group: 'root' +# mode: 0600 + + +- name: Installing client packages + apt: + name: [ 'ldap-auth-config' ] + state: latest diff --git a/root/etc/ansible/roles/nfs-client/templates/ldap.conf b/root/etc/ansible/roles/nfs-client/templates/ldap.conf new file mode 100644 index 0000000..4cbe7b5 --- /dev/null +++ b/root/etc/ansible/roles/nfs-client/templates/ldap.conf @@ -0,0 +1,9 @@ +base dc=directory,dc=nh +uri ldap://{{ esmith.SystemName }}.{{ esmith.DomainName }}:389/ +ldap_version 3 +binddn cn=libuser,dc=directory,dc=nh +bindpw {{ lookup('file', '/var/lib/nethserver/secrets/libuser') }} +rootbinddn cn=libuser,dc=directory,dc=nh +pam_password md5 +#ssl start_tls +nss_initgroups_ignoreusers avahi,avahi-autoipd,backup,bin,colord,daemon,dnsmasq,games,gnats,hplip,irc,kernoops,libuuid,lightdm,list,lp,mail,man,messagebus,news,proxy,pulse,root,rtkit,saned,speech-dispatcher,sshd,statd,sync,sys,syslog,usbmux,uucp,whoopsie,www-data diff --git a/root/etc/ansible/roles/nfs-client/templates/ldap.secret b/root/etc/ansible/roles/nfs-client/templates/ldap.secret new file mode 100644 index 0000000..7f50030 --- /dev/null +++ b/root/etc/ansible/roles/nfs-client/templates/ldap.secret @@ -0,0 +1 @@ +{{ lookup('file', '/var/lib/nethserver/secrets/ldapservice') }} diff --git a/root/etc/ansible/roles/nfs-client/templates/lightdm.conf b/root/etc/ansible/roles/nfs-client/templates/lightdm.conf new file mode 100644 index 0000000..2132505 --- /dev/null +++ b/root/etc/ansible/roles/nfs-client/templates/lightdm.conf @@ -0,0 +1,4 @@ +[Seat:*] +allow-guest=false +greeter-hide-users=true +greeter-show-manual-login=true diff --git a/root/etc/e-smith/templates/etc/ansible/reconfigure_clients.yml/50_nfs-client b/root/etc/e-smith/templates/etc/ansible/reconfigure_clients.yml/50_nfs-client new file mode 100644 index 0000000..6736073 --- /dev/null +++ b/root/etc/e-smith/templates/etc/ansible/reconfigure_clients.yml/50_nfs-client @@ -0,0 +1 @@ + - nfs-client diff --git a/root/etc/e-smith/templates/etc/exports/50libreschool-nfs b/root/etc/e-smith/templates/etc/exports/50libreschool-nfs index bc5662a..0e2b296 100644 --- a/root/etc/e-smith/templates/etc/exports/50libreschool-nfs +++ b/root/etc/e-smith/templates/etc/exports/50libreschool-nfs @@ -1,12 +1,10 @@ # # 50libreschool-nfs # -{ - use esmith::InterfacesDB; - my $ndb = esmith::InterfacesDB->open_ro() || return; +{ + use esmith::NetworksDB; + my $ndb = esmith::NetworksDB->open_ro() || return; my $LocalIP = $ndb->green()->prop('ipaddr') || return; my $LocalNM = $ndb->green()->prop('netmask') || return; - sprintf "/var/lib/nethserver/home\t%s/%s(rw,no_root_squash,sync,no_subtree_check)\n", $LocalIP, $LocalNM; + sprintf "/var/lib/nethserver/home\t%s/%s(rw,no_root_squash,sync,no_subtree_check)\n", $LocalIP, $LocalNM; } - -