当前位置:网站首页>3. Use playbook in ansible
3. Use playbook in ansible
2022-07-22 00:09:00 【More than less difference】
Ansible Medium playbook
One 、Playbook The function of
playbook By one or more play A list of components
Playboot Files use YAML To write it
Two 、YAML
brief introduction
Is a format for expressing data sequences , similar XML
Yet Another Markup Language
2001 First published in
www.yaml.org
characteristic
Good readability
Good interaction with script language
Easy to implement
Applicable program execution flow sorting method
High scalability
Syntactic introduction
Use in file [- - -] Start
Use in file [. . .] ending
The next line generally writes the contents of the document
Indent strictly
Case sensitive
key/value You can write in multiple lines or one line , A line of calligraphy is written in , separate
value It could be a string , But list
One play Need to include name and tasks
name Is to describe
tasks It's action
One name Only one can be included task
Extension name yml perhaps yaml
YAML Two representations of lists
[Linux,C++,Java,Python]
- Linux
- C++
- Java
- Python
YAML Dictionary
The dictionary is used to store key values
name:westos
age:12
jobs:linux
{
name: "westos", age: "12", jobs: "linux"}
3、 ... and 、playbook Carry out orders
ansible-playbook xxx.yml Execute command format
--check|-C testing
--syntax-check check language
--list-hosts List hosts
--list-tags List tag
--list-tasks List task
--limit Specify the execution host
-v -vv Realistic process
Playbook Core components
name Optional , It is recommended to use more to illustrate
hosts List of controlled hosts
tasks Mission
Use and select to execute part of the code
experiment :
requirement :
Complete the following user operations in the system
1. Set up user groups Manufacture,Finance,Technology And meet the following requirements :
* Manufacture Group id by 8000
* Finance Group id by 8001
* Technology Group id by 8002
2. establish westosuser,linux,lee,westosadmin Wait for the user to complete the following requirements
*westosuser The user's additional group is Manufacture and Technology
*lee The main group of is Finance, Additional set for Technology,lee Of uid and gid It has to be consistent
*linux The system account cannot be used by the operator
3. Create a directory to complete the following requirements
* new directory /WESTOS_Manufacture,/WESTOS_Finance,/WESTOS_Technology,/WESTOS_Public
*/WESTOS_Manufacture Directory is Manufacture Data storage directory in , Can only be Manufacture Read and write by personnel in the , And in /WESTOS_Manufacture All files created in belong to Manufacture Inside
*/WESTOS_Finance Directory is Finance Data storage directory in , Can only be Finance Read and write by personnel in the , And in /WESTOS_Finance All files created in belong to Finance Inside
*/WESTOS_Technology Directory is Technology Data storage directory in , Can only be Technology Read and write by personnel in the , And in /WESTOS_Technology All files created in belong to Technology Inside
*/WESTOS_Public Public directory for company personnel , It can be read and written by any employee of the company , But you can only delete your own files
Four 、 Setting skills
autocmd FileType yaml setlocal ai ts=2 sw=2 et
setlocal Set current file
ai Auto backspace alignment ,auto indent
ts tab The construction length is 2 Space tabstop=2
sw The indent length is 2,shiftwidth=2
et hold tab Key into space expandtab
experiment :
requirement :install vsftpd
And anonymous users can log in anon can login
边栏推荐
- Vote | choose the database you want Navicat to support
- Take you to easily decrypt the white box test and (Demo detailed explanation)
- Does Navicat 16 support native Apple silicon M1 chips| Apple user must read
- Lamp架构——mysql高可用切换(MHA高可用)
- LR load balancer management, distributed load generator
- Analysis of cross apply and outer apply query of SQL Server - Part II
- Basic MD5 encryption
- Oracle subquery
- Integer transformation problem
- One click batch termination of processes according to the process name (chromedriver.exe)
猜你喜欢
Navicat was selected into the "global database industry map" released by the Academy of information technology
快速解决电脑无线网络无法连接问题
[infrastructure] [flink] Flink / Flink CDC code to achieve business access
@Correct use of requestparam annotation
Practical exercise | a simple method to retrieve odd or even rows in the database
Peoplecode objects and classes
Tcp/ip Foundation
win7系统忘记登录密码怎么办?(不用启动盘情况下)
How to write the use case of APP login function?
How to test insert and update statements before execution
随机推荐
Kruskal reconstruction tree
Variable usage method of BeanShell of JMeter
Practical exercise | a simple method to retrieve odd or even rows in the database
WiFi authentication & OmniPeek packet capture analysis
1056 Mice and Rice
Migrate repo managed code to Gerrit
On nested connection
What if win7 system forgets its login password? (without startup disk)
LR load balancer management, distributed load generator
LAMP架构——mysql的安装部署、mysql集群及主从结构(1)
Implementation of static address book
MySQL multi table Association delete / update
Database dormitory management system
JProfiler installation and use tutorial
codis集群的搭建
LVM磁盘多分区扩容(fdisk,vgdata,lvdata,df,resize2fs,lvextend,partprobe)
Relevant contents of tube side
Use of source lnsight (read uboot under Samba share)
Database delete EMP_ No duplicate records, only the records corresponding to the smallest ID are retained
Navicat 16.1 provides a new choice of management development tools for oceanbase Community Edition