-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.yml
More file actions
150 lines (118 loc) · 4.1 KB
/
main.yml
File metadata and controls
150 lines (118 loc) · 4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
- hosts: namenode
vars_files:
- vars.yml
tasks:
- name: Registering Namenode Facts in namenode_ip
setup:
register: namenode_ip
- name: Downloading Java JDK from URL
get_url:
url: "http://35.244.242.82/yum/java/el7/x86_64/jdk-8u171-linux-x64.rpm"
dest: "/root/jdk-8u171-linux-x64.rpm"
- name: Downloading Hadoop file from URL
get_url:
url: "https://archive.apache.org/dist/hadoop/core/hadoop-1.2.1/hadoop-1.2.1-1.x86_64.rpm"
dest: "/root/hadoop-1.2.1-1.x86_64.rpm"
- name: Checking if Java JDK is installed or not
command: "rpm -q jdk1.8"
register: check_java
ignore_errors: yes
- debug:
var: check_java
- name: Installing Java JDK
command: "rpm -i /root/jdk-8u171-linux-x64.rpm"
when: '"is not installed" in check_java.stdout'
- name: Checking if Hadoop is installed or not
command: "rpm -q hadoop"
register: check_hadoop
ignore_errors: yes
- debug:
var: check_hadoop
- name: Installing Hadoop
command: "rpm -i /root/hadoop-1.2.1-1.x86_64.rpm --force"
when: '"is not installed" in check_hadoop.stdout'
- name: Namenode Directory creation
file:
state: directory
path: "{{ namenode_dir }}"
notify: Update the changes
- name: Setting up core-site.xml file
template:
dest: "/etc/hadoop/core-site.xml"
src: "/t11_1/namenode/core-site.xml"
- name: Setting up hdfs-site.xml file
template:
dest: "/etc/hadoop/hdfs-site.xml"
src: "/t11_1/namenode/hdfs-site.xml"
- name: Registering dummy host to pass on the namenode IP to the datanode by registering it to namenode_ip_new
add_host:
name: "Dummy_Host"
namenode_ip_new: "{{ namenode_ip }}"
handlers:
- name: Stop the Namenode process if it's already running
command: "hadoop-daemon.sh stop namenode"
ignore_errors: yes
listen: Update the changes
- name: Namenode Formatting
shell: "echo Y | hadoop namenode -format"
listen: Update the changes
- name: Starting Namenode
command: "hadoop-daemon.sh start namenode"
listen: Update the changes
- hosts: datanode
gather_facts: false
vars_files:
- vars.yml
tasks:
- name: Storing the IP obtained from namenode_ip_new to namenode_ip_updated
shell: echo "{{ hostvars['Dummy_Host']['namenode_ip_new']['ansible_facts']['ansible_all_ipv4_addresses'][0] }}" | tail -1
register: namenode_ip_updated
- debug:
var: namenode_ip_updated.stdout
- name: Downloading Java JDK from URL
get_url:
url: "http://35.244.242.82/yum/java/el7/x86_64/jdk-8u171-linux-x64.rpm"
dest: "/root/jdk-8u171-linux-x64.rpm"
- name: Downloading Hadoop file from URL
get_url:
url: "https://archive.apache.org/dist/hadoop/core/hadoop-1.2.1/hadoop-1.2.1-1.x86_64.rpm"
dest: "/root/hadoop-1.2.1-1.x86_64.rpm"
- name: Checking if Java JDK is installed or not
command: "rpm -q jdk1.8"
register: check_java
ignore_errors: yes
- debug:
var: check_java
- name: Installing Java JDK
command: "rpm -i /root/jdk-8u171-linux-x64.rpm"
when: '"is not installed" in check_java.stdout'
- name: Checking if Hadoop is installed or not
command: "rpm -q hadoop"
register: check_hadoop
ignore_errors: yes
- debug:
var: check_hadoop
- name: Installing Hadoop
command: "rpm -i /root/hadoop-1.2.1-1.x86_64.rpm --force"
when: '"is not installed" in check_hadoop.stdout'
- name: Datanode Directory creation
file:
state: directory
path: "{{ datanode_dir }}"
notify: Update the changes
- name: Setting up core-site.xml file
template:
dest: "/etc/hadoop/core-site.xml"
src: "/t11_1/datanode/core-site.xml"
- name: Setting up hdfs-site.xml file
template:
dest: "/etc/hadoop/hdfs-site.xml"
src: "/t11_1/datanode/hdfs-site.xml"
handlers:
- name: Stop the Datanode process if it's already running
command: "hadoop-daemon.sh stop datanode"
ignore_errors: yes
listen: Update the changes
- name: Starting Datanode
command: "hadoop-daemon.sh start datanode"
listen: Update the changes