CentOS 自动化运维实战指南
一 工具选型与适用场景
二 快速上手 Ansible
[webservers]
web1.example.com
web2.example.com
[databases]
db1.example.com
---
- hosts: webservers
become: yes
tasks:
- name: Install Apache
yum:
name: httpd
state: present
- name: Start and enable Apache
service:
name: httpd
state: started
enabled: yes
三 常见场景与示例
0 2 * * * /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1
FROM nginx:latest
COPY ./html /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
四 监控与告警
五 落地路线与最佳实践