Skip to content

Commit

Permalink
Merge c44f885 into a6dfc72
Browse files Browse the repository at this point in the history
  • Loading branch information
pigmej committed Dec 4, 2015
2 parents a6dfc72 + c44f885 commit 72a68b2
Show file tree
Hide file tree
Showing 25 changed files with 1,489 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ env:
cache:
directories:
- $HOME/.pip-accel-cache
before_install:
- sudo apt-get update -qq
- sudo apt-get install -y libluajit-5.1-dev
install:
- pip install pip-accel
- pip-accel install coveralls
Expand Down
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ bunch
riak
# if you want to use sql backend then
# peewee


# if you want to use lua computable inputs
# lupa
6 changes: 6 additions & 0 deletions resources/riak_node_comp/actions/commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- hosts: [{{host}}]
sudo: yes
tasks:
# - shell: sleep 30
- shell: riak-admin cluster plan
- shell: riak-admin cluster commit
15 changes: 15 additions & 0 deletions resources/riak_node_comp/actions/join.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- hosts: [{{host}}]
sudo: yes
tasks:
- shell: riak-admin cluster join {{join_to}}
ignore_errors: true
register: join_output
# those below are hacky solution for "this node is already member of a cluster
# solar for now lacks logic that would allow to avoid it
- shell: /bin/true
when: join_output|failed and join_output.stdout.find("This node is already a member of a cluster") != -1
- shell: /bin/false
when: join_output|failed and join_output.stdout.find("This node is already a member of a cluster") == -1
- shell: /bin/true
when: join_output|success

6 changes: 6 additions & 0 deletions resources/riak_node_comp/actions/remove.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- hosts: [{{host}}]
sudo: yes
tasks:
- apt:
name: riak
state: absent
28 changes: 28 additions & 0 deletions resources/riak_node_comp/actions/run.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
- hosts: [{{host}}]
sudo: yes
tasks:
# those below are mostly for tests
- shell: killall -u riak
ignore_errors: yes
# remove above when non tests

# we install ubuntu repo there,
# NOT recommended on production
- shell: curl -s https://packagecloud.io/install/repositories/basho/riak/script.deb.sh | sudo bash

- apt:
name: riak
state: present
- service:
name: riak
state: stopped
- file: path=/etc/riak/riak.conf state=touch
- template:
src: {{templates_dir}}/riak.conf
dest: /etc/riak/riak.conf
- shell: rm -fr /var/lib/riak/kv_vnode/*
- shell: rm -fr /var/lib/riak/ring/*

- service:
name: riak
state: reloaded
143 changes: 143 additions & 0 deletions resources/riak_node_comp/actions/scripts/add_riak_repo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#!/bin/bash

unknown_os ()
{
echo "Unfortunately, your operating system distribution and version are not supported by this script."
echo "Please email support@packagecloud.io and we will be happy to help."
exit 1
}

curl_check ()
{
echo "Checking for curl..."
if command -v curl > /dev/null; then
echo "Detected curl..."
else
echo "Installing curl..."
apt-get install -q -y curl
fi
}

os=
dist=
host=

get_hostname ()
{
echo "Getting the hostname of this machine..."

host=`hostname -f 2>/dev/null`
if [ "$host" = "" ]; then
host=`hostname 2>/dev/null`
if [ "$host" = "" ]; then
host=$HOSTNAME
fi
fi

if [ "$host" = "" -o "$host" = "(none)" ]; then
echo "Unable to determine the hostname of your system!"
echo
echo "Please consult the documentation for your system. The files you need "
echo "to modify to do this vary between Linux distribution and version."
echo
exit 1
fi

echo "Found hostname: ${host}"
}


# some systems dont have lsb-release yet have the lsb_release binary and
# vice-versa
if [ -e /etc/lsb-release ]; then
. /etc/lsb-release
os=${DISTRIB_ID}
dist=${DISTRIB_CODENAME}

if [ -z "$dist" ]; then
dist=${DISTRIB_RELEASE}
fi

elif [ `which lsb_release 2>/dev/null` ]; then
dist=`lsb_release -c | cut -f2`
os=`lsb_release -i | cut -f2 | awk '{ print tolower($1) }'`

elif [ -e /etc/debian_version ]; then
# some Debians have jessie/sid in their /etc/debian_version
# while others have '6.0.7'
os=`cat /etc/issue | head -1 | awk '{ print tolower($1) }'`
if grep -q '/' /etc/debian_version; then
dist=`cut --delimiter='/' -f1 /etc/debian_version`
else
dist=`cut --delimiter='.' -f1 /etc/debian_version`
fi

else
unknown_os
fi

if [ -z "$dist" ]; then
unknown_os
fi

echo "Detected operating system as $os/$dist."

curl_check

echo -n "Installing apt-transport-https... "

# install apt-https-transport
apt-get install -y apt-transport-https &> /dev/null

echo "done."

get_hostname

apt_source_path="/etc/apt/sources.list.d/basho_riak.list"
apt_config_url="https://packagecloud.io/install/repositories/basho/riak/config_file.list?os=${os}&dist=${dist}&name=${host}&source=script"

echo -n "Installing $apt_source_path..."

# create an apt config file for this repository
curl -f "${apt_config_url}" > $apt_source_path
curl_exit_code=$?

if [ "$curl_exit_code" = "22" ]; then
echo -n "Unable to download repo config from: "
echo "${apt_config_url}"
echo
echo "Please contact support@packagecloud.io and report this."
[ -e $apt_source_path ] && rm $apt_source_path
exit 1
elif [ "$curl_exit_code" = "35" ]; then
echo "curl is unable to connect to packagecloud.io over TLS when running: "
echo " curl ${apt_config_url}"
echo "This is usually due to one of two things:"
echo
echo " 1.) Missing CA root certificates (make sure the ca-certificates package is installed)"
echo " 2.) An old version of libssl. Try upgrading libssl on your system to a more recent version"
echo
echo "Contact support@packagecloud.io with information about your system for help."
[ -e $apt_source_path ] && rm $apt_source_path
exit 1
elif [ "$curl_exit_code" -gt "0" ]; then
echo
echo "Unable to run: "
echo " curl ${apt_config_url}"
echo
echo "Double check your curl installation and try again."
[ -e $apt_source_path ] && rm $apt_source_path
exit 1
else
echo "done."
fi

echo -n "Importing packagecloud gpg key... "
# import the gpg key
curl https://packagecloud.io/gpg.key 2> /dev/null | apt-key add - &>/dev/null
echo "done."

echo -n "Running apt-get update... "
# update apt on this system
apt-get update &> /dev/null
echo "done."
12 changes: 12 additions & 0 deletions resources/riak_node_comp/actions/update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- hosts: [{{host}}]
sudo: yes
tasks:
- service:
name: riak
state: stopped
- template:
src: {{templates_dir}}/riak.conf
dest: /etc/riak/riak.conf
- service:
name: riak
state: reloaded
41 changes: 41 additions & 0 deletions resources/riak_node_comp/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
id: riak_node
handler: ansible
version: 1.0.0
actions:
commit: commit.yaml
run: run.yaml
join: join.yaml
input:
ip:
schema: str!
value:
riak_self_name:
schema: str!
value:
riak_hostname:
schema: str!
value:
riak_name:
schema: str!
value: null
computable:
lang: lua
type: full
func: |
local l = make_arr(data)
return l[resource_name]["riak_self_name"] .. "@" .. l[resource_name]["riak_hostname"]
riak_port_http:
schema: int!
value: 18098
riak_port_pb:
schema: int!
value: 18087
riak_port_solr:
schema: int!
value: 8985
join_to:
schema: str
value:
storage_backend:
schema: str!
value: bitcask
Loading

0 comments on commit 72a68b2

Please sign in to comment.