feat(playbook): add real-world config tasks like nginx setup and SSL update

This commit is contained in:
Haitao Pan 2025-05-25 12:10:21 +08:00
parent 0bad18e5d6
commit 4ca48d9401

View File

@ -1,10 +1,31 @@
- name: Local System Check
- name: Web Server Provision
tasks:
- name: Check system uptime
shell: uptime
- name: Install nginx (macOS/Homebrew)
shell: |
if command -v brew &>/dev/null; then
brew install nginx || echo "nginx already installed"
else
echo "brew not found, skipping"
fi
- name: List current directory
shell: ls -lah
- name: Install nginx (Linux/Apt/Yum)
shell: |
if [ -f /etc/debian_version ]; then
sudo apt-get update && sudo apt-get install -y nginx
elif [ -f /etc/redhat-release ]; then
sudo yum install -y epel-release && sudo yum install -y nginx
else
echo "unsupported OS"
fi
- name: Show disk usage
shell: df -h
- name: Update /etc/hosts
shell: |
sudo sh -c 'echo "127.0.0.1 demo.local" >> /etc/hosts'
- name: Reload nginx
shell: |
sudo nginx -s reload || echo "nginx reload failed (may not be running)"
- name: Simulate SSL cert update
shell: |
mkdir -p /tmp/ssl && echo "dummy-cert" > /tmp/ssl/fullchain.pem