feat(ansible): idempotent role-based host config for both production VMs
common/firewall/docker-tls/platform/lab-host/monitoring-agent/backup roles, orchestrated by site.yml with the ordering that matters (firewall/TLS land before the services that depend on them). Ansible Vault for secrets, no new tool introduced for this project's modest secret surface. Explicit dev/staging/production environment separation, no secrets committed (.gitignore covers vault plaintext, TLS keys, Terraform state, *.env). Validated: ansible-playbook --syntax-check clean.
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
---
|
||||
common_timezone: UTC
|
||||
common_unattended_upgrades: true
|
||||
@@ -0,0 +1,35 @@
|
||||
---
|
||||
# Shared Docker Engine install — used by both platform and lab-host roles (import_tasks from
|
||||
# common, not duplicated). Follows Docker's own official apt-repo installation method.
|
||||
|
||||
- name: Add Docker's GPG key
|
||||
ansible.builtin.get_url:
|
||||
url: https://download.docker.com/linux/ubuntu/gpg
|
||||
dest: /etc/apt/keyrings/docker.asc
|
||||
mode: "0644"
|
||||
register: docker_gpg
|
||||
retries: 3
|
||||
delay: 5
|
||||
until: docker_gpg is succeeded
|
||||
|
||||
- name: Add Docker apt repository
|
||||
ansible.builtin.apt_repository:
|
||||
repo: "deb [arch={{ ansible_architecture | replace('x86_64','amd64') }} signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
|
||||
state: present
|
||||
filename: docker
|
||||
|
||||
- name: Install Docker Engine + Compose plugin
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- docker-ce
|
||||
- docker-ce-cli
|
||||
- containerd.io
|
||||
- docker-compose-plugin
|
||||
state: present
|
||||
update_cache: true
|
||||
|
||||
- name: Enable and start Docker
|
||||
ansible.builtin.systemd:
|
||||
name: docker
|
||||
enabled: true
|
||||
state: started
|
||||
@@ -0,0 +1,58 @@
|
||||
---
|
||||
# Baseline hardening applied to both rn-platform-01 and rn-lab-host-01 before anything
|
||||
# RootNode-specific — idempotent, safe to re-run (Phase 4 §20 requirement).
|
||||
|
||||
- name: Set timezone
|
||||
community.general.timezone:
|
||||
name: "{{ common_timezone }}"
|
||||
|
||||
- name: Install base packages
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- curl
|
||||
- ca-certificates
|
||||
- gnupg
|
||||
- iptables
|
||||
- iptables-persistent
|
||||
- unattended-upgrades
|
||||
- fail2ban
|
||||
- jq
|
||||
state: present
|
||||
update_cache: true
|
||||
cache_valid_time: 3600
|
||||
|
||||
- name: Enable unattended security upgrades
|
||||
ansible.builtin.copy:
|
||||
dest: /etc/apt/apt.conf.d/20auto-upgrades
|
||||
content: |
|
||||
APT::Periodic::Update-Package-Lists "1";
|
||||
APT::Periodic::Unattended-Upgrade "1";
|
||||
mode: "0644"
|
||||
when: common_unattended_upgrades
|
||||
|
||||
- name: Create the rootnode-deploy service account (if not the connecting user already)
|
||||
ansible.builtin.user:
|
||||
name: rootnode-deploy
|
||||
shell: /bin/bash
|
||||
groups: docker
|
||||
append: true
|
||||
create_home: true
|
||||
register: deploy_user_result
|
||||
failed_when: false # non-fatal — some hosts may already use this as ansible_user
|
||||
|
||||
- name: Ensure fail2ban is enabled for SSH
|
||||
ansible.builtin.service:
|
||||
name: fail2ban
|
||||
state: started
|
||||
enabled: true
|
||||
|
||||
- name: Create /opt/rootnode and /etc/rootnode base directories
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0750"
|
||||
loop:
|
||||
- /opt/rootnode
|
||||
- /etc/rootnode
|
||||
Reference in New Issue
Block a user