@@ -190,7 +190,61 @@ PLAY RECAP *********************************************************************
190
190
```
191
191
192
192
193
- - 执行命令:` ansible-playbook /opt/disable-firewalld-playbook.yml `
193
+
194
+ #### 基础环境(CentOS 7.x)
195
+
196
+
197
+ - 创建脚本文件:` vim /opt/install-basic-playbook.yml `
198
+
199
+ ```
200
+ - hosts: all
201
+ remote_user: root
202
+ tasks:
203
+ - name: Disable SELinux at next reboot
204
+ selinux:
205
+ state: disabled
206
+
207
+ - name: disable firewalld
208
+ command: "{{ item }}"
209
+ with_items:
210
+ - systemctl stop firewalld
211
+ - systemctl disable firewalld
212
+ - setenforce 0
213
+
214
+ - name: install-basic
215
+ command: "{{ item }}"
216
+ with_items:
217
+ - yum install -y zip unzip lrzsz git epel-release wget htop deltarpm
218
+
219
+ - name: install-vim
220
+ shell: "{{ item }}"
221
+ with_items:
222
+ - yum install -y vim
223
+ - curl https://raw.githubusercontent.com/wklken/vim-for-server/master/vimrc > ~/.vimrc
224
+
225
+ - name: install-docker
226
+ shell: "{{ item }}"
227
+ with_items:
228
+ - yum install -y yum-utils device-mapper-persistent-data lvm2
229
+ - yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
230
+ - yum makecache fast
231
+ - yum install -y docker-ce
232
+ - systemctl start docker.service
233
+ - docker run hello-world
234
+
235
+ - name: install-docker-compose
236
+ shell: "{{ item }}"
237
+ with_items:
238
+ - curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
239
+ - chmod +x /usr/local/bin/docker-compose
240
+ - docker-compose --version
241
+ - systemctl restart docker.service
242
+ - systemctl enable docker.service
243
+
244
+ ```
245
+
246
+
247
+ - 执行命令:` ansible-playbook /opt/install-basic-playbook.yml `
194
248
195
249
#### 修改 hosts
196
250
@@ -259,6 +313,7 @@ PLAY RECAP *********************************************************************
259
313
#### 部署 Hadoop 集群
260
314
261
315
- 创建脚本文件:` vim /opt/hadoop-playbook.yml `
316
+ - 刚学 Ansible,不好动配置文件,所以就只保留环境部分的设置,其他部分自行手工~
262
317
263
318
```
264
319
- hosts: hadoop-host
@@ -277,20 +332,6 @@ PLAY RECAP *********************************************************************
277
332
path: /data/hadoop/hdfs/tmp
278
333
state: directory
279
334
280
- - name: copy gz file
281
- copy: src=/opt/hadoop-2.6.5.tar.gz dest=/usr/local
282
-
283
- - name: tar gz file
284
- command: cd /usr/local && tar zxf hadoop-2.6.5.tar.gz
285
-
286
- - name: check folder existed
287
- stat: path=/usr/local/hadoop-2.6.5
288
- register: folder_existed
289
-
290
- - name: rename folder
291
- command: mv /usr/local/hadoop-2.6.5 /usr/local/hadoop
292
- when: folder_existed.stat.exists == true
293
-
294
335
- name: set HADOOP_HOME
295
336
blockinfile:
296
337
path: /etc/profile
@@ -306,7 +347,7 @@ PLAY RECAP *********************************************************************
306
347
```
307
348
308
349
309
- - 执行命令:` ansible-playbook /opt/jdk8 -playbook.yml `
350
+ - 执行命令:` ansible-playbook /opt/hadoop -playbook.yml `
310
351
311
352
312
353
@@ -317,7 +358,7 @@ PLAY RECAP *********************************************************************
317
358
318
359
## 资料
319
360
320
-
361
+ - [ ANSIBLE模块 - shell和command区别 ] ( https://www.jianshu.com/p/081139f73613 )
321
362
- < https://www.the5fire.com/ansible-guide-cn.html >
322
363
- < https://www.jianshu.com/p/62388a4fcbc6 >
323
364
- < http://showme.codes/2017-06-12/ansible-introduce/ >
0 commit comments