ansible-play中role的基本用法
#role应用
#roles跟调用角色的剧本文件应该与roles同级关系,即放在ansible目录下
#makir /root/ansible/roles/{nginx,http,ftp,mysql,redis}
palybook.yml
roles/
project/
tasks/ 定义task,role的基本元素,至少包含一个main.yml文件
files/ 存放由copy或script模块等调用的文件
vars/ 定义变量文件
templates/ template模块查找所需要末班文件的目录
handlers/
default/ 设定默认变量
#以nginx为例
思路:
1.group:创建用户组nginx
2.user:创建用户nginx
3.yum:安装nginx
4.template:配置文件更新nginx.conf
5.service:启动nginx
####################################################################
cd /root/ansible/roles/nginx
mkdir tasks templates
cd task touch group.yml
- name: create group nginx
group: name=nginx gid=80 touch user.yml
-name: create user nginx
user: name=nginx uid=80 group=nginx system=yes shell=/sbi/nologin touch install.yml
- name: install package
yum: name=nginx touch start.yml
- name: start service
service: name=nginx state=started enabled=yes touch restart.yml
- name: restart service
service: name=nginx state=restarted touch templ.yml
- name: copy conf
template: src=nginx.conf.j2 dest=/etc/nginx/conf/nginx.conf touch main.yml
- include: group.yml
- include: user.yml
- include: install.yml
- include: templ.yml
- include: start.yml cd ../templates && ll
nginx.conf.j2 cd /root/ansible
touch nginx_role.yml
- hosts: websrvs
remote_user: root
roles:
- role: nginx 执行命令:ansible-playbook nginx_role.yml
ansible-play中role的基本用法的更多相关文章
- Java中的Socket的用法
Java中的Socket的用法 Java中的Socket分为普通的Socket和NioSocket. 普通Socket的用法 Java中的 ...
- ecshop中foreach的详细用法归纳
ec模版中foreach的常见用法. foreach 语法: 假如后台:$smarty->assign('test',$test); {foreach from=$test item=list ...
- matlab中patch函数的用法
http://blog.sina.com.cn/s/blog_707b64550100z1nz.html matlab中patch函数的用法——emily (2011-11-18 17:20:33) ...
- C#中timer类的用法
C#中timer类的用法 关于C#中timer类 在C#里关于定时器类就有3个 1.定义在System.Windows.Forms里 2.定义在System.Threading.Timer类 ...
- C#中dynamic的正确用法
C#中dynamic的正确用法 http://www.cnblogs.com/qiuweiguo/archive/2011/08/03/2125982.html dynamic是FrameWork4 ...
- C++中typename关键字的用法
我在我的 薛途的博客 上发表了新的文章,欢迎各位批评指正. C++中typename关键字的用法
- Guava中Predicate的常见用法
Guava中Predicate的常见用法 1. Predicate基本用法 guava提供了许多利用Functions和Predicates来操作Collections的工具,一般在 Iterabl ...
- C++中const 的各种用法
C++中const 关键字的用法 const修饰变量 const 主要用于把一个对象转换成一个常量,例如: ; size = ; // error: assignment of read-only v ...
- JS里设定延时:js中SetInterval与setTimeout用法
js中SetInterval与setTimeout用法 JS里设定延时: 使用SetInterval和设定延时函数setTimeout 很类似.setTimeout 运用在延迟一段时间,再进行某项操 ...
随机推荐
- Latex 经常见到的问题和解决方法
Latex 经常见到的问题和解决方法 2017-04-10 22:05:48 [资源下载]Texlive 2018 下载地址:http://mirror.lzu.edu.cn/CTAN/system ...
- 【SSL Certificates】什么是数字证书(Certificates)?
本文涉及的相关问题,如果你的问题或需求有与下面所述相似之处,请阅读本文 ssl certificate 什么是ssl certificates? SSL Certificates 是一种使用数字加密技 ...
- HttpClient exception:ExceptionType:System.Threading.Tasks.TaskCanceledException: The operation was canceled. ---> System.IO.IOException: Unable to read data from the transport connection: Operation ca
error msg: System.Threading.Tasks.TaskCanceledException: The operation was canceled. ---> System. ...
- @keyframs实现图片gif效果
页面中使用动效图 一般让设计出一个gif格式的图,但是git图效果都很差,有一个替代gif图做动效的方法:使用@keyframes 具体思路: 1.设计两个互斥的图片(相当于把gif图分割成一帧一帧的 ...
- js三元表达式
条件 ? true的时候执行 : false时候执行 const x = 20; let answer; if (x > 10) { answer = 'greater than 10'; } ...
- 微信、qq二次分享
前言 我们平时做微信分享的时候,一般分享出来的页面都是一个简单的html页面,不会加入框架之类的东西.所以当我们在分享出来的页面里面再次进行分享的时候,由于我们没有配置分享的标题.描述这些东西,分享出 ...
- Codeforces 741 D - Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths
D - Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths 思路: 树上启发式合并 从根节点出发到每个位置的每个字符的奇偶性记为每个位 ...
- 3 - Two Pointers Algorithm
5. Kth Largest Element (quick sort的变种) https://www.lintcode.com/problem/kth-largest-element/descript ...
- gcc使用及动静态库制作
一. GCC的使用 1. GCC的编译过程 (1)预处理(cpp)gcc -E(输出问价通常以 .i 结尾),将头文件展开,宏替换等操作: (2)编译器(gcc)gcc -S(输出问价以 .s 结尾) ...
- 操纵Review被封店,申诉信
标签: 测评被封 亚马逊申诉 操纵评价申诉 分类: 亚马逊申诉模板 Hello,We recently contacted you about product review manipulation. ...