--- # --- # Install nis # --- - name: (nis-install-server.yml) Set (nis) default domain (/etc/defaultdomain) template: dest: /etc/defaultdomain src: etc/defaultdomain.j2 owner: root group: root mode: 0644 tags: - nis-install - nis-install-server - name: (nis-install-server.yml) Install nis common packages package: name: "{{ item }}" state: present with_items: "{{ nis_common_packages }}" register: nis_installed tags: - nis-install - nis-install-server # --- # /etc/default/nis # --- - name: (nis-install-server.yml) Check if file '/etc/default/nis.ORIG' exists stat: path: /etc/default/nis.ORIG register: default_nis_exists tags: - nis-install - nis-install-server - name: (nis-install-server.yml) Backup existing file /etc/default/nis command: cp -a /etc/default/nis /etc/default/nis.ORIG when: - default_nis_exists.stat.exists == False tags: - nis-install - nis-install-server - name: (nis-install-server.yml) Adjust file /etc/default/nis - set 'NISSERVER' (server) replace: path: /etc/default/nis regexp: '^NISSERVER=.*' replace: 'NISSERVER=master' tags: - nis-install - nis-install-server - name: (nis-install-server.yml) Adjust file /etc/default/nis - set 'NISCLIENT' (server) replace: path: /etc/default/nis regexp: '^NISCLIENT=.*' replace: 'NISCLIENT=false' tags: - nis-install - nis-install-server # --- # /etc/ypserv.securenets # --- - name: (nis-install-server.yml) Check if file '/etc/ypserv.securenets.ORIG' exists stat: path: /etc/ypserv.securenets.ORIG register: ypserv_securenets_orig_exists tags: - nis-install - nis-install-server - name: (nis-install-server.yml) Backup existing file /etc/ypserv.securenets command: cp -a /etc/ypserv.securenets /etc/ypserv.securenets.ORIG when: - ypserv_securenets_orig_exists.stat.exists == False tags: - nis-install - nis-install-server - name: (nis-install-client.yml) Comment line like '0.0.0.0 ..' to file /etc/ypserv.securenets replace: path: /etc/ypserv.securenets regexp: '^(0.0.0.0\s+.*)' replace: '#\1' tags: - nis-install - nis-install-client - name: (nis-install-server.yml) Add '255.255.0.0 192.168.0.0' to file /etc/ypserv.securenets lineinfile: path: /etc/ypserv.securenets line: '255.255.0.0 192.168.0.0' insertafter: EOF state: present owner: root group: root mode: '0644' tags: - nis-install - nis-install-client - name: (nis-install-server.yml) Add '255.0.0.0 10.0.0.0' to file /etc/ypserv.securenets lineinfile: path: /etc/ypserv.securenets line: '255.0.0.0 10.0.0.0' insertafter: EOF state: present owner: root group: root mode: '0644' tags: - nis-install - nis-install-server - name: (nis-install-server.yml) Trigger '/usr/lib/yp/ypinit -m' shell: printf '\n' | /usr/lib/yp/ypinit -m when: nis_installed.changed tags: - nis-install - nis-install-server # --- # Base directory containing users' home directory # --- - name: (nis-install-server.yml) Ensure directoriy 'nis_base_home' (usually /data/home) exists file: path: '{{ nis_base_home}}' owner: root group: root mode: '0755' state: directory when: - "groups['nfs_server']|string is search(inventory_hostname)" tags: - nis-install - nis-install-server # --- # /etc/adduser.conf # --- - name: (nis-install-server.yml) Check if file '/etc/adduser.conf.ORIG exists' stat: path: /etc/adduser.conf.ORIG register: adduser_conf_exists tags: - nis-install - nis-install-server - name: (nis-install-server.yml) Backup existing file /etc/adduser.conf command: cp -a /etc/adduser.conf /etc/adduser.conf.ORIG when: - adduser_conf_exists.stat.exists == False tags: - nis-install - nis-install-server - name: (nis-install-server.yml) Adjust file '/etc/adduser.conf' - set 'DHOME' replace: path: /etc/adduser.conf regexp: '^#?DHOME=.*' replace: 'DHOME={{ nis_base_home }}' tags: - nis-install - nis-install-server # --- # /var/yp/Makefile # --- - name: (nis-install-server.yml) Check if file '/var/yp/Makefile.ORIG exists' stat: path: /var/yp/Makefile.ORIG register: adduser_conf_exists tags: - nis-install - nis-install-server - name: (nis-install-server.yml) Backup existing file /var/yp/Makefile command: cp -a /var/yp/Makefile /var/yp/Makefile.ORIG when: - adduser_conf_exists.stat.exists == False tags: - nis-install - nis-install-server - name: (nis-install-server.yml) Adjust file '/var/yp/Makefile' replace: path: /var/yp/Makefile regexp: '^#?{{ item }}=.*' replace: '{{ item }}=true' with_items: - MERGE_PASSWD - MERGE_GROUP notify: - Renew nis databases tags: - nis-install - nis-install-server # TODO: # /var/yp/Makefile