当前位置:网站首页>3.使用Ansible中的playbook
3.使用Ansible中的playbook
2022-07-21 05:20:00 【多于少的区别】
Ansible中的playbook
一、Playbook的功能
playbook 是由一个或多个play组成的列表
Playboot 文件使用YAML来写的
二、YAML
简介
是一种表达资料序列的格式,类似XML
Yet Another Markup Language
2001年首次发表
www.yaml.org
特点
可读性好
和脚本语言交互性好
易于实现
适用程序执行流梳理方式
可扩展性强
语法简介
在文件中用[- - -]开始
在文件中用[. . .]结尾
次行一般书写文件内容
缩进严格
大小写敏感
key/value可以多行书写也可一行书写,一行书写用,隔开
value可以是个字符串,也可是list
一个play需要包括name和tasks
name 是描述
tasks 是动作
一个name只能包含一个task
扩展名称yml或者yaml
YAML列表的两种表示方式
[Linux,C++,Java,Python]
- Linux
- C++
- Java
- Python
YAML的字典
字典作用存放键值
name:westos
age:12
jobs:linux
{
name: "westos", age: "12", jobs: "linux"}
三、playbook执行命令
ansible-playbook xxx.yml 执行命令格式
--check|-C 检测
--syntax-check check language
--list-hosts 列出hosts
--list-tags 列出tag
--list-tasks 列出task
--limit 指定执行主机
-v -vv 现实过程
Playbook的核心组件
name 可选,建议使用多用于说明
hosts 受控主机列表
tasks 任务
用与选择执行部分代码
实验:
要求:
在系统中完成以下用户操作
1.建立用户组Manufacture,Finance,Technology并满足以下要求:
* Manufacture组id为8000
* Finance组id为8001
* Technology组id为8002
2.建立westosuser,linux,lee,westosadmin等用户完成以下要求
*westosuser用户的附加组为Manufacture和Technology
*lee的主组为Finance,附加组为Technology,lee的uid和gid必须一致
*linux为系统账号不能被操作者使用
3.建立目录完成以下要求
*新建目录/WESTOS_Manufacture,/WESTOS_Finance,/WESTOS_Technology,/WESTOS_Public
*/WESTOS_Manufacture目录是Manufacture内的数据存储目录,只能被Manufacture内的人员读写,并且在/WESTOS_Manufacture中建立的文件都属于Manufacture内
*/WESTOS_Finance目录是Finance内的数据存储目录,只能被Finance内的人员读写,并且在/WESTOS_Finance中建立的文件都属于Finance内
*/WESTOS_Technology目录是Technology内的数据存储目录,只能被Technology内的人员读写,并且在/WESTOS_Technology中建立的文件都属于Technology内
*/WESTOS_Public为公司人员公共目录,可以被公司任意员工读写,但是只能删除自己的文件
四、设定技巧
autocmd FileType yaml setlocal ai ts=2 sw=2 et
setlocal 设定当前文件
ai 自动退格对齐,auto indent
ts tab建长度为2空格 tabstop=2
sw 缩进长度为2,shiftwidth=2
et 把tab键变成空格 expandtab
实验:
要求:install vsftpd
并且匿名用户可以登陆anon can login
边栏推荐
- Pycharm 2019使用设置,让你用起来更便捷!
- DNS domain name resolution service
- Using disassembly debugging and complement to explain 0x80000000 / -1 shaping output exception inconsistency
- Use Mysql to query logs slowly
- Take you to easily decrypt the white box test and (Demo detailed explanation)
- ASCII and hexadecimal conversion table
- LR load
- PeopleSoft update table interface program
- Frequently asked interview questions in software testing [2]
- Install cross compiler: eabi-4.3.3_ EmbedSky_ 20100610.tar. bz2
猜你喜欢
Quickly solve the problem that the computer wireless network cannot be connected
Deployment of three centers in two places
Parsing the sliding window of TCP
What should I learn about self-study software testing?
TZC 1283: simple sort merge sort
Peoplecode understands the structure and content of component cache
How to do app upgrade test?
Practical exercise | a simple method to retrieve odd or even rows in the database
Oracle uses data manipulation functions
根据进程名一键批量结束进程(chromedriver.exe)
随机推荐
LVS的不足之处及第四种转发类型FULLNAT
JMeter saves test process data in page form
接口测试(1)
DataGrip 2021 使用设置,让你使用起来更丝滑
Common functions of Charles
Using web workers
[common interview questions of network protocol]
Deployment of three centers in two places
How to do app upgrade test?
Chessboard coverage problem
How to write use cases when uploading files?
The database is for the salaries table emp above_ No field create index idx_ emp_ no
How to write the use case of APP login function?
Frequently asked interview questions in software testing [2]
TZC 1283: simple sort merge sort
根据进程名一键批量结束进程(chromedriver.exe)
How to evaluate the test quality?
Install cross compiler: eabi-4.3.3_ EmbedSky_ 20100610.tar. bz2
JMeter之WebService(soap)请求
How to do regression test