You've already forked ansible-linux-infra
initial commit
This commit is contained in:
5
roles/base_os/handlers/main.yml
Normal file
5
roles/base_os/handlers/main.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
- name: restart chrony
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ base_os_chrony_service_name }}"
|
||||
state: restarted
|
||||
75
roles/base_os/tasks/main.yml
Normal file
75
roles/base_os/tasks/main.yml
Normal file
@@ -0,0 +1,75 @@
|
||||
---
|
||||
- name: Include OS-family-specific variables
|
||||
ansible.builtin.include_vars: "{{ item }}"
|
||||
with_first_found:
|
||||
- "{{ ansible_facts['os_family'] }}.yml"
|
||||
- "default.yml"
|
||||
tags: [base_os, always]
|
||||
|
||||
- name: Update apt cache
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
cache_valid_time: 3600
|
||||
when: ansible_facts['os_family'] == "Debian"
|
||||
tags: [base_os]
|
||||
|
||||
- name: Install base packages
|
||||
ansible.builtin.package:
|
||||
name: "{{ base_os_packages + (base_extra_packages | default([])) }}"
|
||||
state: present
|
||||
tags: [base_os]
|
||||
|
||||
- name: Set timezone
|
||||
community.general.timezone:
|
||||
name: "{{ timezone }}"
|
||||
tags: [base_os]
|
||||
|
||||
- name: Deploy chrony configuration
|
||||
ansible.builtin.template:
|
||||
src: chrony.conf.j2
|
||||
dest: "{{ base_os_chrony_config_path }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify: restart chrony
|
||||
tags: [base_os]
|
||||
|
||||
- name: Enable and start chrony
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ base_os_chrony_service_name }}"
|
||||
enabled: true
|
||||
state: started
|
||||
tags: [base_os]
|
||||
|
||||
- name: Set hostname from inventory
|
||||
ansible.builtin.hostname:
|
||||
name: "{{ inventory_hostname }}"
|
||||
tags: [base_os]
|
||||
|
||||
- name: Remove unwanted packages
|
||||
ansible.builtin.package:
|
||||
name: "{{ base_os_unwanted_packages }}"
|
||||
state: absent
|
||||
tags: [base_os, cis_hardening]
|
||||
|
||||
- name: Gather service facts
|
||||
ansible.builtin.service_facts:
|
||||
tags: [base_os]
|
||||
|
||||
- name: Disable unneeded services if installed
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ item }}"
|
||||
enabled: false
|
||||
state: stopped
|
||||
loop: "{{ base_unneeded_services }}"
|
||||
when: (item + '.service') in ansible_facts.services
|
||||
tags: [base_os]
|
||||
|
||||
- name: Deploy post-login MOTD
|
||||
ansible.builtin.template:
|
||||
src: motd.j2
|
||||
dest: /etc/motd
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
tags: [base_os]
|
||||
9
roles/base_os/templates/chrony.conf.j2
Normal file
9
roles/base_os/templates/chrony.conf.j2
Normal file
@@ -0,0 +1,9 @@
|
||||
# {{ ansible_managed }}
|
||||
{% for server in ntp_servers %}
|
||||
server {{ server }} iburst
|
||||
{% endfor %}
|
||||
|
||||
driftfile /var/lib/chrony/drift
|
||||
makestep 1.0 3
|
||||
rtcsync
|
||||
logdir /var/log/chrony
|
||||
6
roles/base_os/templates/motd.j2
Normal file
6
roles/base_os/templates/motd.j2
Normal file
@@ -0,0 +1,6 @@
|
||||
******************************************************************
|
||||
AUTHORIZED ACCESS ONLY.
|
||||
All activity on this system is logged and monitored.
|
||||
Unauthorized access is prohibited and may be prosecuted.
|
||||
Managed via Ansible ({{ inventory_hostname }}).
|
||||
******************************************************************
|
||||
17
roles/base_os/vars/Debian.yml
Normal file
17
roles/base_os/vars/Debian.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
base_os_packages:
|
||||
- vim
|
||||
- chrony
|
||||
- auditd
|
||||
- firewalld
|
||||
- rsyslog
|
||||
- sudo
|
||||
base_os_unwanted_packages:
|
||||
- sendmail
|
||||
- telnet
|
||||
- rsh-client
|
||||
- rsh-redone-client
|
||||
- nis
|
||||
- tftp
|
||||
base_os_chrony_config_path: /etc/chrony/chrony.conf
|
||||
base_os_chrony_service_name: chrony
|
||||
17
roles/base_os/vars/RedHat.yml
Normal file
17
roles/base_os/vars/RedHat.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
base_os_packages:
|
||||
- vim-enhanced
|
||||
- chrony
|
||||
- audit
|
||||
- policycoreutils-python-utils
|
||||
- firewalld
|
||||
- rsyslog
|
||||
- sudo
|
||||
base_os_unwanted_packages:
|
||||
- sendmail
|
||||
- telnet
|
||||
- rsh
|
||||
- ypbind
|
||||
- tftp
|
||||
base_os_chrony_config_path: /etc/chrony.conf
|
||||
base_os_chrony_service_name: chronyd
|
||||
Reference in New Issue
Block a user