-
Notifications
You must be signed in to change notification settings - Fork 104
Example
Benoit Carriere edited this page Feb 13, 2016
·
1 revision
Here is an simplistic example to show how one can use this role.
It uses three groups: mesos
as a meta-group, mesos-primaries
for the "masters" and mesos-workers
for the "slaves".
The inventory looks like this:
# Inventory file "inventories/development/inventory.yml"
[mesos:children]
mesos-primaries
mesos-workers
[mesos-primaries]
primary-01
primary-02
primary-03
[mesos-workers]
worker-01
worker-02
[zookeeper_hosts]
zookeeper-01
zookeeper-02
The playbook executes for all hosts in mesos
group, gathering facts only once, and executing a play for each installation mode using their respective groups:
# Playbook file "playbooks/mesos/install.yml"
# Empty play that only gather facts once and set required variables.
- name: Mesos
hosts: mesos
gather_facts: yes
vars:
zookeeper_hostnames: "{{ groups.zookeeper_hosts | join(':' + zookeeper_client_port + ',') }}:{{ zookeeper_client_port }}"
# Play to install only "primaries" mesos.
- name: Mesos Primaries
hosts: mesos-primaries
sudo: yes
gather_facts: no
roles:
- { role: ansible-mesos, mesos_install_mode: master }
# Play to install only "workers" mesos.
- name: Mesos Workers
hosts: mesos-workers
sudo: yes
gather_facts: no
roles:
- { role: ansible-mesos, mesos_install_mode: slave }
You can customize your installation by using group_vars, for example:
# playbook group_vars file "inventories/development/group_vars/mesos.yml"
# Mesos
mesos_version: "0.23.0"
mesos_hostname: "{{ ansible_fqdn }}"
mesos_cluster_name: "Development Cluster"
mesos_containerizers: "docker,mesos"
mesos_quorum: '2'
mesos_log_location: '/opt/logs/mesos'
mesos_work_dir: '/opt/mesos'
Executing the playbook is like this:
ansible-playbook -Kk \ # (1)
-i inventories/development/ \ # (2)
playbooks/mesos/install.yml
(1)
asking for both connection password and sudo (become) password
(2)
pickup any file in the inventory folder, here only inventory.yml