蒙阴网站优化,reeoo v5 wordpress,网页设计代码复习,wordpress建菜单简介
roles是ansible#xff0c;playbooks的目录的组织结构#xff0c;将代码或文件进行模块化#xff0c;成为roles的文件目录组织结构。 易读#xff0c;代码可冲哟美好#xff0c;层次清晰
目录机构 mkdir roles/nginx/{files,handlers,tasks,templates,vars} -ptou…简介
roles是ansibleplaybooks的目录的组织结构将代码或文件进行模块化成为roles的文件目录组织结构。 易读代码可冲哟美好层次清晰
目录机构 mkdir roles/nginx/{files,handlers,tasks,templates,vars} -ptouch roles/site.yaml roles/nginx/{handlers,tasks,vars}/main.yamlecho 1234 roles/nginx/files/index.htmlyum -y install nginx cap /etc/nginx/nginx.conf roles/nginx/templates/nginx.conf.j2
编写任务
vim roles/nginx/tasks/main.yaml---
- name: install epel-release packageyum: nameepel-release statelatest
- name: install nginx packageyum: namenginx statelatest
- name: copy index.htmlcopy: srcindex.html dest/usr/share/nginx/html/index.html
- name: copy nginx.conf templatetemplate: srcnginx.conf.j2 dest/etc/nginx/nginx.confnotify: restart nginx
- name: make sure nginx service runningservice: namenginx statestarted enabledyestemplate,相当于copy会替换原来的
准备配置文件
vim roles/nginx/templates/nginx.conf.j2 编写变量
vim roles/nginx/vars/main.yamlworker_connections: 1024
上面的worker_connections 调用此处的变量
编写处理程序
vim roles/nginx/handlers/main.yaml---
- name: restart nginxservice: namenginx staterestarted
编写剧本
vim roles/site.yaml- hosts: sever2roles: - nginx
实施
cd rolesansible-playbook site.yaml --syntax-checkansible-playbook site.yaml