Files
ansible/playbooks/bootstrap_lxc.yml
T
harwinder cf0e62d80c Refactor inventory into OS groups and update playbooks accordingly
Group hosts by OS (ubuntu/rocky) in inventory, refactor playbooks to
use group-targeted plays instead of ansible_os_family conditionals,
add bot host, and add Docker volume backup playbook via rsync to storage.
2026-05-16 17:31:29 -04:00

143 lines
3.2 KiB
YAML

- name: Bootstrap - Install packages on Ubuntu
hosts: ubuntu
become: true
tasks:
- name: Install packages via apt
ansible.builtin.apt:
name:
- vim
- htop
- nmap
- curl
- wget
- iperf3
- fail2ban
- net-tools
- lsof
- unzip
- zip
- git
- sudo
- tree
- traceroute
- dnsutils
- ca-certificates
- python3
- python3-pip
- software-properties-common
- rsync
- apt-transport-https
- sysstat
- screen
- mtr
- tar
state: present
update_cache: true
- name: Bootstrap - Install packages on Rocky Linux
hosts: rocky
become: true
tasks:
- name: Ensure EPEL repo is enabled
ansible.builtin.dnf:
name: epel-release
state: present
- name: Install packages via dnf
ansible.builtin.dnf:
name:
- tar
- vim
- htop
- nmap
- curl
- mtr
- wget
- iperf3
- fail2ban
- net-tools
- lsof
- unzip
- zip
- git
- sudo
- tmux
- tree
- bash-completion
- traceroute
- bind-utils
- ca-certificates
- python3
- python3-pip
- rsync
- sysstat
- screen
state: present
update_cache: true
- name: Bootstrap - Configure SSH access
hosts: all
become: true
tasks:
- name: Ensure root's .ssh directory exists
ansible.builtin.file:
path: /root/.ssh
state: directory
owner: root
group: root
mode: '0700'
- name: Set authorized_keys for root
ansible.builtin.copy:
dest: /root/.ssh/authorized_keys
content: |
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINegitHaQG8i+s412h3wTWf/KvpeX1CEpYFva9MhHR+7 ansible-key
owner: root
group: root
mode: '0600'
- name: Permit root login via public key
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config
regexp: '^#?PermitRootLogin\s+'
line: 'PermitRootLogin prohibit-password'
state: present
backup: true
- name: Ensure PubkeyAuthentication is enabled
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config
regexp: '^#?PubkeyAuthentication\s+'
line: 'PubkeyAuthentication yes'
state: present
- name: Ensure PasswordAuthentication is enabled
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config
regexp: '^#?PasswordAuthentication\s+'
line: 'PasswordAuthentication yes'
state: present
- name: Bootstrap - Restart SSH on Ubuntu
hosts: ubuntu
become: true
tasks:
- name: Restart ssh service
ansible.builtin.service:
name: ssh
state: restarted
- name: Bootstrap - Restart SSH on Rocky Linux
hosts: rocky
become: true
tasks:
- name: Restart sshd service
ansible.builtin.service:
name: sshd
state: restarted