Add ansible roles + templates

This commit is contained in:
2025-01-07 22:17:39 +00:00
parent 3e65c89dc9
commit 04db61efc2
12 changed files with 202 additions and 0 deletions

View File

@ -0,0 +1,6 @@
---
## Reload NSD on changes
- name: restart nsd
ansible.builtin.service:
name: nsd
state: restarted

View File

@ -0,0 +1,35 @@
---
- name: Install packages for local resolver
tags: resolver-install
ansible.builtin.package:
name:
- nsd
- git
state: latest
- name: NSD - Enable service
tags: nsd-enable
ansible.builtin.service:
name: 'nsd'
state: started
enabled: yes
- name: NSD - Define configuration
tags: nsd-configure
ansible.builtin.template:
src: nsd.conf
dest: /etc/nsd/nsd.conf
validate: /usr/sbin/nsd-checkconf %s
backup: yes
notify: restart nsd
- name: Auto-update the git repo for the internal zone
tags: nsd-dns-gitupdate
ansible.builtin.git:
repo: https://git.labolyon.fr/LOL-si/dns-lolinternal.git
dest: /srv/nsd/
version: main
update: yes
notify:
- restart nsd

View File

@ -0,0 +1,22 @@
server:
server-count: 1
hide-version: yes
debug-mode: no
verbosity: 2
zonesdir: "/srv/nsd/"
remote-control:
control-enable: yes
control-interface: /var/run/nsd.sock
zone:
name: "int.labolyon.fr"
zonefile: "int.labolyon.fr.zone"
zone:
name: "labolyon.dn42"
zonefile: "labolyon.dn42.zone"
zone:
name: "labolyon.fr"
zonefile: "labolyon.fr.zone"

View File

@ -0,0 +1,10 @@
---
- name: Load variables
include_vars: "{{ ansible_os_family|lower }}.yml"
- name: Tools | install common packages for servers
ansible.builtin.package:
name: '{{ common_packages }}'
state: latest
tags: common-tools

View File

@ -0,0 +1,15 @@
---
# vars file for tools role
common_packages:
- htop
- neofetch
- curl
- bash
- figlet
- vim
- rsync
- needrestart
- lynis
- apt-listbugs
- dnsutils
- libpam-radius-auth

View File

@ -0,0 +1,52 @@
---
- name: Load variables
include_vars: "{{ ansible_os_family|lower }}.yml"
- name: Linux | Set bash path for Linux hosts
ansible.builtin.set_fact:
bash_path: /bin/bash
- name: All hosts | Create the users
ansible.builtin.user:
name: "{{ item.name }}"
home: /home/{{ item.name }}
shell: '{{ bash_path }}'
groups: sudo
append: true
state: present
with_items: "{{ user_details }}"
- name: All hosts | Set up home directory permissions for users
ansible.builtin.file:
path: /home/{{ item.name }}
owner: "{{ item.name }}"
state: directory
mode: 0700
with_items: "{{ user_details }}"
- name: All hosts | Set up ssh directory for users
ansible.builtin.file:
path: /home/{{ item.name }}/.ssh
owner: "{{ item.name }}"
state: directory
mode: 0700
with_items: "{{ user_details }}"
#- name: All hosts | Add ssh keys for allowing connections
# ansible.builtin.template:
# src: authorized_keys
# dest: /home/vinishor/.ssh/authorized_keys
# owner: vinishor
# mode: 0600
- name: Linux | Correct sudoers file permissions for ansible user
ansible.builtin.file:
path: "/etc/sudoers.d/ansible"
owner: root
group: root
mode: 0640
- name: Linux | Define MOTD file
ansible.builtin.shell:
cmd: figlet -t {{ inventory_hostname_short | quote }} > /etc/motd

View File

@ -0,0 +1,7 @@
---
user_details:
- { name: vincent }
- { name: mirsal }
- { name: jerome }
- { name: sofian }