Skip to content

Instantly share code, notes, and snippets.

@codatory
Created November 19, 2022 01:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codatory/c0dc6d425a95d7268754f2af6dece0ab to your computer and use it in GitHub Desktop.
Save codatory/c0dc6d425a95d7268754f2af6dece0ab to your computer and use it in GitHub Desktop.
Kubernetes Host OS Bootstrap Playbook
- name: Applying OS Configuration Baseline
hosts: all
gather_facts: no
become: true
vars:
ansible_ssh_pipelining: true
tasks:
- name: Install fwupd
apt:
name: fwupd
- name: Refresh fwupd db
command:
cmd: fwupdmgr refresh
ignore_errors: yes
- name: Install firmware updates
register: firmware
command:
cmd: fwupdmgr update -y
- name: Reboot for firmware updates
when: firmware.changed
throttle: 1
reboot:
all:
children:
control:
hosts:
10.8.0.11:
10.8.0.12:
10.8.0.13:
work:
hosts:
10.8.0.21:
10.8.0.22:
10.8.0.23:
- name: Applying OS Configuration Baseline
hosts: all
gather_facts: no
become: true
vars:
ansible_ssh_pipelining: true
tasks:
- name: Configure Sudo NoPasswd
community.general.sudoers:
name: sudoers-nopasswd
state: present
group: sudo
commands: ALL
nopassword: yes
- name: Prepare Aptitude
apt:
cache_valid_time: 1800
autoremove: yes
autoclean: yes
name: aptitude
- name: Install HWE
apt:
name: linux-generic-hwe-20.04
- name: Install NFS Tools
apt:
name: nfs-common
- name: Install Fail2Ban
apt:
name: fail2ban
- name: Configure fail2ban
register: fail2ban_jail
copy:
dest: /etc/fail2ban/jail.local
content: |
[sshd]
enabled = true
port = 22
[sshd-ddos]
enabled = true
port = 22
- name: Restart fail2ban
when: fail2ban_jail.changed
service:
name: fail2ban
state: restarted
- name: Enable fail2ban
service:
name: fail2ban
state: started
enabled: yes
- name: Update all packages
apt:
state: latest
upgrade: yes
- name: Check if reboot is required
stat:
path: /var/run/reboot-required
register: reboot_required
- name: Restart System
throttle: 1
when: reboot_required.stat.exists
reboot:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment