Commit 3fd033ab authored by efikalti's avatar efikalti
Browse files

LAM-14 ansible tasks and playbook for installing prerequired packages and variables in vms

parent 5b36d254
# Package and variable setup
## VM package and variable setup
Contains Ansible playbook for the installation of required packages and variables. The play is split into five (3) tasks:
- install packages and run basic commands on newly created vms.
- fetch public ssh key from master.
- distribute public key to all slave nodes.
Currently, the playbooks are run from an external node, and deploy both master and slave nodes. In future version, they will run from the master node to deploy master and slave nodes.
### Things to do before deployment
- Install python
- Add the public key of the machine running the playbook to all the nodes.
### Prerequisites
- Deploy against Debian 8.0 node
- Make sure `python` is installed on the target nodes
- Ansible version used is `1.9.1`
### How to deploy
```bash
$ ansible-playbook -v playbooks/install.yml
```
#
# config file for ansible
# https://raw.githubusercontent.com/ansible/ansible/devel/examples/ansible.cfg
#
[defaults]
remote_user = root
hostfile = hosts
\ No newline at end of file
export JAVA_HOME=/usr/
export HADOOP_HOME=/usr/local/hadoop
export YARN_HOME=$HADOOP_HOME
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
export YARN_CONF_DIR=$HADOOP_HOME/etc/hadoop
PATH=$PATH:$HADOOP_HOME/bin
PATH=$PATH:$HADOOP_HOME/sbin
export FLINK_HOME=/usr/local/flink
PATH=$PATH:$FLINK_HOME/bin
export KAFKA_HOME=/usr/local/kafka
\ No newline at end of file
127.0.0.1 localhost
192.168.0.3 snf-661306
192.168.0.2 snf-661303
192.168.0.4 snf-661304
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
---
- 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/include/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
\ No newline at end of file
---
# 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
\ No newline at end of file
---
# Install python
- name: install python
tags: install_scripts
apt: name=python state=latest install_recommends=no update_cache=yes
\ No newline at end of file
---
# Update all packages to the latest version
- name: Upgrade packages
tags: install_scripts
apt: upgrade=dist update_cache=yes
\ No newline at end of file
---
# Install vim
- name: install vim
tags: install_scripts
apt: name=vim state=latest install_recommends=no update_cache=yes
\ No newline at end of file
---
#copy hosts ip-hostname file
- name: Copy hosts file
tags: install_scripts
copy: src=files/etc/environment
dest=/etc/ backup=no
owner=root group=root mode=0750
\ No newline at end of file
---
#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
\ No newline at end of file
---
- name: ssh key
authorized_key: user=root key="{{ lookup('file', '/tmp/fetched/id_rsa.pub') }}"
\ No newline at end of file
---
- 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 ""
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