├── vars ├── main.yml ├── Debian.yml └── RedHat.yml ├── .gitignore ├── tasks ├── common.yml ├── main.yml ├── RedHat.yml ├── Debian.yml └── mesos.yml ├── templates ├── mesos.pref.j2 ├── conf-mesos-master.j2 ├── mesos-master.service.j2 ├── mesos-slave.service.j2 ├── init-mesos-slave.j2 ├── init-mesos-master.j2 ├── conf-mesos-slave.j2 └── conf-mesos.j2 ├── tests ├── playbook.yml ├── test.yml └── dependencies.yml ├── .github └── pull_request_template.md ├── handlers └── main.yml ├── meta └── main.yml ├── Vagrantfile ├── defaults └── main.yml ├── .travis.yml ├── README.md └── LICENSE /vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant/ 2 | -------------------------------------------------------------------------------- /vars/Debian.yml: -------------------------------------------------------------------------------- 1 | platform_url_name: "ubuntu" 2 | package_type: "deb" 3 | -------------------------------------------------------------------------------- /tasks/common.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - debug: msg="Install Mode is {{mesos_install_mode}}" 3 | -------------------------------------------------------------------------------- /templates/mesos.pref.j2: -------------------------------------------------------------------------------- 1 | Package: mesos 2 | Pin: version {{ mesos_package_full_version }} 3 | Pin-Priority: {{ mesos_apt_pin_priority }} 4 | -------------------------------------------------------------------------------- /tests/playbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | connection: local 4 | remote_user: root 5 | roles: 6 | - role: role_under_test 7 | mesos_install_mode: "master-slave" 8 | -------------------------------------------------------------------------------- /vars/RedHat.yml: -------------------------------------------------------------------------------- 1 | os_version_major: "{{ ansible_distribution_major_version }}" 2 | 3 | # Mesosphere released packaged per OS version 4 | mesosphere_releases: 5 | '6': 'mesosphere-el-repo-6-3.noarch.rpm' 6 | '7': 'mesosphere-el-repo-7-1.noarch.rpm' 7 | 8 | -------------------------------------------------------------------------------- /templates/conf-mesos-master.j2: -------------------------------------------------------------------------------- 1 | # {{ansible_managed}} 2 | 3 | export MESOS_QUORUM="{{ mesos_quorum }}" 4 | export MESOS_WORK_DIR="{{ mesos_work_dir }}" 5 | export MESOS_PORT="{{ mesos_master_port }}" 6 | 7 | # Additional configs 8 | {% for config_item in mesos_master_additional_configs %} 9 | export {{mesos_option_prefix}}{{config_item.name}}={{config_item.value}} 10 | {% endfor %} 11 | -------------------------------------------------------------------------------- /templates/mesos-master.service.j2: -------------------------------------------------------------------------------- 1 | # {{ansible_managed}} 2 | 3 | [Unit] 4 | Description=mesos master 5 | After=network.target 6 | Wants=network.target 7 | 8 | [Service] 9 | ExecStart=/usr/bin/mesos-init-wrapper master 10 | Restart=always 11 | RestartSec=20 12 | TimeoutSec=300 13 | User={{ mesos_owner }} 14 | Group={{ mesos_group }} 15 | 16 | [Install] 17 | WantedBy=multi-user.target 18 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Here we are using the debian package if debian 3 | - include_vars: "{{ ansible_os_family }}.yml" 4 | 5 | - include: common.yml 6 | 7 | # Here we are using the debian package if debian 8 | - include: Debian.yml 9 | when: ansible_os_family == "Debian" 10 | 11 | - include: RedHat.yml 12 | when: ansible_os_family == "RedHat" 13 | 14 | - include: mesos.yml tags=configuration 15 | -------------------------------------------------------------------------------- /templates/mesos-slave.service.j2: -------------------------------------------------------------------------------- 1 | # {{ansible_managed}} 2 | 3 | [Unit] 4 | Description=mesos slave 5 | After=network.target 6 | Wants=network.target 7 | 8 | [Service] 9 | ExecStart=/usr/bin/mesos-init-wrapper slave 10 | KillMode=process 11 | Restart=always 12 | RestartSec=20 13 | TimeoutSec=300 14 | User={{ mesos_owner }} 15 | Group={{ mesos_group }} 16 | 17 | [Install] 18 | WantedBy=multi-user.target 19 | -------------------------------------------------------------------------------- /tests/test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | connection: local 4 | remote_user: root 5 | tasks: 6 | - shell: "ps aux | grep -i mesos" 7 | register: status 8 | failed_when: status.rc != 0 9 | when: ansible_service_mgr != 'systemd' 10 | 11 | - shell: "systemctl status mesos-master | grep running" 12 | register: status 13 | failed_when: status.rc != 0 14 | when: ansible_service_mgr == 'systemd' 15 | -------------------------------------------------------------------------------- /templates/init-mesos-slave.j2: -------------------------------------------------------------------------------- 1 | # {{ansible_managed}} 2 | 3 | description "mesos slave" 4 | 5 | # Start just after the System-V jobs (rc) to ensure networking and zookeeper 6 | # are started. This is as simple as possible to ensure compatibility with 7 | # Ubuntu, Debian, CentOS, and RHEL distros. See: 8 | # http://upstart.ubuntu.com/cookbook/#standard-idioms 9 | start on stopped rc RUNLEVEL=[2345] 10 | respawn 11 | 12 | exec /usr/bin/mesos-init-wrapper slave 13 | -------------------------------------------------------------------------------- /templates/init-mesos-master.j2: -------------------------------------------------------------------------------- 1 | # {{ansible_managed}} 2 | 3 | description "mesos master" 4 | 5 | # Start just after the System-V jobs (rc) to ensure networking and zookeeper 6 | # are started. This is as simple as possible to ensure compatibility with 7 | # Ubuntu, Debian, CentOS, and RHEL distros. See: 8 | # http://upstart.ubuntu.com/cookbook/#standard-idioms 9 | start on stopped rc RUNLEVEL=[2345] 10 | respawn 11 | 12 | exec /usr/bin/mesos-init-wrapper master 13 | -------------------------------------------------------------------------------- /tasks/RedHat.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Add mesosphere repo 3 | yum: name={{ mesosphere_yum_repo }} state=present 4 | 5 | - name: Downloading and enable the EPEL repository definitions. 6 | yum: name={{ epel_repo }} state=present 7 | 8 | - name: Install os packages 9 | yum: name={{item}} state=present 10 | with_items: 11 | - wget 12 | - curl 13 | - unzip 14 | - libselinux-python 15 | - python-setuptools 16 | - mesos-{{mesos_version}} 17 | 18 | -------------------------------------------------------------------------------- /templates/conf-mesos-slave.j2: -------------------------------------------------------------------------------- 1 | # {{ansible_managed}} 2 | 3 | export MESOS_MASTER="{{ mesos_zookeeper_masters }}" 4 | export MESOS_CONTAINERIZERS="{{ mesos_containerizers }}" 5 | export MESOS_EXECUTOR_REGISTRATION_TIMEOUT="{{ mesos_executor_timeout }}" 6 | export MESOS_PORT="{{ mesos_slave_port }}" 7 | export MESOS_WORK_DIR="{{ mesos_work_dir }}" 8 | 9 | # Additional configs 10 | {% for config_item in mesos_slave_additional_configs %} 11 | export {{mesos_option_prefix}}{{config_item.name}}={{config_item.value}} 12 | {% endfor %} 13 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ### Short description: 2 | 3 | I found the following issue(s) or bug(s): 4 | - 5 | 6 | _And/OR_ 7 | 8 | I found that the following _enhancement_ is worthwhile: 9 | - 10 | 11 | 12 | ### Bookkeeping 13 | I did the following bookkeeping: 14 | - [ ] If a major change, bumped the playbook version in `vars/` 15 | - [ ] Added as much documentation as I could (we're not looking a book, just enough to help others) 16 | - [ ] Confirmed that the PR works by running the vagrant tests (if any) and/or added to the tests (see `ci/` or legacy `tests/`) 17 | - [ ] Followed up with any automated test results as a result of the pull request 18 | -------------------------------------------------------------------------------- /tests/dependencies.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | connection: local 4 | remote_user: root 5 | tasks: 6 | - name: installing repo for Java 8 in Ubuntu 7 | apt_repository: repo='ppa:openjdk-r/ppa' 8 | when: 9 | - ansible_os_family == 'Debian' 10 | 11 | - hosts: localhost 12 | connection: local 13 | remote_user: root 14 | roles: 15 | - role: geerlingguy.java 16 | java_packages: 17 | - openjdk-8-jdk 18 | when: ansible_os_family == 'Debian' 19 | 20 | - role: geerlingguy.java 21 | java_packages: 22 | - java-1.8.0-openjdk 23 | when: ansible_os_family == 'RedHat' 24 | 25 | - role: AnsibleShipyard.ansible-zookeeper 26 | -------------------------------------------------------------------------------- /tasks/Debian.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Add apt-key 3 | apt_key: id=E56151BF keyserver=keyserver.ubuntu.com state=present 4 | 5 | - name: Add mesosphere repo 6 | apt_repository: repo='deb {{ mesosphere_apt_url }} {{ ansible_distribution_release | lower }} main' state=present update_cache=yes 7 | 8 | - name: Pin Mesos version 9 | template: 10 | src: mesos.pref.j2 11 | dest: /etc/apt/preferences.d/mesos.pref 12 | when: mesos_apt_pin_priority | default(false) | bool 13 | 14 | - name: Install Debian OS packages 15 | apt: pkg={{ item }} state=present update_cache=yes cache_valid_time=3600 16 | with_items: 17 | - wget 18 | - curl 19 | - unzip 20 | - python-setuptools 21 | - python-dev 22 | - "{{ mesos_apt_package }}" 23 | -------------------------------------------------------------------------------- /handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # While waiting for https://github.com/ansible/ansible-modules-core/issues/191 4 | - name: Reload daemon 5 | command: systemctl daemon-reload 6 | when: ansible_service_mgr == 'systemd' 7 | 8 | - name: Cleanup meta/slaves/latest 9 | file: path="{{mesos_work_dir}}/meta/slaves/latest" state=absent 10 | when: 11 | - mesos_install_mode == "slave" or mesos_install_mode == "master-slave" 12 | - mesos_agent_meta_cleanup | bool 13 | 14 | # i.e. upgrade mesos, templates stay the same... 15 | - name: Restart mesos-master 16 | service: name=mesos-master state=restarted 17 | when: mesos_install_mode == "master" or mesos_install_mode == "master-slave" 18 | 19 | - name: Restart mesos-slave 20 | service: name=mesos-slave state=restarted 21 | when: mesos_install_mode == "slave" or mesos_install_mode == "master-slave" 22 | -------------------------------------------------------------------------------- /templates/conf-mesos.j2: -------------------------------------------------------------------------------- 1 | # {{ansible_managed}} 2 | 3 | # special options supported by 4 | # mesos-init-wrapper 5 | CLUSTER="{{mesos_cluster_name}}" 6 | IP={{mesos_ip}} 7 | LOGS={{mesos_log_location}} 8 | ULIMIT="{{mesos_ulimit}}" 9 | ZK="{{ mesos_zookeeper_masters }}" 10 | 11 | {% if mesos_ssl_enabled %} 12 | export LIBPROCESS_SSL_ENABLED=true 13 | export LIBPROCESS_SSL_SUPPORT_DOWNGRADE={{ mesos_ssl_support_downgrade | ternary('true', 'false')}} 14 | export LIBPROCESS_SSL_KEY_FILE={{ mesos_ssl_key_file }} 15 | export LIBPROCESS_SSL_CERT_FILE={{ mesos_ssl_cert_file }} 16 | export LIBPROCESS_SSL_VERIFY_CERT=false 17 | export LIBPROCESS_SSL_REQUIRE_CERT=false 18 | 19 | {% endif %} 20 | # mesos env variables 21 | # see http://mesos.apache.org/documentation/latest/configuration/ 22 | export MESOS_HOSTNAME="{{ mesos_hostname }}" 23 | 24 | # Additional configs 25 | export MESOS_OPTION_PREFIX={{mesos_option_prefix}} 26 | {% for config_item in mesos_additional_configs %} 27 | export {{mesos_option_prefix}}{{config_item.name}}={{config_item.value}} 28 | {% endfor %} 29 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: Jason Giedymin 4 | description: Ansible Mesos Playbook Role 5 | company: http://jasongiedymin.com 6 | license: Apache 2 7 | min_ansible_version: 1.7 8 | # 9 | # Below are all platforms currently available. Just uncomment 10 | # the ones that apply to your role. If you don't see your 11 | # platform on this list, let us know and we'll get it added! 12 | # 13 | platforms: 14 | - name: EL 15 | versions: 16 | - 6 17 | - 7 18 | #- name: GenericUNIX 19 | # versions: 20 | # - all 21 | # - any 22 | #- name: Fedora 23 | # versions: 24 | # - all 25 | # - 16 26 | # - 17 27 | # - 18 28 | # - 19 29 | # - 20 30 | #- name: opensuse 31 | # versions: 32 | # - all 33 | # - 12.1 34 | # - 12.2 35 | # - 12.3 36 | # - 13.1 37 | # - 13.2 38 | #- name: GenericBSD 39 | # versions: 40 | # - all 41 | # - any 42 | #- name: FreeBSD 43 | # versions: 44 | # - all 45 | # - 8.0 46 | # - 8.1 47 | # - 8.2 48 | # - 8.3 49 | # - 8.4 50 | # - 9.0 51 | # - 9.1 52 | # - 9.1 53 | # - 9.2 54 | - name: Ubuntu 55 | versions: 56 | - trusty 57 | - wily 58 | - xenial 59 | #- name: SLES 60 | # versions: 61 | # - all 62 | # - 10SP3 63 | # - 10SP4 64 | # - 11 65 | # - 11SP1 66 | # - 11SP2 67 | # - 11SP3 68 | #- name: GenericLinux 69 | # versions: 70 | # - all 71 | # - any 72 | - name: Debian 73 | versions: 74 | - all 75 | - etch 76 | - lenny 77 | - squeeze 78 | - wheezy 79 | 80 | # Below are all categories currently available. Just as with 81 | # the platforms above, uncomment those that apply to your role. 82 | # 83 | categories: 84 | - system 85 | - platform 86 | dependencies: [] 87 | # - ansible-java 88 | # - ansible-scala 89 | # - ansible-sbt 90 | # List your role dependencies here, one per line. Only 91 | # dependencies available via galaxy should be listed here. 92 | # Be sure to remove the '[]' above if you add dependencies 93 | # to this list. 94 | 95 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | config.ssh.forward_agent = true 6 | config.vm.synced_folder Dir.getwd, "/home/vagrant/roles/ansible-mesos", nfs: true 7 | 8 | # ubuntu 12.04 that Travis CI is using 9 | config.vm.define 'travis', primary: true do |c| 10 | c.vm.network "private_network", ip: "192.168.100.2" 11 | c.vm.box = "precise-server-cloudimg-amd64-vagrant-disk1" 12 | c.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box" 13 | c.vm.provision "shell" do |s| 14 | s.inline = "apt-get update -y; apt-get install python-software-properties; add-apt-repository ppa:rquillo/ansible; apt-get update -y; apt-get install ansible -y" 15 | s.privileged = true 16 | end 17 | end 18 | 19 | # ubuntu 14.04 20 | config.vm.define 'ubuntu', primary: true do |c| 21 | c.vm.network "private_network", ip: "192.168.100.3" 22 | c.vm.box = "trusty-server-cloudimg-amd64-vagrant-disk1" 23 | c.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box" 24 | c.vm.provision "shell" do |s| 25 | s.inline = "apt-get update -y; apt-get install -y software-properties-common; apt-add-repository ppa:ansible/ansible; apt-get update -y; apt-get install -y ansible" 26 | s.privileged = true 27 | end 28 | end 29 | 30 | # centos 6: 31 | config.vm.define 'centos' do |c| 32 | c.vm.network "private_network", ip: "192.168.100.4" 33 | c.vm.box = "centos65-x86_64-20140116" 34 | c.vm.box_url = "https://github.com/2creatives/vagrant-centos/releases/download/v6.5.3/centos65-x86_64-20140116.box" 35 | c.vm.provision "shell" do |s| 36 | s.inline = "yum update gmp; yum install ansible -y" 37 | s.privileged = true 38 | end 39 | end 40 | 41 | # centos 7: 42 | config.vm.define 'centos7' do |c| 43 | c.vm.network "private_network", ip: "192.168.100.5" 44 | c.vm.box = "centos/7" 45 | c.vm.provision "shell" do |s| 46 | s.inline = "yum install -y epel-release; yum install -y ansible" 47 | s.privileged = true 48 | end 49 | end 50 | 51 | end 52 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | mesos_install_mode: "master" # {master|slave|master-slave} 3 | mesos_version: "1.1.0" 4 | 5 | mesos_repo_host: repos.mesosphere.com 6 | 7 | # Debian 8 | mesos_package_version: "2.0.107" 9 | mesos_os_distribution: "{{ ansible_distribution | lower }}" 10 | mesos_os_version: "{{ ansible_distribution_version.split('.') | join('') }}" 11 | mesos_package_full_version: "{{ mesos_version }}-{{ mesos_package_version }}.{{ mesos_os_distribution }}{{ mesos_os_version }}" 12 | mesosphere_apt_url: "http://{{ mesos_repo_host }}/{{ ansible_distribution | lower }}" 13 | mesos_apt_package: "mesos={{ mesos_package_full_version }}" 14 | 15 | # RedHat: EPEL and Mesosphere yum repositories URL 16 | epel_repo: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ os_version_major }}.noarch.rpm" 17 | mesosphere_yum_repo: "https://{{ mesos_repo_host }}/el/{{ os_version_major }}/noarch/RPMS/{{ mesosphere_releases[os_version_major] }}" 18 | 19 | # conf file settings 20 | mesos_cluster_name: "mesos_cluster" 21 | mesos_ip: "{{ ansible_default_ipv4.address }}" 22 | mesos_hostname: "{{ ansible_hostname }}" 23 | mesos_master_port: "5050" 24 | mesos_slave_port: "5051" 25 | mesos_log_location: "/var/log/mesos" 26 | mesos_ulimit: "-n 8192" 27 | mesos_work_dir: "/var/mesos" 28 | mesos_quorum: "1" 29 | zookeeper_client_port: "2181" 30 | zookeeper_hostnames: "{{ mesos_hostname }}:{{ zookeeper_client_port }}" 31 | mesos_zookeeper_masters: "zk://{{ zookeeper_hostnames }}/mesos" 32 | mesos_owner: root 33 | mesos_group: root 34 | 35 | # Containerizer 36 | mesos_containerizers: "docker,mesos" 37 | mesos_executor_timeout: "5mins" 38 | 39 | # SSL 40 | mesos_ssl_enabled: false 41 | mesos_ssl_support_downgrade: false 42 | 43 | # If 'true' cleans symlink 'meta/slaves/latest' to avoid mesos-slave restart failures on config changes 44 | mesos_agent_meta_cleanup: false 45 | 46 | mesos_option_prefix: "MESOS_" 47 | 48 | # Additional configurations 49 | mesos_additional_configs: [] 50 | # For example: 51 | # - name: FOO 52 | # value: bar 53 | 54 | # Additional configurations for master 55 | mesos_master_additional_configs: [] 56 | # For example: 57 | # - name: FOO 58 | # value: bar 59 | 60 | # Additional configurations for slave 61 | mesos_slave_additional_configs: [] 62 | # For example: 63 | # - name: FOO 64 | # value: bar 65 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | 3 | env: 4 | matrix: 5 | - distro: ernestasposkus/centos7 6 | init: /usr/lib/systemd/systemd 7 | run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" 8 | - distro: ernestasposkus/centos6 9 | init: /sbin/init 10 | run_opts: "" 11 | - distro: ernestasposkus/ubuntu1604 12 | init: /lib/systemd/systemd 13 | run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" 14 | - distro: ernestasposkus/ubuntu1404 15 | init: /sbin/init 16 | run_opts: "" 17 | 18 | services: 19 | - docker 20 | 21 | before_install: 22 | - sudo apt-get update 23 | # Pull container. 24 | - 'sudo docker pull ${distro}:latest' 25 | 26 | script: 27 | - container_id=$(mktemp) 28 | # Run container in detached state. 29 | - 'sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} ${distro}:latest "${init}" > "${container_id}"' 30 | 31 | # Inspect docker container 32 | - 'sudo docker inspect $(cat ${container_id})' 33 | 34 | # Print ansible version 35 | - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible --version' 36 | 37 | # Check Ansible host setup 38 | - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible all -i "localhost," -c local -m setup' 39 | 40 | # Install dependencies 41 | - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-galaxy install geerlingguy.java' 42 | - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-galaxy install AnsibleShipyard.ansible-zookeeper' 43 | - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/dependencies.yml' 44 | 45 | # Ansible syntax check. 46 | - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/playbook.yml --syntax-check' 47 | 48 | # Test role. 49 | - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/playbook.yml' 50 | 51 | # Test role idempotence. 52 | - idempotence=$(mktemp) 53 | - sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/playbook.yml | tee -a ${idempotence} 54 | - > 55 | tail ${idempotence} 56 | | grep -q 'changed=0.*failed=0' 57 | && (echo 'Idempotence test: pass' && exit 0) 58 | || (echo 'Idempotence test: fail' && exit 1) 59 | 60 | # Test role. 61 | - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml' 62 | 63 | # View container logs 64 | - 'sudo docker logs "$(cat ${container_id})"' 65 | 66 | # Clean up. 67 | - 'sudo docker stop "$(cat ${container_id})"' 68 | 69 | notifications: 70 | webhooks: https://galaxy.ansible.com/api/v1/notifications/ - "curl http://localhost:5050/" 71 | -------------------------------------------------------------------------------- /tasks/mesos.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # == Work Dir for replicated log 3 | - name: create work dir 4 | file: path={{ mesos_work_dir }} state=directory 5 | 6 | # == Remove default configs 7 | - name: Remove Default Mesos Configs 8 | file: state=absent path=/etc/mesos/ 9 | 10 | - name: Remove Mesos ZK File 11 | file: state=absent path=/etc/mesos/zk 12 | 13 | - name: Remove Default Mesos-Master Config 14 | file: state=absent path=/etc/mesos-master/ 15 | 16 | - name: Remove Default Mesos-Slave Config 17 | file: state=absent path=/etc/mesos-slave/ 18 | 19 | # == Configure and recreate 20 | - name: Mesos default config file 21 | template: src=conf-mesos.j2 dest=/etc/default/mesos 22 | notify: 23 | - Restart mesos-master 24 | - Restart mesos-slave 25 | - Cleanup meta/slaves/latest 26 | 27 | - name: Mesos Master config file 28 | template: src=conf-mesos-master.j2 dest=/etc/default/mesos-master 29 | when: mesos_install_mode == "master" or mesos_install_mode == "master-slave" 30 | notify: 31 | - Restart mesos-master 32 | 33 | - name: Mesos Slave config file 34 | template: src=conf-mesos-slave.j2 dest=/etc/default/mesos-slave 35 | when: mesos_install_mode == "slave" or mesos_install_mode == "master-slave" 36 | notify: 37 | - Restart mesos-slave 38 | - Cleanup meta/slaves/latest 39 | 40 | - name: Mesos master upstart script 41 | template: src=init-mesos-master.j2 dest=/etc/init/mesos-master.conf 42 | when: 43 | - (mesos_install_mode == "master" or mesos_install_mode == "master-slave") 44 | - ansible_service_mgr != 'systemd' 45 | notify: 46 | - Restart mesos-master 47 | 48 | - name: Mesos slave upstart script 49 | template: src=init-mesos-slave.j2 dest=/etc/init/mesos-slave.conf 50 | when: 51 | - (mesos_install_mode == "slave" or mesos_install_mode == "master-slave") 52 | - ansible_service_mgr != 'systemd' 53 | notify: 54 | - Restart mesos-slave 55 | 56 | - name: Check if systemd exists 57 | stat: path=/lib/systemd/system/ 58 | register: systemd_check 59 | 60 | - name: Mesos master systemd script 61 | template: src=mesos-master.service.j2 dest=/lib/systemd/system/mesos-master.service 62 | when: (mesos_install_mode == "master" or mesos_install_mode == "master-slave") and systemd_check.stat.exists == true 63 | notify: 64 | - Reload daemon 65 | - Restart mesos-master 66 | 67 | - name: Mesos slave systemd script 68 | template: src=mesos-slave.service.j2 dest=/lib/systemd/system/mesos-slave.service 69 | when: (mesos_install_mode == "slave" or mesos_install_mode == "master-slave") and systemd_check.stat.exists == true 70 | notify: 71 | - Reload daemon 72 | - Restart mesos-slave 73 | 74 | - name: Enable/Disable mesos-master service 75 | service: name=mesos-master enabled="{{ (mesos_install_mode == 'slave') | ternary('no', 'yes') }}" 76 | when: systemd_check.stat.exists == true 77 | 78 | - name: Enable/Disable mesos-slave service 79 | service: name=mesos-slave enabled="{{ (mesos_install_mode == 'master') | ternary('no', 'yes') }}" 80 | when: systemd_check.stat.exists == true 81 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ansible-mesos - Ansible Playbook for Mesos 2 | ============= 3 | 4 | [![Build Status](https://travis-ci.org/AnsibleShipyard/ansible-mesos.svg?branch=master)](https://travis-ci.org/AnsibleShipyard/ansible-mesos) 5 | 6 | The ansible-mesos role supports the installation and configuration of a mesos cluster with options for master, slave or a master-slave setup. It supports Ubuntu and RedHat/Centos. 7 | 8 | It also allows the setting of specific slave executors so you can run with native docker support. 9 | 10 | Installation 11 | ----------- 12 | 13 | ```bash 14 | ansible-galaxy install JasonGiedymin.mesos 15 | ``` 16 | 17 | Dependencies 18 | ------------ 19 | 20 | Java and Zookeeper 21 | 22 | - https://github.com/geerlingguy/ansible-role-java OR https://github.com/AnsibleShipyard/ansible-java 23 | - https://github.com/AnsibleShipyard/ansible-zookeeper 24 | 25 | Requirements 26 | ------------ 27 | 28 | Ansible version at least 1.7 29 | 30 | Role Variables 31 | -------------- 32 | 33 | ```yaml 34 | --- 35 | mesos_install_mode: "master" # {master|slave|master-slave} 36 | mesos_version: "1.0.1" 37 | 38 | # Debian 39 | mesos_package_version: "2.0.93" 40 | mesos_os_distribution: "{{ ansible_distribution | lower }}" 41 | mesos_os_version: "{{ ansible_distribution_version.split('.') | join('') }}" 42 | mesos_apt_url: "http://{{ mesos_repo_host }}/{{ ansible_distribution | lower }}" 43 | mesos_package_full_version: "{{ mesos_version }}-{{ mesos_package_version }}.{{ mesos_os_distribution }}{{ mesos_os_version }}" 44 | mesos_apt_package: "mesos={{ mesos_package_full_version }}" 45 | 46 | # RedHat: EPEL and Mesosphere yum repositories URL 47 | epel_repo: "https://dl.fedoraproject.org/pub/epel/{{ os_version_major }}/{{ ansible_architecture }}/{{ epel_releases[os_version_major] }}" 48 | mesosphere_yum_repo: "https://repos.mesosphere.com/el/{{ os_version_major }}/noarch/RPMS/{{ mesosphere_releases[os_version_major] }}" 49 | 50 | # conf file settings 51 | mesos_cluster_name: "mesos_cluster" 52 | mesos_ip: "{{ ansible_default_ipv4.address }}" 53 | mesos_hostname: "{{ ansible_hostname }}" 54 | mesos_master_port: "5050" 55 | mesos_slave_port: "5051" 56 | mesos_log_location: "/var/log/mesos" 57 | mesos_ulimit: "-n 8192" 58 | mesos_work_dir: "/var/mesos" 59 | mesos_quorum: "1" 60 | zookeeper_client_port: "2181" 61 | zookeeper_hostnames: "{{ mesos_hostname }}:{{ zookeeper_client_port }}" 62 | mesos_zookeeper_masters: "zk://{{ zookeeper_hostnames }}/mesos" 63 | mesos_owner: root 64 | mesos_group: root 65 | 66 | # Containerizer 67 | mesos_containerizers: "docker,mesos" 68 | mesos_executor_timeout: "5mins" 69 | 70 | # SSL 71 | mesos_ssl_enabled: false 72 | mesos_ssl_support_downgrade: false 73 | mesos_ssl_key_file: # When SSL is enabled this must be used to point to the SSL key file 74 | mesos_ssl_cert_file: # When SSL is enabled this must be used to point to the SSL certificate file 75 | 76 | mesos_option_prefix: "MESOS_" 77 | 78 | # Additional configurations 79 | mesos_additional_configs: [] 80 | # For example: 81 | # - name: FOO 82 | # value: bar 83 | 84 | # Additional configurations for master 85 | mesos_master_additional_configs: [] 86 | # For example: 87 | # - name: FOO 88 | # value: bar 89 | 90 | # Additional configurations for slave 91 | mesos_slave_additional_configs: [] 92 | # For example: 93 | # - name: FOO 94 | # value: bar 95 | ``` 96 | 97 | Playbook Example 98 | ---------------- 99 | 100 | ```yaml 101 | - name: Java + Zookeeper + Mesos [master-slave] 102 | hosts: all 103 | sudo: yes 104 | roles: 105 | - role: geerlingguy.java 106 | 107 | - role: AnsibleShipyard.ansible-zookeeper 108 | 109 | - role: ansible-mesos 110 | mesos_install_mode: master-slave 111 | ``` 112 | 113 | Docker is only required on slave nodes and is not installed by default. 114 | To use docker with Mesos ensure that docker is installed on slave nodes. 115 | You can then set ```mesos_containerizers: "docker,mesos"``` for slave nodes. 116 | 117 | License 118 | ------- 119 | 120 | Apache License 121 | 122 | AnsibleShipyard 123 | ------- 124 | 125 | Our related playbooks 126 | 127 | 1. [ansible-marathon](https://github.com/AnsibleShipyard/ansible-marathon) 128 | 1. [ansible-chronos](https://github.com/AnsibleShipyard/ansible-chronos) 129 | 1. [ansible-zookeeper](https://github.com/AnsibleShipyard/ansible-zookeeper) 130 | 131 | Author Information 132 | ------------------ 133 | 134 | @AnsibleShipyard/developers and others. 135 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | --------------------------------------------------------------------------------