main.yml 4.42 KiB
---
# tasks file for simApp
- block:
- name: enable ubuntu group
group: name=ubuntu state=present
- name: enable ubuntu user
user: name=ubuntu state=present shell=/bin/bash
- name: Install Java Package
apt: pkg=openjdk-8-jre-headless state=installed update_cache=true force=yes
- name: make sure AllowUser statement is absent
lineinfile:
dest: /etc/ssh/sshd_config
regexp: '^AllowUsers*'
state: absent
- name: download hadoop
get_url: url=http://artfiles.org/apache.org/hadoop/common/stable/hadoop-2.9.2.tar.gz dest=/root/hadoop-2.9.2.tar.gz
register: downloaded
- name: unpack hadoop
shell: tar -xvf /root/hadoop-2.9.2.tar.gz
when: downloaded.changed
- name: copy hadoop to target location
shell: cp -rf /home/ubuntu/hadoop-2.9.2 /opt/hadoop
when: downloaded.changed
- name: make sure hadoop folder has the correct permissions
file: path=/opt/hadoop owner=ubuntu group=ubuntu recurse=yes
- name: make sure sshd is restarted
service: name=ssh state=restarted
when: task == "DEPLOY"
remote_user: ubuntu
- block:
- name: edit core-site.xml configuration
shell: echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n
<?xml-stylesheet type=\"text/xsl\" href=\"configuration.xsl\"?>\n
<configuration>\n
\t<property>\n
\t\t<name>fs.defaultFS</name>\n
\t\t<value>hdfs://hadoop-master:9000</value>\n
\t</property>\n
</configuration>\n" > /opt/hadoop/etc/hadoop/core-site.xml
- name: edit hdfs-site.xml configuration
shell: echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<?xml-stylesheet type=\"text/xsl\" href=\"configuration.xsl\"?>
<configuration>
<property>
<name>dfs.replication</name>
<value>3</value>
</property>
</configuration>" > /opt/hadoop/etc/hadoop/hdfs-site.xml
- name: edit mapred-site.xml configuration
shell: echo "<?xml version=\"1.0\"?>
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>" > /opt/hadoop/etc/hadoop/mapred-site.xml
- name: edit yarn-site.xml configuration