Skip to content
This repository has been archived by the owner on Feb 4, 2021. It is now read-only.

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
davidx committed Jun 16, 2015
1 parent b16a34b commit cd92977
Show file tree
Hide file tree
Showing 12 changed files with 478 additions and 0 deletions.
71 changes: 71 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
# defaults file for davidx.riak-simple
riak_version: "2.1.1"
riak_config:
search: 'on'
search.solr.port: '8093'
search.solr.jmx_port: '8985'
search.solr.jvm_options: '-Xms1g -Xmx1g -XX:+UseStringCache -XX:+UseCompressedOops'
search.root_dir: '/var/lib/riak/yz'
anti_entropy: 'active'
log.console: 'file'
log.console.level: 'info'
log.console.file: '/var/log/riak/console.log'
log.error.file: '/var/log/riak/error.log'
log.syslog: 'off'
listener.http.internal: '0.0.0.0:8098'
listener.protobuf.internal: '0.0.0.0:8087'
ring.state_dir: '/var/lib/riak/ring'
handoff.port: '8099'
dtrace: 'off'
platform_bin_dir: '/usr/sbin'
platform_data_dir: '/var/lib/riak'
platform_etc_dir: '/etc/riak'
platform_lib_dir: '/usr/lib/riak/lib'
platform_log_dir: '/var/log/riak'
log.crash.file: './log/crash.log'
log.crash.maximum_message_size: '64KB'
log.crash.size: '10MB'
log.crash.rotation: '$D0'
log.crash.rotation.keep: '5'
log.error.redirect: 'on'
log.error.messages_per_second: '100'
storage_backend: 'bitcask'
anti_entropy.tree.build_limit.number: '1'
anti_entropy.tree.build_limit.per_timespan: '1h'
anti_entropy.tree.expiry: '1w'
anti_entropy.concurrency_limit: '2'
anti_entropy.trigger_interval: '15s'
anti_entropy.data_dir: '/var/lib/riak/anti_entropy'
anti_entropy.write_buffer_size: '4MB'
anti_entropy.max_open_files: '20'
javascript.map_pool_size: '8'
javascript.reduce_pool_size: '6'
javascript.hook_pool_size: '2'
javascript.maximum_heap_size: '8'
javascript.maximum_stack_size: '16'
transfer_limit: '50000'
object.format: '1'
riak_control: 'on'
riak_control.auth.mode: 'userlist'
riak_control.auth.user.user.password: 'pass'
bitcask.data_root: '/var/lib/riak/bitcask'
bitcask.io_mode: 'erlang'
leveldb.data_root: '/var/lib/riak/leveldb'
leveldb.bloomfilter: 'on'
nodename: "riak@{{ riak_local_ip }}"
distributed_cookie: 'riak'
erlang.async_threads: '64'
erlang.max_ports: '64000'
erlang.crash_dump: '/var/log/riak/erl_crash.dump'
erlang.max_ets_tables: '256000'
erlang.process_limit: '256000'

riak_local_ip: "{{ ansible_default_ipv4['address'] }}"
riak_http_port: "{{ riak_config['listener.http.internal'].split(':')[1] }}"
riak_net_speed: 1Gb

ulimit:
riak: 128000

java_version: 8
4 changes: 4 additions & 0 deletions files/etc_security_limits.d_riak.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
riak soft nofile 65336
riak hard nofile 65336
root soft nofile 65336
root hard nofile 65336
25 changes: 25 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
# handlers file for davidx.riak-simple
- name: update sysctl
command: sysctl -e -p /etc/sysctl.d/riak.conf

- name: source rclocal
command: /bin/bash /etc/rc.local

- name: restart riak
service: name=riak state=restarted

- name: wait for http
wait_for: port={{ riak_http_port }}

- name: wait for kv
riak: wait_for_service=kv

- name: commit cluster changes
riak: command=commit

- name: wait for handoffs
riak: wait_for_handoffs=1200

- name: wait for ring
riak: wait_for_ring=600
126 changes: 126 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
---
galaxy_info:
author: Basho Devops <[email protected]>
description: Installs and configures Riak
company: Basho
license: Apache
min_ansible_version: 1.7

# Below are all platforms currently available. Just uncomment
# the ones that apply to your role. If you don't see your
# platform on this list, let us know and we'll get it added!
#
platforms:
- name: EL
versions:
# - all
# - 5
- 6
# - 7
#- name: GenericUNIX
# versions:
# - all
# - any
#- name: Fedora
# versions:
# - all
# - 16
# - 17
# - 18
# - 19
# - 20
# - 21
# - 22
#- name: SmartOS
# versions:
# - all
# - any
#- name: opensuse
# versions:
# - all
# - 12.1
# - 12.2
# - 12.3
# - 13.1
# - 13.2
#- name: Amazon
# versions:
# - all
# - 2013.03
# - 2013.09
#- name: GenericBSD
# versions:
# - all
# - any
#- name: FreeBSD
# versions:
# - all
# - 8.0
# - 8.1
# - 8.2
# - 8.3
# - 8.4
# - 9.0
# - 9.1
# - 9.1
# - 9.2
- name: Ubuntu
versions:
# - all
# - lucid
# - maverick
# - natty
# - oneiric
# - precise
# - quantal
# - raring
# - saucy
- trusty
# - utopic
# - vivid
#- name: SLES
# versions:
# - all
# - 10SP3
# - 10SP4
# - 11
# - 11SP1
# - 11SP2
# - 11SP3
#- name: GenericLinux
# versions:
# - all
# - any
#- name: Debian
# versions:
# - all
# - etch
# - jessie
# - lenny
# - squeeze
# - wheezy
#
# Below are all categories currently available. Just as with
# the platforms above, uncomment those that apply to your role.
#
#categories:
#- cloud
#- cloud:ec2
#- cloud:gce
#- cloud:rax
#- clustering
#- database
- database:nosql
#- database:sql
#- development
#- monitoring
#- networking
#- packaging
#- system
#- web
dependencies: []
# List your role dependencies here, one per line. Only
# dependencies available via galaxy should be listed here.
# Be sure to remove the '[]' above if you add dependencies
# to this list.

36 changes: 36 additions & 0 deletions tasks/Debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---

- name: install curl
apt: name=curl state=present update_cache=yes cache_valid_time=86400

- name: Setup Java repo
apt_repository: repo='ppa:webupd8team/java'

- name: Accept Java License
shell: 'echo "oracle-java{{ java_version }}-installer shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections'

- name: Install Java
apt: name={{ item }} state=present update_cache=yes
with_items:
- oracle-java{{ java_version }}-installer

- stat: path=/etc/apt/sources.list.d/basho_riak.list
register: basho_riak_repo_installed

- name: fetch repo script from packagecloud.io
get_url: url=https://packagecloud.io/install/repositories/basho/riak/script.deb.sh dest=/tmp/basho-repo.sh
when: not basho_riak_repo_installed.stat.exists

- name: Run repo installation script
shell: /bin/bash /tmp/basho-repo.sh
when: not basho_riak_repo_installed.stat.exists

- name: update pam configuration
lineinfile: line="session required pam_limits.so" dest={{ item }} regexp="session required pam_limits.so" insertafter="^# end of pam-auth-update config"
with_items:
- /etc/pam.d/common-session
- /etc/pam.d/common-session-noninteractive

- apt: name=riak={{riak_version}} state=present


47 changes: 47 additions & 0 deletions tasks/Redhat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
- name: fetch yum repository
get_url: url=http://mirror.pnl.gov/epel/6/i386/epel-release-6-8.noarch.rpm dest=/tmp

- name: configure the epel repository
yum: name=/tmp/epel-release-6-8.noarch.rpm


- name: install java
yum: name=java-1.8.0-openjdk

- stat: path=/etc/yum.repos.d/basho_riak.repo
register: basho_riak_repo_installed

- name: fetch the basho repo install script from packagecloud
get_url: url=https://packagecloud.io/install/repositories/basho/riak/script.rpm dest=/tmp/basho-repo.sh
when: not basho_riak_repo_installed.stat.exists

- name: Run repo installation script
shell: /bin/bash /tmp/basho-repo.sh
when: not basho_riak_repo_installed.stat.exists

- name: install libselinux-python
yum: name=libselinux-python state=present

#- name: set riak_ee fact
# set_fact: riak_ee=yes
# when: riak_package.find('ee') != -1

# CentOS specific package installations

# edit hosts file fix aws dns


- name: update limits
copy: src=etc_security_limits.d_riak.conf dest=/etc/security/limits.d/riak.conf owner=root group=root mode=0644


- name: create sysctl.d
file: dest=/etc/sysctl.d state=directory

- name: configure sysctl
template: src=etc_sysctl.d_riak.conf.j2 dest=/etc/sysctl.d/riak.conf owner=root group=root mode=0644
notify: update sysctl

- name: install riak
yum: name="{{ riak_package }}" state=present
5 changes: 5 additions & 0 deletions tasks/Ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: disable ufw
service: name=ufw state=stopped enabled=no
register: ufw_result
# failed_when: "ufw_result|failed and 'not found' not in ufw_result.msg"
50 changes: 50 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
- include_vars: vagrant.yml
when: ansible_ssh_user == 'vagrant'

- include_vars: Redhat.yml
when: ansible_os_family == "RedHat"

- include: RedHat.yml
when: ansible_os_family == "RedHat"

- include: Debian.yml
when: ansible_os_family == "Debian"

- include: Ubuntu.yml
when: ansible_distribution == "Ubuntu"

- name: copying custom beams
copy: src={{ item }} dest="{{ riak_patch_dir }}/"
with_fileglob:
- "{{riak_custom_beams_dir}}/*.beam"
when: riak_custom_beams_dir is defined
notify:
- restart riak
- wait for http
- wait for kv

- name: configure riak.conf
template: src=etc_riak_riak.conf.j2 dest=/etc/riak/riak.conf
tags: configfiles
notify:
- restart riak
- wait for http
- wait for kv

- name: fix aws hostname
lineinfile: dest=/etc/hosts line="{{ ansible_default_ipv4['address'] }} {{ hostvars[inventory_hostname]['ansible_nodename'] }} ip-{{ ansible_default_ipv4['address'] | regex_replace('\.', '-') }}"
when: '".ec2.internal" in ansible_nodename'

- name: start riak
service: name=riak enabled=yes state=started

- name: wait for port {{ riak_http_port }} to become active
wait_for: port={{ riak_http_port }}

- name: wait for riak_kv service to start
riak: wait_for_service=kv

- name: ping riak
riak: command=ping
register: info
4 changes: 4 additions & 0 deletions templates/etc_riak_riak.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## {{ ansible_managed }}
{% for config_item in riak_config %}
{{ config_item }} = {{ riak_config[config_item] }}
{% endfor %}
Loading

0 comments on commit cd92977

Please sign in to comment.