基于学习的目的,演示使用ansible往远程linux服务器上部署nginx。
创建playbook相关目录和文件
mkdir ansible-study
mkdir -p ansible-study/files
mkdir -p ansible-study/templates
touch ansible-study/hosts
touch ansible-study/web-notls.yml
创建主部署文件web-notls.yml
文件路径:./playbook/ansible-nginx
- name: Configure webserver with nginx
hosts: webservers
sudo: True
tasks:
- name: Nginx Install rpm
yum:
name: http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
- name: Nginx install nginx
yum:
name: nginx
state: latest
- name: copy nginx config file
copy: src=files/nginx.conf dest=/etc/nginx/sites-av