File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- # Protect packages that SSH and cloud-init depend on from autoremove
2- # These must be marked as manually installed BEFORE any autoremove runs
3- - name : Mark SSH and cloud-init dependencies as manually installed
4- ansible.builtin.shell : |
5- apt-mark manual openssh-server cloud-init python3-systemd python3-jinja2 python3-yaml python3-oauthlib python3-configobj || true
6- changed_when : false
1+ # IMPORTANT: Do NOT use autoremove: true in these tasks!
2+ # Autoremove causes cascading removal of cloud-init and breaks SSH on the AMI.
3+ # Autoremove is handled safely in 90-cleanup.sh after apt-mark protection.
74
85- name : Remove build dependencies
96 ansible.builtin.apt :
10- autoremove : true
7+ autoremove : false
118 pkg :
129 - bison
1310 - build-essential
3229# - Dev packages provide headers for building exploits
3330# - salt-minion is a remote management agent (large attack surface)
3431# - sshpass stores credentials in plaintext
35- # NOTE: autoremove disabled here to prevent cascading removal of cloud-init deps
3632- name : Remove high-security-risk packages
3733 ansible.builtin.apt :
3834 autoremove : false
6460 # Build tool leftovers
6561 - ansible-core
6662 state : ' absent'
67-
68- # Run a final autoremove to clean up any remaining orphaned packages
69- # This runs after apt-mark manual, so cloud-init deps are protected
70- - name : Clean up orphaned packages
71- ansible.builtin.apt :
72- autoremove : true
73- changed_when : false
You can’t perform that action at this time.
0 commit comments