如何在CentOS 7(EC2实例)中完全卸载Puppet服务端及客户端?
Got it, let’s walk through completely wiping Puppet from your CentOS 7 system (including EC2 instances) — partial uninstalls are super common when folks miss hidden configs or leftover services, so we’ll cover every loose end here.
卸载Puppet客户端(Agent)
Start with stopping and disabling the agent service to avoid it running mid-uninstall:
- Stop the puppet agent:
systemctl stop puppet - Disable it from starting on boot:
systemctl disable puppet - Remove the agent packages (cover all common package names):
yum remove -y puppet puppet-agent puppet-release
Next, delete all leftover config, data, and log directories — these are often what cause "residual" Puppet issues:
rm -rf /etc/puppet/ /var/lib/puppet/ /var/log/puppet/- If you installed via Puppet Labs official repo, clean up their dedicated directory:
rm -rf /opt/puppetlabs/
卸载Puppet服务端(Master/Server)
For servers, we need to handle the puppetservice specifically:
- Stop the puppetserver service:
systemctl stop puppetserver - Disable auto-start:
systemctl disable puppetserver - Remove server-related packages:
yum remove -y puppetserver puppet-server puppet puppet-release
Now wipe server-specific data (including SSL certificates, which are a big one for leftover traces):
rm -rf /etc/puppetlabs/ /var/lib/puppetlabs/ /var/log/puppetlabs/- Clear old SSL certs (if you had a CA setup):
rm -rf /var/lib/puppet/ssl/
通用残留清理(适用于客户端和服务端)
Even after removing packages, there might be loose ends to tie up:
- Clean up YUM repos: If you added Puppet’s official repo, delete the repo file:
rm -rf /etc/yum.repos.d/puppet*.repo - Clear YUM cache:
yum clean all - Check for stray processes: Run
ps aux | grep puppet— if any processes show up, kill them withkill -9 <pid>(replace<pid>with the process ID from the output) - EC2-specific check: If you used cloud-init or user data to install Puppet on your EC2 instance, double-check these files to make sure Puppet isn’t set to reinstall on reboot:
/var/lib/cloud/instance/user-data.txt/etc/cloud/cloud.cfg
Remove any lines that reference Puppet installation if present.
验证卸载完成
To make sure everything’s gone, run these checks:
rpm -qa | grep puppet— should return no resultssystemctl list-unit-files | grep puppet— should show no enabled/disabled Puppet services- Check that all the directories we deleted earlier don’t exist anymore
If you tried uninstalling before and it didn’t stick, this full cleanup should fix it — most partial uninstalls miss the SSL certs or /opt/puppetlabs/ directory.
内容的提问来源于stack exchange,提问作者envalentine

