# YAML的字典

> 来源：梦飞idc云平台 | 原文：https://www.mfisp.com/16618.html | 发布：2023-02-14 | 更新：2023-02-14 | 分类：投稿分享

## 1. 作用解释

 

字典作用存放键值  
name:westos  
age:12  
jobs:linux

 

## 2.相关参数

 

ansible-playbook xxx.yml ...  
--check|-C #预执行  
--syntax-check #check language  
--list-hosts #列出hosts  
--list-tags #列出tag  
--list-tasks #列出task清单的所有主机  
--limit #指定执行主机  
-v -vv #现实过程-vv显示详细过程

 

## 3. vim设定方式

 

vim ~/.vimrc #编辑该文件使得其可以进行设定  
autocmd FileType yaml setlocal ai ts=2 sw=2 et  
set nu #设定所有文件都代行号显示

 

## 4.练习

 

使用playbook安装httpd软件同时将该服务设定为开机自起，同时将其设定为启动状态

 

1 ---  
 2 - name: for 91-93 httpd.server install and start  
 3 hosts: server  
 4 tags: httpd server start and firealld add + port 8080/tcp  
 5 tasks:  
 6 - yum:  
 7 state: latest  
 8 name: httpd  
 9 - service:  
 10 name: httpd  
 11 state: started  
 12 enabled: yes  
 13 - shell:  
 14 cmd: systemctl enable --now httpd  
 15 executable: bash  
 16 - firewalld:  
 17 service: http  
 18 zone: public  
 19 immediate: yes  
 20 permanent: yes  
 21 state: enabled  
 22 - firewalld:  
 23 port: 443/tcp  
 24 zone: public  
 25 permanent: yes  
 26 immediate: yes  
 27 state: enabled  
 28 ...

 

![YAML的字典](https://www.mfisp.com/wp-content/uploads/2022/10/11048-apQ5nb.jpg)

---
本页由 梦飞idc云平台（https://www.mfisp.com）提供。站点导航见 https://www.mfisp.com/llms.txt
