NTP client/server, prepare slapd
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
parent
7f39ea724a
commit
1115f7d0a8
3
group_vars/all/ntp.yml
Normal file
3
group_vars/all/ntp.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
glob_ntp_client:
|
||||||
|
servers:
|
||||||
|
- ntp.crans.org
|
7
group_vars/slapd.yml
Normal file
7
group_vars/slapd.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
glob_slapd:
|
||||||
|
master_ip: "{{ query('ldap', 'ip', 'tealc', 'adm') | ipv4 | first }}"
|
||||||
|
regex: "^(role:(dhcp|dns|dns-primary|dns-secondary|ftp|gitlab|miroir|ntp|pve|radius|backup)|ecdsa-sha2-nistp256:.*|ssh-(ed25519|dss|rsa):.*)$"
|
||||||
|
replication_credentials: "{{ vault.ldap_replication_credentials }}"
|
||||||
|
private_key: "{{ vault.ldap_private_key }}"
|
||||||
|
certificate: "{{ vault.ldap_certificate }}"
|
3
hosts
3
hosts
@ -13,6 +13,9 @@ localhost
|
|||||||
templier.adh.crans.org
|
templier.adh.crans.org
|
||||||
dt.adh.crans.org
|
dt.adh.crans.org
|
||||||
|
|
||||||
|
[slapd]
|
||||||
|
dt.adh.crans.org
|
||||||
|
|
||||||
[virtu]
|
[virtu]
|
||||||
dt.adh.crans.org
|
dt.adh.crans.org
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- import_playbook: apt.yml
|
- import_playbook: apt.yml
|
||||||
|
- import_playbook: ntp.yml
|
||||||
|
|
||||||
- hosts: all
|
- hosts: all
|
||||||
roles:
|
roles:
|
||||||
@ -20,7 +21,7 @@
|
|||||||
- sudo
|
- sudo
|
||||||
- systemd
|
- systemd
|
||||||
- pacman
|
- pacman
|
||||||
- ntp
|
- ntp-client-arch
|
||||||
- texlive
|
- texlive
|
||||||
- xorg
|
- xorg
|
||||||
- i3
|
- i3
|
||||||
|
13
plays/ntp.yml
Executable file
13
plays/ntp.yml
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env ansible-playbook
|
||||||
|
---
|
||||||
|
- hosts: ntp_server
|
||||||
|
vars:
|
||||||
|
ntp_server: '{{ glob_ntp_server | combine(loc_ntp_server | default({})) }}'
|
||||||
|
roles:
|
||||||
|
- ntp-server
|
||||||
|
|
||||||
|
- hosts: debian
|
||||||
|
vars:
|
||||||
|
ntp_client: '{{ glob_ntp_client | combine(loc_ntp_client | default({})) }}'
|
||||||
|
roles:
|
||||||
|
- ntp-client
|
5
roles/ntp-client/handlers/main.yml
Normal file
5
roles/ntp-client/handlers/main.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- name: Restart systemd-timesyncd
|
||||||
|
service:
|
||||||
|
name: systemd-timesyncd
|
||||||
|
state: restarted
|
29
roles/ntp-client/tasks/main.yml
Normal file
29
roles/ntp-client/tasks/main.yml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
- name: Clean up ntp
|
||||||
|
apt:
|
||||||
|
state: absent
|
||||||
|
name: ntp
|
||||||
|
purge: true
|
||||||
|
register: apt_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_result is succeeded
|
||||||
|
when: "'ntp_server' not in group_names"
|
||||||
|
|
||||||
|
- name: Install systemd-timesyncd (bullseye)
|
||||||
|
apt:
|
||||||
|
name: systemd-timesyncd
|
||||||
|
update_cache: true
|
||||||
|
install_recommends: false
|
||||||
|
register: apt_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_result is succeeded
|
||||||
|
when:
|
||||||
|
- "'ntp_server' not in group_names"
|
||||||
|
- ansible_distribution_release == "bullseye"
|
||||||
|
|
||||||
|
- name: Configure NTP
|
||||||
|
template:
|
||||||
|
src: systemd/timesyncd.conf.j2
|
||||||
|
dest: /etc/systemd/timesyncd.conf
|
||||||
|
notify: Restart systemd-timesyncd
|
||||||
|
when: "'ntp_server' not in group_names"
|
2
roles/ntp-client/templates/systemd/timesyncd.conf.j2
Normal file
2
roles/ntp-client/templates/systemd/timesyncd.conf.j2
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Time]
|
||||||
|
NTP={{ ntp_client.servers | join(' ') }}
|
27
roles/ntp-server/tasks/main.yml
Normal file
27
roles/ntp-server/tasks/main.yml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
- name: Install NTP
|
||||||
|
apt:
|
||||||
|
update_cache: true
|
||||||
|
name: ntp
|
||||||
|
register: apt_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_result is succeeded
|
||||||
|
|
||||||
|
- name: Configure NTP daemon
|
||||||
|
lineinfile:
|
||||||
|
path: /etc/default/ntp
|
||||||
|
regexp: '^NTPD_OPTS'
|
||||||
|
line: NTPD_OPTS='-g -x'
|
||||||
|
check_mode: no
|
||||||
|
|
||||||
|
- name: Configure NTP
|
||||||
|
template:
|
||||||
|
src: ntp.conf.j2
|
||||||
|
dest: /etc/ntp.conf
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
|
- name: Start ntp service
|
||||||
|
systemd:
|
||||||
|
name: ntp
|
||||||
|
enabled: true
|
||||||
|
state: started
|
62
roles/ntp-server/templates/ntp.conf.j2
Normal file
62
roles/ntp-server/templates/ntp.conf.j2
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
{{ ansible_header | comment }}
|
||||||
|
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
|
||||||
|
|
||||||
|
driftfile /var/lib/ntp/ntp.drift
|
||||||
|
|
||||||
|
# Leap seconds definition provided by tzdata
|
||||||
|
leapfile /usr/share/zoneinfo/leap-seconds.list
|
||||||
|
|
||||||
|
# Enable this if you want statistics to be logged.
|
||||||
|
#statsdir /var/log/ntpstats/
|
||||||
|
|
||||||
|
statistics loopstats peerstats clockstats
|
||||||
|
filegen loopstats file loopstats type day enable
|
||||||
|
filegen peerstats file peerstats type day enable
|
||||||
|
filegen clockstats file clockstats type day enable
|
||||||
|
|
||||||
|
|
||||||
|
# pool.ntp.org maps to about 1000 low-stratum NTP servers. Your server will
|
||||||
|
# pick a different set every time it starts up. Please consider joining the
|
||||||
|
# pool: <http://www.pool.ntp.org/join.html>
|
||||||
|
pool ntp.crans.org iburst
|
||||||
|
pool 0.debian.pool.ntp.org iburst
|
||||||
|
pool 1.debian.pool.ntp.org iburst
|
||||||
|
pool 2.debian.pool.ntp.org iburst
|
||||||
|
pool 3.debian.pool.ntp.org iburst
|
||||||
|
|
||||||
|
|
||||||
|
# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
|
||||||
|
# details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
|
||||||
|
# might also be helpful.
|
||||||
|
#
|
||||||
|
# Note that "restrict" applies to both servers and clients, so a configuration
|
||||||
|
# that might be intended to block requests from certain clients could also end
|
||||||
|
# up blocking replies from your own upstream servers.
|
||||||
|
|
||||||
|
# By default, exchange time with everybody, but don't allow configuration.
|
||||||
|
restrict -4 default kod notrap nomodify nopeer noquery limited
|
||||||
|
restrict -6 default kod notrap nomodify nopeer noquery limited
|
||||||
|
|
||||||
|
# Local users may interrogate the ntp server more closely.
|
||||||
|
restrict 127.0.0.1
|
||||||
|
restrict ::1
|
||||||
|
|
||||||
|
# Needed for adding pool entries
|
||||||
|
restrict source notrap nomodify noquery
|
||||||
|
|
||||||
|
# Server on adm can sync
|
||||||
|
restrict 172.16.42.0 mask 255.255.255.0 notrap nomodify
|
||||||
|
|
||||||
|
# Clients from this (example!) subnet have unlimited access, but only if
|
||||||
|
# cryptographically authenticated.
|
||||||
|
#restrict 192.168.123.0 mask 255.255.255.0 notrust
|
||||||
|
|
||||||
|
|
||||||
|
# If you want to provide time to your local subnet, change the next line.
|
||||||
|
# (Again, the address is an example only.)
|
||||||
|
#broadcast 192.168.123.255
|
||||||
|
|
||||||
|
# If you want to listen to time broadcasts on your local subnet, de-comment the
|
||||||
|
# next lines. Please do this only if you trust everybody on the network!
|
||||||
|
#disable auth
|
||||||
|
#broadcastclient
|
13
roles/slapd/README.md
Normal file
13
roles/slapd/README.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# SLAPD
|
||||||
|
|
||||||
|
Deploie un serveur ldap master ou replica
|
||||||
|
|
||||||
|
## VARS
|
||||||
|
|
||||||
|
slapd:
|
||||||
|
- ip : l'ip sur lequel il va installer le serveur ldap
|
||||||
|
- replica : s'il s'agit d'un master ou d'une replica
|
||||||
|
- replica_rid : le numéro de replica du serveur
|
||||||
|
- master_ip : l'ip du master
|
||||||
|
- replication_credentials : les credientials pour authentifier les replicas
|
||||||
|
auprès du master
|
6
roles/slapd/handlers/main.yml
Normal file
6
roles/slapd/handlers/main.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Restart slapd
|
||||||
|
service:
|
||||||
|
name: slapd.service
|
||||||
|
state: restarted
|
35
roles/slapd/tasks/main.yml
Normal file
35
roles/slapd/tasks/main.yml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
---
|
||||||
|
- name: Install slapd
|
||||||
|
apt:
|
||||||
|
update_cache: true
|
||||||
|
name:
|
||||||
|
- slapd
|
||||||
|
register: apt_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_result is succeeded
|
||||||
|
|
||||||
|
- name: Remove slapd config directory
|
||||||
|
file:
|
||||||
|
path: /etc/ldap/slapd.d/
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Deploy slapd configuration
|
||||||
|
template:
|
||||||
|
src: "ldap/{{ item.dest }}.j2"
|
||||||
|
dest: "/etc/ldap/{{ item.dest }}"
|
||||||
|
mode: "{{ item.mode }}"
|
||||||
|
owner: openldap
|
||||||
|
group: openldap
|
||||||
|
loop:
|
||||||
|
- { dest: slapd.conf, mode: "0600" }
|
||||||
|
- { dest: ldap.key, mode: "0600" }
|
||||||
|
- { dest: ldap.pem, mode: "0644" }
|
||||||
|
notify: Restart slapd
|
||||||
|
|
||||||
|
- name: Deploy ldap services
|
||||||
|
lineinfile:
|
||||||
|
path: /etc/default/slapd
|
||||||
|
regexp: '^SLAPD_SERVICES='
|
||||||
|
line: 'SLAPD_SERVICES="ldaps://{{ slapd.ip }}/ ldapi:///"'
|
||||||
|
notify: Restart slapd
|
||||||
|
check_mode: no
|
1
roles/slapd/templates/ldap/ldap.key.j2
Normal file
1
roles/slapd/templates/ldap/ldap.key.j2
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{ slapd.private_key }}
|
1
roles/slapd/templates/ldap/ldap.pem.j2
Normal file
1
roles/slapd/templates/ldap/ldap.pem.j2
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{ slapd.certificate }}
|
202
roles/slapd/templates/ldap/slapd.conf.j2
Normal file
202
roles/slapd/templates/ldap/slapd.conf.j2
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
# This is the main slapd configuration file. See slapd.conf(5) for more
|
||||||
|
# info on the configuration options.
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# Global Directives:
|
||||||
|
|
||||||
|
# Schema and objectClass definitions
|
||||||
|
include /etc/ldap/schema/core.schema
|
||||||
|
include /etc/ldap/schema/cosine.schema
|
||||||
|
include /etc/ldap/schema/nis.schema
|
||||||
|
include /etc/ldap/schema/inetorgperson.schema
|
||||||
|
|
||||||
|
# Where the pid file is put. The init.d script
|
||||||
|
# will not stop the server if you change this.
|
||||||
|
pidfile /var/run/slapd/slapd.pid
|
||||||
|
|
||||||
|
# List of arguments that were passed to the server
|
||||||
|
argsfile /var/run/slapd/slapd.args
|
||||||
|
|
||||||
|
# Read slapd.conf(5) for possible values
|
||||||
|
loglevel none
|
||||||
|
|
||||||
|
# Where the dynamically loaded modules are stored
|
||||||
|
modulepath /usr/lib/ldap
|
||||||
|
moduleload back_mdb
|
||||||
|
{% if not slapd.replica %}
|
||||||
|
moduleload auditlog
|
||||||
|
|
||||||
|
overlay auditlog
|
||||||
|
auditlog /var/log/openldap/auditlog.log
|
||||||
|
|
||||||
|
moduleload constraint
|
||||||
|
overlay constraint
|
||||||
|
constraint_attribute description regex {{ slapd.regex }}
|
||||||
|
restrict=ldap:///ou=hosts,dc=ynerant,dc=fr??one?(objectClass=device)
|
||||||
|
constraint_attribute uid regex ^_
|
||||||
|
restrict=ldap:///ou=passwd,dc=ynerant,dc=fr??one?(objectClass=posixAccount)
|
||||||
|
|
||||||
|
moduleload syncprov
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
# TLS Certificates
|
||||||
|
#TLSCipherSuite HIGH:MEDIUM:-SSLv2:-SSLv3
|
||||||
|
TLSCertificateFile /etc/ldap/ldap.pem
|
||||||
|
TLSCertificateKeyFile /etc/ldap/ldap.key
|
||||||
|
|
||||||
|
# The maximum number of entries that is returned for a search operation
|
||||||
|
sizelimit 500
|
||||||
|
|
||||||
|
# The tool-threads parameter sets the actual amount of cpu's that is used
|
||||||
|
# for indexing.
|
||||||
|
tool-threads 1
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# Specific Backend Directives for mdb:
|
||||||
|
# Backend specific directives apply to this backend until another
|
||||||
|
# 'backend' directive occurs
|
||||||
|
backend mdb
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# Specific Backend Directives for 'other':
|
||||||
|
# Backend specific directives apply to this backend until another
|
||||||
|
# 'backend' directive occurs
|
||||||
|
#backend <other>
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# Specific Directives for database #1, of type mdb:
|
||||||
|
# Database specific directives apply to this databasse until another
|
||||||
|
# 'database' directive occurs
|
||||||
|
database mdb
|
||||||
|
|
||||||
|
# The base of your directory in database #1
|
||||||
|
suffix "dc=ynerant,dc=fr"
|
||||||
|
|
||||||
|
# rootdn directive for specifying a superuser on the database. This is needed
|
||||||
|
# for syncrepl.
|
||||||
|
rootdn "cn=admin,dc=ynerant,dc=fr"
|
||||||
|
|
||||||
|
# Where the database file are physically stored for database #1
|
||||||
|
directory "/var/lib/ldap"
|
||||||
|
|
||||||
|
# The dbconfig settings are used to generate a DB_CONFIG file the first
|
||||||
|
# time slapd starts. They do NOT override existing an existing DB_CONFIG
|
||||||
|
# file. You should therefore change these settings in DB_CONFIG directly
|
||||||
|
# or remove DB_CONFIG and restart slapd for changes to take effect.
|
||||||
|
|
||||||
|
# For the Debian package we use 2MB as default but be sure to update this
|
||||||
|
# value if you have plenty of RAM
|
||||||
|
#dbconfig set_cachesize 0 2097152 0
|
||||||
|
|
||||||
|
# Sven Hartge reported that he had to set this value incredibly high
|
||||||
|
# to get slapd running at all. See http://bugs.debian.org/303057 for more
|
||||||
|
# information.
|
||||||
|
|
||||||
|
# Number of objects that can be locked at the same time.
|
||||||
|
#dbconfig set_lk_max_objects 1500
|
||||||
|
# Number of locks (both requested and granted)
|
||||||
|
#dbconfig set_lk_max_locks 1500
|
||||||
|
# Number of lockers
|
||||||
|
#dbconfig set_lk_max_lockers 1500
|
||||||
|
|
||||||
|
# Indexing options for database #1
|
||||||
|
index objectClass eq
|
||||||
|
|
||||||
|
# Save the time that the entry gets modified, for database #1
|
||||||
|
lastmod on
|
||||||
|
|
||||||
|
# Checkpoint the BerkeleyDB database periodically in case of system
|
||||||
|
# failure and to speed slapd shutdown.
|
||||||
|
checkpoint 512 30
|
||||||
|
|
||||||
|
{% if slapd.replica %}
|
||||||
|
syncrepl
|
||||||
|
rid={{ slapd.replica_rid }}
|
||||||
|
provider=ldaps://{{ slapd.master_ip }}:636
|
||||||
|
bindmethod=simple
|
||||||
|
binddn="cn=replicator,dc=ynerant,dc=fr"
|
||||||
|
credentials={{ slapd.replication_credentials }}
|
||||||
|
searchbase="dc=ynerant,dc=fr"
|
||||||
|
scope=sub
|
||||||
|
schemachecking=on
|
||||||
|
type=refreshAndPersist
|
||||||
|
timeout=0
|
||||||
|
network-timeout=0
|
||||||
|
retry="30 20 300 +"
|
||||||
|
tls_reqcert=allow
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if slapd.replica %}
|
||||||
|
# The userPassword by default can be changed
|
||||||
|
# by the entry owning it if they are authenticated.
|
||||||
|
# Others should not be able to see it, except the
|
||||||
|
# admin entry below
|
||||||
|
# These access lines apply to database #1 only
|
||||||
|
access to attrs=userPassword,shadowLastChange
|
||||||
|
by anonymous auth
|
||||||
|
by * none
|
||||||
|
|
||||||
|
# Ensure read access to the base for things like
|
||||||
|
# supportedSASLMechanisms. Without this you may
|
||||||
|
# have problems with SASL not knowing what
|
||||||
|
# mechanisms are available and the like.
|
||||||
|
# Note that this is covered by the 'access to *'
|
||||||
|
# ACL below too but if you change that as people
|
||||||
|
# are wont to do you'll still need this if you
|
||||||
|
# want SASL (and possible other things) to work
|
||||||
|
# happily.
|
||||||
|
access to dn.base="" by * read
|
||||||
|
|
||||||
|
# The admin dn has full write access, everyone else
|
||||||
|
# can read everything.
|
||||||
|
access to *
|
||||||
|
by * read
|
||||||
|
{% else %}
|
||||||
|
overlay syncprov
|
||||||
|
|
||||||
|
# The userPassword by default can be changed
|
||||||
|
# by the entry owning it if they are authenticated.
|
||||||
|
# Others should not be able to see it, except the
|
||||||
|
# admin entry below
|
||||||
|
# These access lines apply to database #1 only
|
||||||
|
access to attrs=userPassword,shadowLastChange
|
||||||
|
by anonymous auth
|
||||||
|
by self write
|
||||||
|
by set="[cn=nounou,ou=group,dc=ynerant,dc=fr]/memberUid & user/uid" write
|
||||||
|
by dn="cn=replicator,dc=ynerant,dc=fr" read
|
||||||
|
by * none
|
||||||
|
|
||||||
|
access to attrs=loginShell,mail,telephoneNumber
|
||||||
|
by self write
|
||||||
|
by set="[cn=nounou,ou=group,dc=ynerant,dc=fr]/memberUid & user/uid" write
|
||||||
|
by dn="cn=replicator,dc=ynerant,dc=fr" read
|
||||||
|
by * read
|
||||||
|
|
||||||
|
# Ensure read access to the base for things like
|
||||||
|
# supportedSASLMechanisms. Without this you may
|
||||||
|
# have problems with SASL not knowing what
|
||||||
|
# mechanisms are available and the like.
|
||||||
|
# Note that this is covered by the 'access to *'
|
||||||
|
# ACL below too but if you change that as people
|
||||||
|
# are wont to do you'll still need this if you
|
||||||
|
# want SASL (and possible other things) to work
|
||||||
|
# happily.
|
||||||
|
access to dn.base="" by * read
|
||||||
|
|
||||||
|
# The admin dn has full write access, everyone else
|
||||||
|
# can read everything.
|
||||||
|
access to *
|
||||||
|
by set="[cn=nounou,ou=group,dc=ynerant,dc=fr]/memberUid & user/uid" write
|
||||||
|
by dn="cn=replicator,dc=ynerant,dc=fr" read
|
||||||
|
by * read
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# Specific Directives for database #2, of type 'other' (can be mdb too):
|
||||||
|
# Database specific directives apply to this databasse until another
|
||||||
|
# 'database' directive occurs
|
||||||
|
#database <other>
|
||||||
|
|
||||||
|
# The base of your directory for database #2
|
||||||
|
#suffix "dc=debian,dc=org"
|
Loading…
Reference in New Issue
Block a user