Commit 822737ea authored by Georgios Ouzounis's avatar Georgios Ouzounis
Browse files

LAM-33 Created common role.

parent 3d1b6300
---
- hosts: all
user: root
roles:
- ../roles/common
---
- hosts: vms
user: root
tasks:
# aptitude packages
- include: ../tasks/aptitude/upgrade.yml tags=install_scripts
- include: ../tasks/aptitude/java.yml tags=install_scripts
- include: ../tasks/aptitude/vim.yml tags=install_scripts
- include: ../tasks/aptitude/python.yml tags=install_scripts
# copy /etc/hosts file
- include: ../tasks/install/hosts.yml tags=install_scripts
# copy /etc/environment file
- include: ../tasks/install/environment.yml tags=install_scripts
# run ssh-keygen
- include: ../tasks/ssh/ssh-keygen.yml tags=install_scripts
- hosts: master
user: root
tasks:
# copy ssh public key of master
- include: ../tasks/ssh/fetch-key.yml
- hosts: vms
user: root
tasks:
# distribute ssh key to all nodes
- include: ../tasks/ssh/authorized-key.yml
export JAVA_HOME=/usr/
export HADOOP_HOME=/usr/local/hadoop
Host master-node
StrictHostKeyChecking no
Host slave-1
StrictHostKeyChecking no
Host slave-2
StrictHostKeyChecking no
Host 0.0.0.0
StrictHostKeyChecking no
---
- name: Upgrade packages.
apt: upgrade=dist update_cache=yes
- name: Install the latest Java 7.
apt: name=openjdk-7-jdk state=latest install_recommends=no update_cache=yes
- name: Copy hosts file.
template: src=hosts.j2 dest=/etc/hosts backup=no owner=root group=root mode=0750
- name: Copy environment file.
copy: src=environment dest=/etc/environment backup=no owner=root group=root mode=0750
- name: Generate ssh key.
shell: cat /dev/zero | ssh-keygen -q -N ""
args:
creates: /root/.ssh/id_rsa.pub
---
- name: ssh key
authorized_key: user=root key="{{ lookup('file', '/tmp/fetched/id_rsa.pub') }}"
- name: Distribute ssh key to all nodes.
authorized_key: user=root key="{{ lookup('file', '/tmp/fetched/id_rsa.pub') }}"
---
- name: Include common tasks.
include: common-1.yml
tags:
- common-1
- name: Include tasks for master.
include: master.yml
when: "'master' in group_names"
tags:
- master
- name: Include more common tasks.
include: common-2.yml
tags:
- common-2
---
- name: Fetch id_rsa.pub file from master.
fetch: src=/root/.ssh/id_rsa.pub dest=/tmp/fetched/ flat=yes
- name: Set up ssh config.
copy: src="ssh-config" dest="/root/.ssh/config" owner=root group=root mode=664
127.0.0.1 localhost
192.168.0.3 snf-661306
192.168.0.2 snf-661303
192.168.0.4 snf-661304
{{ hostvars["master-node"]["internal_ip"] }} master-node
{{ hostvars["slave-1"]["internal_ip"] }} slave-1
{{ hostvars["slave-2"]["internal_ip"] }} slave-2
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
......
---
# Install latest version of "openjdk-7-jdk" ignoring "install-recommends"
- name: install latest Java 7
tags: install_scripts
apt: name=openjdk-7-jdk state=latest install_recommends=no update_cache=yes
---
# Install python
- name: install python
tags: install_scripts
apt: name=python state=latest install_recommends=no update_cache=yes
---
# Update all packages to the latest version
- name: Upgrade packages
tags: install_scripts
apt: upgrade=dist update_cache=yes
---
# Install vim
- name: install vim
tags: install_scripts
apt: name=vim state=latest install_recommends=no update_cache=yes
---
- name: Make hdfs user dir
command: /usr/local/hadoop/bin/hadoop fs -mkdir /user
- name: Make hdfs user/root dir
command: /usr/local/hadoop/bin/hadoop fs -mkdir /user/root
---
#copy environment file
- name: Copy environment file
tags: install_scripts
copy: src=../files/etc/environment
dest=/etc/ backup=no
owner=root group=root mode=0750
---
#copy hosts ip-hostname file
- name: Copy hosts file
tags: install_scripts
copy: src=../files/etc/hosts
dest=/etc/ backup=no
owner=root group=root mode=0750
---
- name: fetch id_rsa.pub file from master
fetch: src=/root/.ssh/id_rsa.pub dest=/tmp/fetched/ flat=yes
---
- name: Run ssh-keygen
tags: install_scripts
shell: cat /dev/zero | ssh-keygen -q -N ""
args:
creates: /root/.ssh/id_rsa.pub
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment