AnsibleShipyard / ansible-mesos

Mesos Playbook for Ansible
Apache License 2.0
169 stars 104 forks source link

ainsible-docker support #37

Closed veacks closed 8 years ago

veacks commented 8 years ago

Hi,

First of all, I would like to thank you for your ansible roles. It's really simple to play with them.

The mesos role goes well if I don't use docker as mesos_containerizers.

Unfortunately When using docker (installed with your AnsibleShipyard/ansible-docker role) each time I try to start my mesos-slaves I have the message in my mesos-slave log:

_Failed to create a containerizer: Could not create DockerContainerizer: Failed to execute 'docker version': exited with status 1_

Docker is installed, when I do a sudo docker version I have this output:

Client:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   a34a1d5
 Built:        Fri Nov 20 17:56:04 UTC 2015
 OS/Arch:      linux/amd64

Server:
 Version:      1.9.1
  API version:  1.21
  Go version:   go1.4.3
  Git commit:   a34a1d5
  Built:        Fri Nov 20 17:56:04 UTC 2015
  OS/Arch:      linux/amd64

But when I don't do any sudo, I have this output:

Client:
Version:      1.9.1
API version:  1.21
Go version:   go1.4.3
Git commit:   a34a1d5
Built:        Fri Nov 20 17:56:04 UTC 2015
OS/Arch:      linux/amd64
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

I'd like to know if someone already faced this issue and can help me with each group/users I need set up to make work docker and mesos together.

This is my configuration for the mesos-slave (all the roles used here are from AnsibleShipyard) :


---
- hosts: [mesos_slaves]
  sudo: True
  pre_tasks:
    - name: Remove require tty
      lineinfile: regexp="tty" dest=/etc/sudoers/os_defaults state=absent
      tags: ['system']
  roles: 
    - { role: 'ansible-docker', tags: ['docker'] }
    - { role: 'ansible-java', tags: ['java'], when: ansible_os_family == 'Debian' }
    - { role: 'ansible-mesos', mesos_containerizers: "docker,mesos", zookeeper_hostnames: "{{ groups.mesos_masters | join(':' + zookeeper_client_port + ',')  }}:{{ zookeeper_client_port  }}", mesos_cluster_name: 'oprt',  mesos_install_mode: "slave", tags:  ['mesos'] }
    - { role: 'ansible-consul', consul_conf_start_join: "{{ groups.mesos_masters }}", consul_conf_retry_join: "{{ groups.mesos_masters }}", tags: ['consul'] }

Thanks, Valentin.

veacks commented 8 years ago

This is the whole configuration of my cluster in case of: I run the play book across 3 Ubuntu 14.04 machines on AWS.

playbook.yml

---
- include: common.yml
- include: mesos_masters.yml
- include: mesos_slaves.yml

common.yml

---
- hosts: [all]
  sudo: True
  tags: ['system']
  pre_tasks:
    - name: Install Debian Packages
      apt: pkg={{ item }} state=present update_cache=yes
      with_items:
        - git
        - vim
        - htop
        - unzip
      when: ansible_os_family == "Debian"
    - name: Downloading and enable the EPEL repository definitions.
      yum: name=http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm state=present
      when: ansible_os_family == "RedHat"
    - name: Install Redhat Packages 
      yum: pkg={{ item }} state=present
      with_items:
        - java7
        - git
        - vim
        - htop
        - unzip
      when: ansible_os_family == "RedHat"
    - name: Disable iptables
      action: service name=iptables state=stopped enabled=false
      when: ansible_os_family == "RedHat"
    - name: Remove require tty
      lineinfile: regexp="^\s+\w+\s+requiretty" dest=/etc/sudoers state=absent
    - name: Remove require tty - alt
      lineinfile: regexp="requiretty" dest=/etc/sudoers.d/os_defaults state=absent

mesos_masters.yml

---
- hosts: [mesos_masters]
  sudo: True
  roles:
    - { role: 'ansible-java', tags: ['runtimes', 'java'], when: ansible_os_family == 'Debian' }
    - { role: 'ansible-zookeeper', tags: ['zookeeper'] }
    - { role: 'ansible-mesos', mesos_quorum: "1", zookeeper_hostnames: "{{ groups.mesos_masters | join(':' + zookeeper_client_port + ',')  }}:{{ zookeeper_client_port  }}", mesos_install_mode: 'master', mesos_cluster_name: 'oprt', tags: ['mesos', 'platforms'] }
    - { role: 'ansible-marathon', zookeeper_hostnames: "{{ groups.mesos_masters | join(':' + zookeeper_client_port + ',')  }}:{{ zookeeper_client_port  }}",  tags: ['mesos-tools'] }
    - { role: 'ansible-consul', consul_conf_start_join: "{{ groups.mesos_masters }}", consul_conf_retry_join: "{{ groups.mesos_masters }}", consul_install_mode: 'server', consul_install_webui: true, tags: ['consul'] }

mesos_slave.yml

---
- hosts: [mesos_slaves]
  sudo: True
  pre_tasks:
    - name: Remove require tty
      lineinfile: regexp="tty" dest=/etc/sudoers/os_defaults state=absent
      tags: ['system']
  roles: 
    - { role: 'ansible-docker', tags: ['docker'] }
    - { role: 'ansible-java', tags: ['java'], when: ansible_os_family == 'Debian' }
    - { role: 'ansible-mesos', mesos_containerizers: "docker,mesos", zookeeper_hostnames: "{{ groups.mesos_masters | join(':' + zookeeper_client_port + ',')  }}:{{ zookeeper_client_port  }}", mesos_cluster_name: 'oprt',  mesos_install_mode: "slave", tags:  ['mesos'] }
    - { role: 'ansible-consul', mesos_group: "docker", consul_conf_start_join: "{{ groups.mesos_masters }}", consul_conf_retry_join: "{{ groups.mesos_masters }}", tags: ['consul'] }
veacks commented 8 years ago

I have sent a PR for this issue #38

JasonGiedymin commented 8 years ago

Merged and closing this.