(三)使用Ansible搭建分布式大数据基础环境-编写第一个playbook

本文是使用Ansible搭建分布式大数据基础环境系列的第三篇,重点介绍如何编写common.yaml,创建目录并配置环境变量。通过执行playbook,将在多台服务器上创建指定目录并部署app_bin.sh,以实现自动化运维。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

“使用Ansible搭建分布式大数据基础环境”列文章完整包含了如何使用Ansible这一分布式运维利器,来帮我们快速搭建Hadoop2/Spark2/Hive2/ZooKeeper3/Flink1.7/ElasticSearch5等一整套大数据解决方案。本篇是系列文章的第三篇。更多后续文章敬请关注。

(一)使用Ansible搭建分布式大数据基础环境-环境准备

(二)使用Ansible搭建分布式大数据基础环境-Ansible项目创建

(三)使用Ansible搭建分布式大数据基础环境-编写第一个playbook

(四)使用Ansible搭建分布式大数据基础环境-Ansible常用Module介绍

(五)使用Ansible搭建分布式大数据基础环境-ZooKeeper集群模式搭建

(六)使用Ansible搭建分布式大数据基础环境-Hadoop高可用集群搭建

(七)使用Ansible搭建分布式大数据基础环境-MySQL安装​​​​​​​

 

     

本章我们主要完成我们的第一个playbook——common的编写,通过这个这一章节,我们可以大概熟悉playbook.yaml文件写法。

1.common.yaml完成目录创建

首先,在roles/common/目录下,创建task/main.yaml。然后开始编写我们的第一个指令:

--- # YAML文件段落分隔符
- name: Create Base Working Directory # 任务名称
  file: path={
  
  {base}} state=directory # 调用file模块,创建path指定的文件,文件类型是目录

这一条指令中,我们引用了file模块为我们创建我们的根目录({ {base}}是一个Jinja2模板引擎的变量引用,引用我们在group_vars或者host_vars中定义的变量)。

file module的官方说明是“Manage files and file properties”,它具有如下参数:

Parameter Choices/Defaults Comments
access_time

string

added in 2.7

 

This parameter indicates the time the file's access time should be set to.

Should be preserve when no modification is required, YYYYMMDDHHMM.SSwhen using default time format, or now.

Default is None meaning that preserve is the default for state=[file,directory,link,hard] and now is default for state=touch.

access_time_format

string

added in 2.7

Default:

"%Y%m%d%H%M.%S"

When used with access_time, indicates the time format that must be used.

Based on default Python format (see time.strftime doc).

attributes

string

added in 2.3

 

The attributes the resulting file or directory should have.

To get supported flags look at the man page for chattr on the target system.

This string should contain the attributes in the same order as the one displayed by lsattr.

The = operator is assumed as default, otherwise + or - operators need to be included in the string.


aliases: attr

follow

boolean

  • Choices:
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值