Skip to content

Commit

Permalink
Merge pull request #57 from basho-labs/small-fixes
Browse files Browse the repository at this point in the history
TravisCI, Remove obsolete code & fix packagecloud implementation
  • Loading branch information
christophermancini authored Oct 10, 2016
2 parents 4464591 + 31621a8 commit f00c1b0
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 69 deletions.
34 changes: 34 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
language: python
python: "2.7"

sudo: required
dist: trusty

addons:
hosts:
- riak-test

install:
- sudo apt-get install -y software-properties-common python-software-properties
- sudo add-apt-repository -y ppa:ansible/ansible
- sudo apt-get update -y
- sudo apt-get install -y ansible
- echo 'riak-test' | sudo tee -a /etc/ansible/hosts

# Check ansible version
- ansible --version

# Create ansible.cfg with correct roles_path
- 'printf "[defaults]\nroles_path=../" > ansible.cfg'

env:
- ANSIBLE_HOST_KEY_CHECKING=False

script:
- ansible-playbook tests/test.yml -v

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
slack:
secure: ZtgcjTxhTxrzWW6MIHLRtucW/BMm42RKS3nGRtSfgER9rx7oJ0Y9gOYkh1FM0GsM7Z11Q/iDhWs/8WTccAV0PrMZ6KHaq54wGmfYyqwPM4YreUwQ87PnOW4wZbl0TJTeWutasEwZvnVJ8VEyyQcS2PHt0zlsENn0XWvobvaZ+FM=
21 changes: 12 additions & 9 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,35 @@
riak_package: riak

riak_enterprise: false
riak_usr_lib: /usr/lib

riak_admin: '/usr/sbin/riak-admin'

riak_conf_template: riak.conf.j2

riak_node_name: 'riak@{{ ansible_fqdn }}'

riak_ring_size: 64

riak_backend: bitcask

riak_pb_bind_ip: 0.0.0.0
riak_pb_port: 8087

riak_http_bind_ip: 0.0.0.0
riak_http_port: 8098

riak_control: "off"
riak_search: "off"
riak_https_bind_ip: 0.0.0.0
riak_https_port: 10011

riak_ring_size: 64
riak_backend: bitcask
riak_control: 'off'
riak_search: 'off'

riak_leveldb_max_mem_percent: 70

riak_net_speed: 1Gb

riak_anti_entropy: active

riak_security_enabled: false

# riak_shell configuration
riak_shell_group: 'riak'
riak_shell_interface: 'ansible_eth0'
Expand Down Expand Up @@ -86,5 +88,6 @@ riak_scheduler: noop
# Create permission grants
#
#riak_grants:
# - {subject: 'user', bucket_type: 'certificate', bucket: '', permissions: ''}
# - {subject: 'group', bucket_type: 'password', bucket: '', permissions: ''}
# - {subject: 'all', scope: 'any', permissions: ''}
# - {subject: 'user', scope: 'mybuckettype', permissions: ''}
# - {subject: 'group', scope: 'mybuckettype mybucket', permissions: ''}
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ galaxy_info:
description: "Installs and configures Riak KV and TS, a distributed, highly available NoSQL and TimeSeries database."
company: Basho
license: Apache
min_ansible_version: 2.0
min_ansible_version: 2.1
platforms:
- name: EL
versions:
Expand Down
32 changes: 17 additions & 15 deletions tasks/Debian.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
---
- name: Include DEB vars
include_vars: Debian.yml
tags: Debian

- name: Install Pre-requisites
package: name={{ item }} state=present update_cache=yes cache_valid_time=3600
tags: Debian
with_items:
- curl
- apt-transport-https
- openjdk-7-jre
- default-jre

- name: Fetch ansible ansible_version
local_action: shell ansible --version
register: ans_ver
- name: Check if Riak is installed
stat: path=/etc/riak/riak.conf
register: dist

- name: Add Package Cloud repository key without validation
apt_key: url=https://packagecloud.io/gpg.key state=present validate_certs=no
tags: Debian
when: ans_ver.stdout.find(' 1.5.') > 0

- name: Add Package Cloud repository key with validation
apt_key: url=https://packagecloud.io/gpg.key state=present
tags: Debian
when: ans_ver.stdout.find(' 1.5.') < 0
when:
- not dist.stat.exists

- name: Add Basho Riak repository (hosted at Package Cloud)
template: src=deb_repo.list.j2 dest=/etc/apt/sources.list.d/basho_riak.list owner=root group=root mode=0644
when:
- not dist.stat.exists

- name: Install Riak for Debian
package: "name={{ riak_package }} state=present update_cache=yes"
tags: Debian
when: "'deb' not in riak_package"

- name: Install Riak for Debian
package: name={{ riak_package }} state=present update_cache=yes
apt: "deb={{ riak_package }}"
tags: Debian
when:
- "'deb' in riak_package"
- not dist.stat.exists

- name: Set the riak ulimit for Debian
copy: src=etc_default_riak_ulimit dest=/etc/default/riak owner=riak group=riak
Expand Down
7 changes: 2 additions & 5 deletions tasks/RedHat.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
---
- name: Include RHEL vars
include_vars: RedHat.yml
tags: RedHat

- name: "Install Java & libselinux-python"
package: "name={{ item }} state=present"
tags: RedHat
Expand All @@ -20,7 +16,8 @@
- name: Install package cloud repo if Riak is not already installed
command: '/tmp/packagecloud_rpm.sh'
tags: RedHat
when: not dist.stat.exists
when:
- not dist.stat.exists

- name: Install Riak for RedHat
package: "name={{ riak_package }} state=present"
Expand Down
27 changes: 4 additions & 23 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,42 +30,23 @@
template: src=etc_sysctl.d_riak.conf.j2 dest=/etc/sysctl.d/riak.conf owner=root group=root mode=0644

- name: copy custom beams
synchronize: src={{ riak_custom_beams_dir }} dest={{ riak_patch_dir }}
synchronize: "src={{ riak_custom_beams_dir }} dest={{ riak_patch_dir }}"
when: riak_custom_beams_dir is defined

- name: Check if this is first pass
stat: path=/etc/riak/riak.conf.dist
register: dist

- name: Check if this is first pass
stat: path=/etc/riak/riak_shell.config.dist
register: distts
when: riak_package == "riak-ts"

- name: preserve distribution copy of riak.conf if not already done
command: "cp -i /etc/riak/riak.conf /etc/riak/riak.conf.dist"
tags: configfiles
when: not dist.stat.exists

- name: preserve distribution copy of riak_shell.config if not already done
command: "cp -i /etc/riak/riak_shell.config /etc/riak/riak_shell.config.dist"
tags: configfiles
when: riak_package == "riak-ts" and not distts.stat.exists

- name: install riak.conf with templated configuration
template: src={{ riak_conf_template }} dest=/etc/riak/riak.conf owner=root group=root mode=0444
template: "src={{ riak_conf_template }} dest=/etc/riak/riak.conf owner=root group=root mode=0444 backup=yes"
notify: restart riak

- name: install riak_shell.config with templated configuration
template: src={{ riak_shell_conf_template }} dest=/etc/riak/riak_shell.config owner=root group=root mode=0444
template: "src={{ riak_shell_conf_template }} dest=/etc/riak/riak_shell.config owner=root group=root mode=0444"
when: riak_package == "riak-ts" and riak_shell_nodes is defined
notify: restart riak

- name: Make certain Riak is started and set to start on boot
service: name=riak enabled=yes state=started

- name: Wait for Riak to start up before continuing
wait_for: delay=5 timeout=30 host={{ riak_pb_bind_ip }} port={{ riak_pb_port }} state=started
wait_for: "delay=5 timeout=30 host={{ riak_pb_bind_ip }} port={{ riak_pb_port }} state=started"

- name: Bucket operations
include: buckets.yml
Expand Down
5 changes: 3 additions & 2 deletions tasks/security.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
- name: Enable Security
command: '{{ riak_admin }} security enable'
when: riak_security_enabled

- name: Create Groups
command: '{{ riak_admin }} security add-group {{ item }}'
Expand All @@ -15,14 +16,14 @@
- name: Create users
command: '{{ riak_admin }} security add-user {{ item.user }} password={{ item.password }}'
with_items: "{{ riak_users }}"
when: (riak_users is defined) and (riak_groups is not defined)
when: (riak_users is defined) and (riak_groups is not defined)

- name: Create security sources
command: '{{ riak_admin }} security add-source {{ item.user }} {{ item.cidr }} {{ item.type }}'
with_items: '{{ riak_sources }}'
when: riak_sources is defined

- name: Set security permissions
command: '{{ riak_admin }} security grant {{ item.permissions }} on {{ item.container }} to {{ item.subject }}'
command: '{{ riak_admin }} security grant {{ item.permissions }} on {{ item.scope }} to {{ item.subject }}'
with_items: '{{ riak_grants }}'
when: riak_grants is defined
16 changes: 8 additions & 8 deletions templates/packagecloud_rpm.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ main ()
curl_check


yum_repo_config_url="https://packagecloud.io/install/repositories/basho/{{ riak_package }}/config_file.repo?os=${os}&dist=${dist}&source=script"
yum_repo_config_url="https://packagecloud.io/install/repositories/basho/{% if 'riak-ts' in riak_package %}riak-ts{% else %}riak{% endif %}/config_file.repo?os=${os}&dist=${dist}&source=script"

yum_repo_path=/etc/yum.repos.d/basho_{{ riak_package }}.repo
yum_repo_path=/etc/yum.repos.d/basho_{% if 'riak-ts' in riak_package %}riak-ts{% else %}riak{% endif %}.repo

echo "Downloading repository file: ${yum_repo_config_url}"

Expand Down Expand Up @@ -141,7 +141,7 @@ main ()
fi

echo "Installing pygpgme to verify GPG signatures..."
yum install -y pygpgme --disablerepo='basho_{{ riak_package }}'
yum install -y pygpgme --disablerepo='basho_{% if 'riak-ts' in riak_package %}riak-ts{% else %}riak{% endif %}'
pypgpme_check=`rpm -qa | grep -qw pygpgme`
if [ "$?" != "0" ]; then
echo
Expand All @@ -152,11 +152,11 @@ main ()
echo

# set the repo_gpgcheck option to 0
sed -i'' 's/repo_gpgcheck=1/repo_gpgcheck=0/' /etc/yum.repos.d/basho_{{ riak_package }}.repo
sed -i'' 's/repo_gpgcheck=1/repo_gpgcheck=0/' /etc/yum.repos.d/basho_{% if 'riak-ts' in riak_package %}riak-ts{% else %}riak{% endif %}.repo
fi

echo "Installing yum-utils..."
yum install -y yum-utils --disablerepo='basho_{{ riak_package }}'
yum install -y yum-utils --disablerepo='basho_{% if 'riak-ts' in riak_package %}riak-ts{% else %}riak{% endif %}'
yum_utils_check=`rpm -qa | grep -qw yum-utils`
if [ "$?" != "0" ]; then
echo
Expand All @@ -165,11 +165,11 @@ main ()
echo
fi

echo "Generating yum cache for basho_{{ riak_package }}..."
yum -q makecache -y --disablerepo='*' --enablerepo='basho_{{ riak_package }}'
echo "Generating yum cache for basho_{% if 'riak-ts' in riak_package %}riak-ts{% else %}riak{% endif %}..."
yum -q makecache -y --disablerepo='*' --enablerepo='basho_{% if 'riak-ts' in riak_package %}riak-ts{% else %}riak{% endif %}'

echo
echo "The repository is setup! You can now install packages."
}

main
main
3 changes: 1 addition & 2 deletions templates/riak.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ listener.protobuf.internal = {{ riak_pb_bind_ip }}:{{ riak_pb_port }}
##
## Acceptable values:
## - an IP/port pair, e.g. 127.0.0.1:10011
## listener.https.internal = 127.0.0.1:8098
{% if not riak_security_enabled %}#{% endif %}listener.https.internal = {{ riak_https_bind_ip }}:{{ riak_https_port }}

## How Riak will repair out-of-sync keys. Some features require
## this to be set to 'active', including search.
Expand Down Expand Up @@ -501,4 +501,3 @@ search.solr.jmx_port = 8985
## Acceptable values:
## - text
search.solr.jvm_options = -d64 -Xms1g -Xmx1g -XX:+UseStringCache -XX:+UseCompressedOops

36 changes: 36 additions & 0 deletions tests/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
- hosts: riak-test
connection: local
become: yes
become_method: sudo
roles:
- ansible-riak
vars:
riak_node_name: "[email protected]"
riak_pb_bind_ip: 127.0.0.1
riak_pb_port: 8087
riak_http_bind_ip: 127.0.0.1
riak_http_port: 8098

riak_bucket_types:
- { name: counters, props: '{"props":{"datatype":"counter"}}' }
- { name: maps, props: '{"props":{"datatype":"map"}}' }
- { name: sets, props: '{"props":{"datatype":"set"}}' }

riak_users:
- {user: 'riakuser', password: '', cert: '', groups: ''}
- {user: 'riakpass', password: 'Test1234', cert: '', groups: ''}
- {user: 'riakadmin', password: '', cert: '', groups: 'admins'}
- {user: 'riakdeveloper', password: '', cert: '', groups: 'developers'}

riak_groups:
- admins
- developers

riak_sources:
- {user: 'riakuser', type: 'certificate', cidr: '0.0.0.0/0'}
- {user: 'riakpass', type: 'password', cidr: '0.0.0.0/0'}

riak_grants:
- {subject: 'riakuser', scope: 'any', permissions: 'riak_kv.get,riak_kv.put'}
- {subject: 'riakpass', scope: 'any', permissions: 'riak_kv.get,riak_kv.put'}
2 changes: 0 additions & 2 deletions vars/Debian.yml

This file was deleted.

2 changes: 0 additions & 2 deletions vars/RedHat.yml

This file was deleted.

0 comments on commit f00c1b0

Please sign in to comment.