Skip to content

Commit

Permalink
ansible roles
Browse files Browse the repository at this point in the history
  • Loading branch information
shahiinn committed Jan 2, 2018
0 parents commit c867dca
Show file tree
Hide file tree
Showing 186 changed files with 8,509 additions and 0 deletions.
79 changes: 79 additions & 0 deletions activemq/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
Steps playbook performs

- choose wheater to install from repository or tarball
- Adding Service Scripts if it is tarball Installation
- Starting ActiceMQ in Server

yml files Involved

apt.yml :

- Repository Installation of activemq in server

download.yml :

- Download ActiveMQ tarball file
- Extract the downloaded Package
- Create user and group if not exist
- Changing file Permissions

service.yml :

- Coping ActiveMQ service script to server
- Enabling activemq service in default run levels

start.yml :

- To start ActiveMQ

Variables :

amq_install_mode = mode of installation(tarball or apt)

amq_user = owner user of Installation directory

amq_group = owner group of Installation directory

amq_port = running port

amq_install_dir = Installation directory

amq_home_dir = ActiveMQ home directory

amq_skip_checksum = true or false

amq_url_prefix = URL of download space

amq_version_major = Major version no

amq_version_minor = Minor version no

amq_version_patch = Patch version np

amq_version = Exact ActiveMQ version

amq_checksums = ActiveMQ checksum (List out all supported checksums here)

amq_service = If you want amq as service give 'yes'



---------------------test.yml---------------------

---

- name: Active-MQ installation

hosts: amq

remote_user: ubuntu

become: yes

become_method: sudo

roles:
- java-8
- amq

--------------------------------------------------
24 changes: 24 additions & 0 deletions activemq/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
#Default variable list for installing active-mq
amq_install_mode: "tarball"
amq_user: ubuntu
amq_group: ubuntu
amq_port: 8161
amq_install_dir: /opt
amq_home_dir: "{{ amq_install_dir }}/apache-activemq-{{ amq_version }}"
amq_skip_checksum: true
amq_url_prefix: "http://archive.apache.org/dist/activemq"
#Enter exact version to install
amq_version_major: "5"
amq_version_minor: "13"
amq_version_patch: "4"
amq_version: "{{ amq_version_major }}.{{ amq_version_minor }}.{{ amq_version_patch }}"
#List out all supported checksums here.
amq_checksums:
- { version: "5.13.3" , checksum: "md5:05e4c36bc109a0dc3d0bab74ec202787" }
- { version: "5.13.5" , checksum: "md5:07285ffcc6921ac87018af26f3718522" }
amq_url: "{{ amq_url_prefix }}/{{ amq_version }}/apache-activemq-{{ amq_version }}-bin.tar.gz"

#If you want amq as service give 'yes'.
amq_service: "yes"

11 changes: 11 additions & 0 deletions activemq/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
#Handler for manual starting
- name: start amq
command: "{{ amq_home_dir }}/bin/activemq start"

#Handler for starting service
- name: Starting amq service
service:
name: activemq
state: started

7 changes: 7 additions & 0 deletions activemq/tasks/apt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Install latest activemq from apt-get
apt:
name: activemq
state: present
update_cache: yes

37 changes: 37 additions & 0 deletions activemq/tasks/download.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
#To download activemq paackage
- name: Downloading amq-{{ amq_version }}
get_url:
url: "{{ amq_url }}"
dest: "{{ amq_install_dir }}/apache-activemq-{{ amq_version }}-bin.tar.gz"
force: no
# owner: "{{ amq_user }}"
# group: "{{ amq_group }}"
register: result
until: result|success
retries: 5
delay: 2

#Extracting the package
- name: Extracting downloaded package
unarchive:
src: "{{ amq_install_dir }}/apache-activemq-{{ amq_version }}-bin.tar.gz"
dest: "{{ amq_install_dir }}"
remote_src: true

- name: create user if not exist
user:
name: "{{ amq_user }}"
state: present

- name: Create user group if not exist
group: name={{ amq_group }} state=present

#File permissions
- name: Changing file permissions
file:
path: "{{ amq_install_dir }}/apache-activemq-{{ amq_version }}"
owner: "{{ amq_user }}"
group: "{{ amq_group }}"
recurse: yes

12 changes: 12 additions & 0 deletions activemq/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#Including required tasks
- include: apt.yml
when: amq_install_mode == "apt"

- include: download.yml
when: amq_install_mode == "tarball"

- include: service.yml
when: amq_service == "yes" and amq_install_mode == "tarball"

- include: start.yml
when: amq_service == "no" and amq_install_mode == "tarball"
42 changes: 42 additions & 0 deletions activemq/tasks/service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
#Creating activemq as service
- name: Creating activemq service script
copy:
src: "{{ amq_home_dir }}/bin/env"
dest: /etc/default/activemq
owner: root
group: root
mode: 0644

#Enter username value in 'env' file
#- name: Add username in env file
# command: sed -i '~s/^ACTIVEMQ_USER=""/ACTIVEMQ_USER="ubuntu"/' /etc/default/activemq
#- name: Adding username to run activemq
# lineinfile:
# name: /etc/default/activemq
# regexp: 'ACTIVEMQ_USER=" "'
# line: 'ACTIVEMQ_USER="{{ amq_user }}"'


- name: Copying env script to /etc/default
template:
src: env.j2
dest: /etc/default/activemq
owner: "{{ amq_user }}"
group: "{{ amq_group }}"
mode: 0644

#Create a link from activemq /etc/init.d
- name: Creating link to Init.d
file:
src: "{{ amq_home_dir }}/bin/activemq"
dest: "/etc/init.d/activemq"
owner: root
group: root
mode: 0755
state: link

#Enable activemq service in default run levels
- name: Enabling activemq service in defualt run levels
command: update-rc.d activemq defaults
notify: Starting amq service
6 changes: 6 additions & 0 deletions activemq/tasks/start.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- stat: path={{ amq_install_dir }}/apache-activemq-{{ amq_version }}
register: result

- debug: msg="Path exists and a directory"
notify: start amq
Loading

0 comments on commit c867dca

Please sign in to comment.