Giter VIP home page Giter VIP logo

ansible-mesos-playbook's Introduction

ansible-mesos-playbook

An ansible playbook for launching a mesos cluster with native docker and mesos executors, along with Marathon), Consul and HAProxy support. Run this on Ubuntu 14.04 LTS (preferred) or Centos/RHEL 6. Read the blog post for a descriptive overview.

Getting Started

  • Install ansible, version >= 1.7.
  • Install librarian-ansible via gem install librarian-ansible
  • Run librarian-ansible install
  • Spin up a bunch of Ubuntu 14.04 servers, say 5, on your favorite cloud provider.
  • cp hosts.sample hosts and update the mesos_masters and mesos_slaves groups.
  • cp ansible.cfg.sample ansible.cfg to ensure librarian_roles is in the ansible path (ansible.cfg is git-ignored).
  • Run ansible-playbook playbook.yml.

The Setup

  • zookeeper, haproxy, mesos-master, consul and marathon with ha mode run on nodes in the mesos_primaries group. The zoo_id host variable is used to configure zookeeper, and consul_bootstrap is set on one node to initialize the cluster.
  • mesos-slave runs in the mesos_workers group and are passed the list of mesos_primaries for coordination.
  • Docker and native mesos are configured as containerizers on mesos-slaves.
  • A cron job on each master is set up to query the marathon api and configure HAProxy.
  • HAProxy routes a frontend (listening on port 80) to backends based on marathon tasks.
  • Consul for service discovery. It's not hooked into any other services, just part of the default setup.
  • You probably want to tweak the HAProxy configuration script (in /opt/marathon/bin) for your needs. With the current setup you can have a wildcard dns prefix route to a backend matching the marathon name: i.e. www.example.com would do a least-connection proxy to the www task.

Altering the Playbook

There are a variety of tweaks you can make to this playbook for your needs.

  • Don't want Marathon, Consul or HAProxy? Simply remove roles from mesos_primaries.yml
  • Don't want to overload the primaries? Simply add new groups and remap roles appropriately.

Troubelshooting

If you have trouble, /var/log/syslog on Ubuntu and /var/log/messages on RHEL is your friend. For Zookeeper, try /var/log/zookeeper/zookeeper.log. You can try re-running the playbook; the roles aren't perfect but most are idempotent.

Ansible lets you perform actions on groups of servers. You can try query or restart zookeeper and/or mesos:

$ ansible mesos_primaries -a "sudo status zookeeper"
$ ansible mesos_primaries -a "sudo restart zookeeper"

Notes

Currently this installs Mesos 0.20.1 with Marathon 0.7.3.

Launching a Container

POST to /v2/apps:

{
    "id": "mlh", 
    "container": {
        "docker": {
            "image": "mhamrah/mesos-sample",
            "network": "BRIDGE",
            "portMappings": [
                { "containerPort": 8080, "hostPort": 0, "protocol": "tcp" }
            ]
        },
        "type": "DOCKER"
    },
    "cpus": 0.5,
    "mem": 512,
    "instances": 1
}

ansible-mesos-playbook's People

Contributors

adammeghji avatar jakedahn avatar maccam912 avatar mhamrah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-mesos-playbook's Issues

How to access things

Stupid newbie questions: When using this via vagrant, with vagrant up ... how do I go about getting started? Can I access some kind of web ui via some port, or do I need to call things from inside the box only?

ansible-playbook needs -u flag

I could clone the repo and submit a pull, but this is a small (mostly documentation?) item, at least in my environment (ubuntu 14.04 against ec2 instances from any user account that is not named ubuntu on the machine executing ansible-playbook) executing ansible-playbook requires the "-u ubuntu" flag.

Please add 'cache_valid_time' for 'update_cache=yes'

Confirm that the problem is Ubuntu

I got the msg "Could not fetch updated apt files", added 'cache_valid_time=3000' before

Line 7 in common.yml

I'm using ansible v1.9.2 on Ubuntu Server 14.04 to manage hosts running Ubuntu Server 14.04.

Update to the latest versions

Hi, this is very useful but getting to be over a year outdated. It would be nice if you updated the versions of mesos, marathon, docker, etc.

Cannot run librarian-ansible install.

Hi,

I installed ansible and librarian-ansible. I'm trying to run 'librarian-ansible install' but it keeps failing with the following error. Am i missing something here? the syntax of the Ansiblefile should be correct (i'm using the one from this playbook). Any help would be appreciated!

[root@svdpdac015 ansible-mesos-playbook]# librarian-ansible install
/root/ansible-mesos-playbook/Ansiblefile:7:in run': compile error (SyntaxError) /root/ansible-mesos-playbook/Ansiblefile:7: syntax error, unexpected ':', expecting $end github: "mhamrah/ansible-docker" ^ from /usr/lib64/ruby/gems/1.8/gems/librarian-0.1.2/lib/librarian/dsl.rb:79:inrun'
from /usr/lib64/ruby/gems/1.8/gems/librarian-0.1.2/lib/librarian/dsl.rb:73:in tap' from /usr/lib64/ruby/gems/1.8/gems/librarian-0.1.2/lib/librarian/dsl.rb:73:inrun'
from /usr/lib64/ruby/gems/1.8/gems/librarian-0.1.2/lib/librarian/dsl.rb:17:in run' from /usr/lib64/ruby/gems/1.8/gems/librarian-0.1.2/lib/librarian/environment.rb:148:indsl'
from /usr/lib64/ruby/gems/1.8/gems/librarian-0.1.2/lib/librarian/specfile.rb:15:in read' from /usr/lib64/ruby/gems/1.8/gems/librarian-0.1.2/lib/librarian/action/resolve.rb:17:inrun'
from /usr/lib64/ruby/gems/1.8/gems/librarian-0.1.2/lib/librarian/cli.rb:169:in resolve!' from /usr/lib64/ruby/gems/1.8/gems/librarian-ansible-1.0.6/lib/librarian/ansible/cli.rb:41:ininstall'
from /usr/lib64/ruby/gems/1.8/gems/thor-0.19.1/lib/thor/command.rb:27:in __send__' from /usr/lib64/ruby/gems/1.8/gems/thor-0.19.1/lib/thor/command.rb:27:inrun'
from /usr/lib64/ruby/gems/1.8/gems/thor-0.19.1/lib/thor/invocation.rb:126:in invoke_command' from /usr/lib64/ruby/gems/1.8/gems/thor-0.19.1/lib/thor.rb:359:indispatch'
from /usr/lib64/ruby/gems/1.8/gems/thor-0.19.1/lib/thor/base.rb:440:in start' from /usr/lib64/ruby/gems/1.8/gems/librarian-0.1.2/lib/librarian/cli.rb:26:inbin!'
from /usr/lib64/ruby/gems/1.8/gems/librarian-0.1.2/lib/librarian/cli.rb:31:in returning_status' from /usr/lib64/ruby/gems/1.8/gems/librarian-0.1.2/lib/librarian/cli.rb:26:inbin!'
from /usr/lib64/ruby/gems/1.8/gems/librarian-0.1.2/lib/librarian/cli.rb:47:in with_environment' from /usr/lib64/ruby/gems/1.8/gems/librarian-0.1.2/lib/librarian/cli.rb:26:inbin!'
from /usr/lib64/ruby/gems/1.8/gems/librarian-ansible-1.0.6/bin/librarian-ansible:7
from /usr/bin/librarian-ansible:23:in `load'
from /usr/bin/librarian-ansible:23
[root@svdpdac015 ansible-mesos-playbook]#

Sonali

fatal: [master1] => {'msg': "AnsibleUndefinedVariable: One or more undefined variables: 'dict object' has no attribute 'zoo_id'", 'failed': True}

@mhamrah thank you very much for the great job.
While trying to build the cluster, the following TASK fails:

[./librarian_roles/ansible-mesos | Create zookeeper config file] ******** 
TASK: [./librarian_roles/ansible-mesos | Create zookeeper config file] ******** 
fatal: [master1] => {'msg': "AnsibleUndefinedVariable: One or more undefined variables: 'dict object' has no attribute 'zoo_id'", 'failed': True}
fatal: [master1] => {'msg': "AnsibleUndefinedVariable: One or more undefined variables: 'dict object' has no attribute 'zoo_id'", 'failed': True}
fatal: [master2] => {'msg': "AnsibleUndefinedVariable: One or more undefined variables: 'dict object' has no attribute 'zoo_id'", 'failed': True}
fatal: [master2] => {'msg': "AnsibleUndefinedVariable: One or more undefined variables: 'dict object' has no attribute 'zoo_id'", 'failed': True}
fatal: [master3] => {'msg': "AnsibleUndefinedVariable: One or more undefined variables: 'dict object' has no attribute 'zoo_id'", 'failed': True}
fatal: [master3] => {'msg': "AnsibleUndefinedVariable: One or more undefined variables: 'dict object' has no attribute 'zoo_id'", 'failed': True}

FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/home/me/playbook.retry

master1               : ok=15   changed=6    unreachable=1    failed=0   
master2               : ok=15   changed=6    unreachable=1    failed=0   
master3               : ok=15   changed=6    unreachable=1    failed=0   

docker group problem

run into this problem on digitalocean

stderr: groupadd: group 'docker' already exists

Also, I needed to rename the "librarian-roles" directory to "roles" in order to make ansible run. Thanks for building this btw!

ansible-playbook search path for roles doesn't include librarian_roles

sym linking it fixed the issue, but using the instructions out of the readme result in the following error.

Workaround that seems to work: ln -s ./librarian_roles roles

Maybe a better solution is directing librarian to put stuff in roles (I don't know, I'm an ansible newbie)

ERROR: cannot find role in /home/vagrant/ansible-mesos-playbook/roles/ansible-docker or /home/vagrant/ansible-mesos-playbook/ansible-docker or /etc/ansible/roles/ansible-docker

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.