Initial commit
This commit is contained in:
9
roles/common/tasks/main.yml
Executable file
9
roles/common/tasks/main.yml
Executable file
@ -0,0 +1,9 @@
|
||||
---
|
||||
- import_tasks: nfs.yml
|
||||
tags:
|
||||
- nfs
|
||||
|
||||
- import_tasks: nis-install-client.yml
|
||||
# when: "groups['nis_client']|string is search(inventory_hostname)"
|
||||
tags:
|
||||
- nis-install
|
26
roles/common/tasks/nfs.yml
Executable file
26
roles/common/tasks/nfs.yml
Executable file
@ -0,0 +1,26 @@
|
||||
---
|
||||
|
||||
|
||||
- name: (nfs.yml) Ensure NFS utilities (clients) are installed.
|
||||
apt:
|
||||
pkg: nfs-common
|
||||
state: present
|
||||
when:
|
||||
- ansible_os_family == "Debian"
|
||||
tags:
|
||||
- nfs-client
|
||||
|
||||
- name: (nfs.yml) NFS Mount exports from nfs server
|
||||
mount:
|
||||
path: "{{ item.path }}"
|
||||
src: "{{ item.src }}"
|
||||
fstype: nfs
|
||||
opts: "{{ item.mount_opts }}"
|
||||
dump: "{{ item.dump | default(omit) }}"
|
||||
passno: "{{ item.passno | default(omit) }}"
|
||||
state: mounted
|
||||
loop: "{{ nfs_exports }}"
|
||||
loop_control:
|
||||
label: '{{ item.src }}'
|
||||
tags:
|
||||
- nfs-client
|
310
roles/common/tasks/nis-install-client.yml
Executable file
310
roles/common/tasks/nis-install-client.yml
Executable file
@ -0,0 +1,310 @@
|
||||
---
|
||||
|
||||
# ---
|
||||
# Install nis
|
||||
# ---
|
||||
|
||||
- name: (nis-install-client.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-client
|
||||
|
||||
- name: (nis-install-client.yml) Create preconfigured /etc/yp.conf on nis clients
|
||||
template:
|
||||
dest: /etc/yp.conf
|
||||
src: etc/yp.conf.j2
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
tags:
|
||||
- nis-install
|
||||
- nis-install-client
|
||||
|
||||
- name: (nis-install-client.yml) Install nis common packages
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
with_items: "{{ nis_common_packages }}"
|
||||
tags:
|
||||
- nis-install
|
||||
- nis-install-client
|
||||
|
||||
|
||||
# ---
|
||||
# /etc/default/nis
|
||||
# ---
|
||||
|
||||
- name: (nis-install-client.yml) Check if file '/etc/default/nis.ORIG' exists
|
||||
stat:
|
||||
path: /etc/default/nis.ORIG
|
||||
register: default_nis_exists
|
||||
tags:
|
||||
- nis-install
|
||||
- nis-install-client
|
||||
|
||||
- name: (nis-install-client.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-client
|
||||
|
||||
- name: (nis-install-client.yml) Adjust file /etc/default/nis - set 'NISSERVER' (client)
|
||||
replace:
|
||||
path: /etc/default/nis
|
||||
regexp: '^NISSERVER=.*'
|
||||
replace: 'NISSERVER=false'
|
||||
tags:
|
||||
- nis-install
|
||||
- nis-install-client
|
||||
|
||||
- name: (nis-install-client.yml) Adjust file /etc/default/nis - set 'NISCLIENT' (client)
|
||||
replace:
|
||||
path: /etc/default/nis
|
||||
regexp: '^NISCLIENT=.*'
|
||||
replace: 'NISCLIENT=true'
|
||||
tags:
|
||||
- nis-install
|
||||
- nis-install-client
|
||||
|
||||
|
||||
# ---
|
||||
# /etc/{passwd,group,shadow}
|
||||
# ---
|
||||
|
||||
- name: (nis-install-client.yml) Add '+::::::' to file /etc/passwd
|
||||
lineinfile:
|
||||
path: /etc/passwd
|
||||
line: '+::::::'
|
||||
insertafter: EOF
|
||||
state: present
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
when: "ansible_distribution_major_version|int < 18"
|
||||
tags:
|
||||
- nis-install
|
||||
- nis-install-client
|
||||
|
||||
- name: (nis-install-client.yml) Add '+:::' to file /etc/group
|
||||
lineinfile:
|
||||
path: /etc/group
|
||||
line: '+:::'
|
||||
insertafter: EOF
|
||||
state: present
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
when: "ansible_distribution_major_version|int < 18"
|
||||
tags:
|
||||
- nis-install
|
||||
- nis-install-client
|
||||
|
||||
- name: (nis-install-client.yml) Add '+::::::::' to file /etc/shadow
|
||||
lineinfile:
|
||||
path: /etc/shadow
|
||||
line: '+::::::::'
|
||||
insertafter: EOF
|
||||
state: present
|
||||
owner: root
|
||||
group: shadow
|
||||
mode: '0640'
|
||||
when: "ansible_distribution_major_version|int < 18"
|
||||
tags:
|
||||
- nis-install
|
||||
- nis-install-client
|
||||
|
||||
|
||||
# ---
|
||||
# /etc/hosts
|
||||
# ---
|
||||
|
||||
- name: (nis-install-client.yml) Check if file '/etc/hosts.ORIG' exists
|
||||
stat:
|
||||
path: /etc/hosts.ORIG
|
||||
register: etc_hosts_orig_exists
|
||||
tags:
|
||||
- nis-install
|
||||
- nis-install-client
|
||||
|
||||
- name: (nis-install-client.yml) Backup existing file /etc/hosts
|
||||
command: cp -a /etc/hosts /etc/hosts.ORIG
|
||||
when:
|
||||
- etc_hosts_orig_exists.stat.exists == False
|
||||
tags:
|
||||
- nis-install
|
||||
- nis-install-client
|
||||
|
||||
- name: (nis-install-client.yml) Add nis-server to file /etc/hosts
|
||||
lineinfile:
|
||||
path: /etc/hosts
|
||||
line: '{{ nis_server_address }} {{ nis_server_name }} {{ nis_server_name.split(".")[1] }}'
|
||||
insertafter: EOF
|
||||
state: present
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
tags:
|
||||
- nis-install
|
||||
- nis-install-client
|
||||
|
||||
|
||||
# ---
|
||||
# /etc/nsswitch.conf
|
||||
# ---
|
||||
|
||||
#- name: (nis.yml) Check if file '/etc/nsswitch.conf.ORIG' exists
|
||||
# stat:
|
||||
# path: /etc/nsswitch.conf.ORIG
|
||||
# register: nsswitch_conf_orig_exists
|
||||
# tags:
|
||||
# - nis-install
|
||||
# - nis-install-client
|
||||
#
|
||||
#- name: (nis.yml) Backup existing file /etc/nsswitch.conf
|
||||
# command: cp -a /etc/nsswitch.conf /etc/nsswitch.conf.ORIG
|
||||
# when:
|
||||
# - nsswitch_conf_orig_exists.stat.exists == False
|
||||
# tags:
|
||||
# - nis-install
|
||||
# - nis-install-client
|
||||
#
|
||||
#- name: (nis-install-client.yml) Adjust file /etc/nsswitch.conf (set hosts)
|
||||
# replace:
|
||||
# path: /etc/nsswitch.conf
|
||||
# regexp: '(hosts:\s+files)\s+([^nis].*)'
|
||||
# replace: '\1 nis \2'
|
||||
# tags:
|
||||
# - nis-install
|
||||
# - nis-install-client
|
||||
#
|
||||
#- name: (nis-install-client.yml) Adjust file /etc/nsswitch.conf (set passwd/group/shadow)
|
||||
# replace:
|
||||
# path: /etc/nsswitch.conf
|
||||
# regexp: '^({{ item }}:\s+.*(?!nis).*)'
|
||||
# replace: '\1 nis'
|
||||
# with_items:
|
||||
# - passwd
|
||||
# - group
|
||||
# - shadow
|
||||
# tags:
|
||||
# - nis-install
|
||||
# - nis-install-client
|
||||
- name: Copy /etc/nsswitch.conf
|
||||
copy:
|
||||
src: etc/nsswitch.conf
|
||||
dest: /etc/nsswitch.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
|
||||
# ---
|
||||
# /etc/systemd/system/systemd-logind.service.d/nis_allow_network.conf
|
||||
# ---
|
||||
|
||||
# - !! Using NIS client in Ubuntu 18.04 crashes both Gnome and Unity !!
|
||||
# - ===================================================================
|
||||
#
|
||||
# - Unter NIS in Ubuntu 18.04 stütrzt Gnome und Unity ab
|
||||
# -
|
||||
# - Abhilfe schafft:
|
||||
# -
|
||||
#
|
||||
# - Create a new directory in /etc/systemd/system/ named exactly after the
|
||||
# - service you want to extend including a '.d', here this would be:
|
||||
# - systemd-logind.service.d
|
||||
# -
|
||||
# - mkdir /etc/systemd/system/systemd-logind.service.d
|
||||
#
|
||||
# - Create a new file choose_an_appropriate_name.conf (e.g. nis_allow_network.conf)
|
||||
# - inside the newly created directory with the following content, which specifies
|
||||
# - the IP or IP range you want to be allowed:
|
||||
# -
|
||||
# - cat <<EOF > /etc/systemd/system/systemd-logind.service.d/nis_allow_network.conf
|
||||
# - [Service]
|
||||
# - IPAddressAllow=192.168.0.0/16
|
||||
# - EOF
|
||||
# -
|
||||
# - systemctl daemon-reload
|
||||
# - systemctl restart systemd-logind.service
|
||||
|
||||
- name: (nis-install-client.yml) Ensure directory /etc/systemd/system/systemd-logind.service.d exists
|
||||
file:
|
||||
path: /etc/systemd/system/systemd-logind.service.d
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
state: directory
|
||||
when: "ansible_distribution_major_version|int >= 18"
|
||||
tags:
|
||||
- nis-install
|
||||
- nis-install-client
|
||||
|
||||
- name: (nis-install-client.yml) Ensure file /files/etc/systemd/system/systemd-logind.service.d/nis_allow_network.conf exists
|
||||
copy:
|
||||
src: "{{ role_path + '/files/etc/systemd/system/systemd-logind.service.d/nis_allow_network.conf' }}"
|
||||
dest: /etc/systemd/system/systemd-logind.service.d/nis_allow_network.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
when: "ansible_distribution_major_version|int >= 18"
|
||||
# XXX: killt meine Xsession (Tim)
|
||||
# notify:
|
||||
# - Restart systemd-logind.service
|
||||
tags:
|
||||
- nis-install
|
||||
- nis-install-client
|
||||
|
||||
|
||||
# - Seit Ubuntu 16.04 startet nis vor dem portmapper (rpcbind). Das Starten
|
||||
# - schlägt deshalb fehl und nis steht nicht zur Verfügung.
|
||||
# -
|
||||
# - Abhilfe:
|
||||
# -
|
||||
# - Run "systemctl edit rpcbind.socket" and add the following:
|
||||
# -
|
||||
# - [Unit]
|
||||
# - DefaultDependencies=no
|
||||
# - Wants=rpcbind.target
|
||||
# - Before=rpcbind.target
|
||||
# -
|
||||
# - You can see your changes:
|
||||
# - cat /etc/systemd/system/rpcbind.socket.d/override.conf
|
||||
|
||||
- name: (nis-install-client.yml) Ensure directory /etc/systemd/system/rpcbind.socket.d exists
|
||||
file:
|
||||
path: /etc/systemd/system/rpcbind.socket.d
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
state: directory
|
||||
when: "ansible_distribution_major_version|int >= 16"
|
||||
tags:
|
||||
- nis-install
|
||||
- nis-install-client
|
||||
|
||||
- name: (nis-install-client.yml) Ensure file /files/etc/systemd/system/rpcbind.socket.d/override.conf exists
|
||||
copy:
|
||||
src: "{{ role_path + '/files/etc/systemd/system/rpcbind.socket.d/override.conf' }}"
|
||||
dest: /etc/systemd/system/rpcbind.socket.d/override.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
when: "ansible_distribution_major_version|int >= 16"
|
||||
notify:
|
||||
- Restart rpcbind
|
||||
tags:
|
||||
- nis-install
|
||||
- nis-install-client
|
||||
|
||||
|
||||
# TODO:
|
||||
# /etc/systemd/system/systemd-logind.service.d/nis_allow_network.conf
|
||||
# /etc/systemd/system/rpcbind.socket.d/override.conf
|
Reference in New Issue
Block a user