“使用Ansible搭建分布式大数据基础环境”列文章完整包含了如何使用Ansible这一分布式运维利器,来帮我们快速搭建Hadoop2/Spark2/Hive2/ZooKeeper3/Flink1.7/ElasticSearch5等一整套大数据解决方案。本篇是系列文章的第三篇。更多后续文章敬请关注。
(二)使用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
preservewhen no modification is required,YYYYMMDDHHMM.SSwhen using default time format, ornow.Default is
Nonemeaning thatpreserveis the default forstate=[file,directory,link,hard]andnowis default forstate=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: attrfollow boolean
- Choices:

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

被折叠的 条评论
为什么被折叠?



