[ssh_known_hosts] ssh_known_hosts is a service not a role

linter
_shirenn 2022-07-04 21:57:24 +02:00
parent 304f95c33b
commit 55e1fdc184
7 changed files with 33 additions and 15 deletions

View File

@ -0,0 +1,15 @@
---
glob_service_ssh_known_hosts:
name: ssh_known_hosts
install_dir: /var/local/services/ssh_known_hosts
dependencies:
- python3-ldap
- python3-jinja2
git:
remote: https://gitlab.adm.crans.org/nounous/ssh_known_hosts.git
version: main
cron:
frequency: "*/10 * * * *"
config:
ldap:
server: "ldaps://{{ query('ldap', 'ip', 'tealc', 'adm') | ansible.utils.ipv4 | first }}"

View File

@ -0,0 +1,5 @@
---
loc_service_ssh_known_hosts:
config:
ldap:
server: "ldaps://{{ query('ldap', 'ip', 'thot', 'adm') | ansible.utils.ipv4 | first }}"

View File

@ -0,0 +1,5 @@
---
loc_service_ssh_known_hosts:
config:
ldap:
server: "ldaps://{{ query('ldap', 'ip', 'ft', 'adm') | ansible.utils.ipv4 | first }}"

View File

@ -117,3 +117,8 @@ loc_bind:
default:
type: slave
primaries: "{{ query('ldap', 'ip', 'silice', 'adm') }}"
loc_service_ssh_known_hosts:
config:
ldap:
server: "ldaps://{{ query('ldap', 'ip', 'sputnik', 'adm') | ansible.utils.ipv4 | first }}"

View File

@ -1,5 +1,7 @@
#!/usr/bin/env ansible-playbook
---
- hosts: server
vars:
service: "{{ glob_service_ssh_known_hosts | default({}) | combine(loc_service_ssh_known_hosts | default({})) }}"
roles:
- ssh_known_hosts
- service

View File

@ -1,5 +0,0 @@
---
- name:
template:
src: ssh/ssh_known_hosts.j2
dest: /etc/ssh/ssh_known_hosts

View File

@ -1,9 +0,0 @@
{{ ansible_header | comment }}
{% set hosts = query('ldap', 'query', 'ou=hosts,dc=crans,dc=org', 'one', 'objectClass=device') %}
{% for host, device in hosts.items() | sort(attribute='0') %}
{% set cns = query('ldap', 'all_cn', hosts[host].cn[0]) | sort %}
{% set ips = query('ldap', 'all_ip', hosts[host].cn[0]) | sort %}
{% for key in query('ldap', 'ssh_keys', hosts[host].cn[0]) | sort %}
{{ hosts[host].cn[0] }},{{ cns | join(',') }},{{ ips | join(',') }} {{ key }} root@{{ hosts[host].cn[0] }}
{% endfor %}
{% endfor %}