diff --git a/sync/config.yaml b/sync/config.yaml index 7cb3229..f779b85 100644 --- a/sync/config.yaml +++ b/sync/config.yaml @@ -1,31 +1,28 @@ -- name: Web Server Provision +- name: Local Config Tasks tasks: - - name: Install nginx (macOS/Homebrew) + - name: Install nginx (macOS/Homebrew or Linux/apt) shell: | if command -v brew &>/dev/null; then - brew install nginx || echo "nginx already installed" - else - echo "brew not found, skipping" - fi - - - name: Install nginx (Linux/Apt/Yum) - shell: | - if [ -f /etc/debian_version ]; then + brew install nginx || true + elif command -v apt-get &>/dev/null; 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" + echo "⚠️ Unsupported OS" fi - - name: Update /etc/hosts + - name: Update /etc/hosts with test domain shell: | - sudo sh -c 'echo "127.0.0.1 demo.local" >> /etc/hosts' + echo "127.0.0.1 test.cw-agent.local" | sudo tee -a /etc/hosts - - name: Reload nginx + - name: Create dummy SSL cert (for test) shell: | - sudo nginx -s reload || echo "nginx reload failed (may not be running)" + mkdir -p /tmp/ssl + openssl req -x509 -newkey rsa:2048 -keyout /tmp/ssl/key.pem -out /tmp/ssl/cert.pem -days 1 -nodes -subj "/CN=test.cw-agent.local" - - name: Simulate SSL cert update + - name: Reload nginx (if available) shell: | - mkdir -p /tmp/ssl && echo "dummy-cert" > /tmp/ssl/fullchain.pem + if command -v nginx &>/dev/null; then + sudo nginx -s reload || sudo brew services restart nginx + else + echo "nginx not found" + fi