From fa610cabf721bee19852c07561dee1a5323970ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Sun, 7 Feb 2016 22:30:32 +0100 Subject: [PATCH] ceph-ansible: allow to run containerized daemons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit run containerized daemons in virtual machines. to enable it simply do: `cp site-docker.yml.sample site-docker.yml` and set `docker: true` in `vagrant_variables.yml` Signed-off-by: Sébastien Han --- .gitignore | 1 + Vagrantfile | 43 ++++++++++++++----- roles/ceph-mds/tasks/docker/fetch_configs.yml | 2 +- roles/ceph-mds/tasks/docker/pre_requisite.yml | 37 ++++++++++++---- roles/ceph-mon/tasks/docker/fetch_configs.yml | 2 +- roles/ceph-mon/tasks/docker/pre_requisite.yml | 37 ++++++++++++---- roles/ceph-osd/tasks/docker/fetch_configs.yml | 2 +- roles/ceph-osd/tasks/docker/pre_requisite.yml | 37 ++++++++++++---- .../tasks/docker/fetch_configs.yml | 2 +- .../tasks/docker/pre_requisite.yml | 37 ++++++++++++---- roles/ceph-rgw/tasks/docker/fetch_configs.yml | 2 +- roles/ceph-rgw/tasks/docker/pre_requisite.yml | 37 ++++++++++++---- site-docker.yml.sample | 28 ++++++++++++ site.yml.sample | 1 - vagrant_variables.yml.sample | 3 ++ 15 files changed, 214 insertions(+), 57 deletions(-) create mode 100644 site-docker.yml.sample diff --git a/.gitignore b/.gitignore index 468791410..05ce69b8e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ group_vars/rgws group_vars/restapis *.DS_Store site.yml +site-docker.yml *.pyc diff --git a/Vagrantfile b/Vagrantfile index 11b7f1010..3ca7d390a 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -17,9 +17,15 @@ BOX = settings['vagrant_box'] MEMORY = settings['memory'] STORAGECTL = settings['vagrant_storagectl'] ETH = settings['eth'] +DOCKER = settings['docker'] ansible_provision = proc do |ansible| - ansible.playbook = 'site.yml' + if DOCKER then + ansible.playbook = 'site-docker.yml' + else + ansible.playbook = 'site.yml' + end + # Note: Can't do ranges like mon[0-2] in groups because # these aren't supported by Vagrant, see # https://github.com/mitchellh/vagrant/issues/3539 @@ -33,16 +39,31 @@ ansible_provision = proc do |ansible| } # In a production deployment, these should be secret - ansible.extra_vars = { - ceph_stable: 'true', - journal_collocation: 'true', - journal_size: 100, - monitor_interface: ETH, - cluster_network: "#{SUBNET}.0/24", - public_network: "#{SUBNET}.0/24", - devices: settings['disks'], - os_tuning_params: settings['os_tuning_params'] - } + if DOCKER then + ansible.extra_vars = { + mon_containerized_deployment: 'true', + osd_containerized_deployment: 'true', + mds_containerized_deployment: 'true', + rgw_containerized_deployment: 'true', + restapi_containerized_deployment: 'true', + ceph_mon_docker_interface: ETH, + ceph_mon_docker_subnet: "#{SUBNET}.0/24", + ceph_osd_docker_extra_env: "CEPH_DAEMON=OSD_CEPH_DISK,OSD_JOURNAL_SIZE=100", + ceph_osd_docker_device: settings['disks'], + ceph_rgw_civetweb_port: 8080 + } + else + ansible.extra_vars = { + ceph_stable: 'true', + journal_collocation: 'true', + journal_size: 100, + monitor_interface: ETH, + cluster_network: "#{SUBNET}.0/24", + public_network: "#{SUBNET}.0/24", + devices: settings['disks'], + os_tuning_params: settings['os_tuning_params'] + } + end ansible.limit = 'all' end diff --git a/roles/ceph-mds/tasks/docker/fetch_configs.yml b/roles/ceph-mds/tasks/docker/fetch_configs.yml index 1ab999b49..b500cfcdb 100644 --- a/roles/ceph-mds/tasks/docker/fetch_configs.yml +++ b/roles/ceph-mds/tasks/docker/fetch_configs.yml @@ -9,7 +9,7 @@ - /var/lib/ceph/bootstrap-mds/ceph.keyring - name: stat for ceph config and keys - local_action: stat path={{ item }} + local_action: stat path={{ fetch_directory }}/docker_mon_files/{{ item }} with_items: ceph_config_keys changed_when: false become: false diff --git a/roles/ceph-mds/tasks/docker/pre_requisite.yml b/roles/ceph-mds/tasks/docker/pre_requisite.yml index 71a03bd05..8e40aa963 100644 --- a/roles/ceph-mds/tasks/docker/pre_requisite.yml +++ b/roles/ceph-mds/tasks/docker/pre_requisite.yml @@ -7,24 +7,45 @@ - /etc/ceph/ - /var/lib/ceph/bootstrap-mds -- name: install pip on debian +- name: install pip and docker on ubuntu apt: - name: python-pip + name: "{{ item }}" state: present - when: ansible_os_family == 'Debian' + update_cache: yes + with_items: + - python-pip + - docker + - docker.io + when: ansible_distribution == 'Ubuntu' -- name: install pip on redhat - yum: - name: python-pip +- name: install pip and docker on debian + apt: + name: "{{ item }}" state: present + update_cache: yes + with_items: + - python-pip + - docker-engine + when: ansible_distribution == 'Debian' + +- name: install pip and docker on redhat + yum: + name: "{{ item }}" + state: present + with_items: + - python-pip + - docker-engine when: ansible_os_family == 'RedHat' and ansible_pkg_mgr == "yum" -- name: install pip on redhat +- name: install pip and docker on redhat dnf: - name: python-pip + name: "{{ item }}" state: present + with_items: + - python-pip + - docker-engine when: ansible_os_family == 'RedHat' and ansible_pkg_mgr == "dnf" diff --git a/roles/ceph-mon/tasks/docker/fetch_configs.yml b/roles/ceph-mon/tasks/docker/fetch_configs.yml index 5381c1ade..bdf71b92a 100644 --- a/roles/ceph-mon/tasks/docker/fetch_configs.yml +++ b/roles/ceph-mon/tasks/docker/fetch_configs.yml @@ -11,7 +11,7 @@ - /var/lib/ceph/bootstrap-mds/ceph.keyring - name: stat for ceph config and keys - local_action: stat path={{ item }} + local_action: stat path={{ fetch_directory }}/docker_mon_files/{{ item }} with_items: ceph_config_keys changed_when: false become: false diff --git a/roles/ceph-mon/tasks/docker/pre_requisite.yml b/roles/ceph-mon/tasks/docker/pre_requisite.yml index c4fb42d02..41fb0e7fd 100644 --- a/roles/ceph-mon/tasks/docker/pre_requisite.yml +++ b/roles/ceph-mon/tasks/docker/pre_requisite.yml @@ -9,24 +9,45 @@ - /var/lib/ceph/bootstrap-mds - /var/lib/ceph/bootstrap-rgw -- name: install pip on debian +- name: install pip and docker on ubuntu apt: - name: python-pip + name: "{{ item }}" state: present - when: ansible_os_family == 'Debian' + update_cache: yes + with_items: + - python-pip + - docker + - docker.io + when: ansible_distribution == 'Ubuntu' -- name: install pip on redhat - yum: - name: python-pip +- name: install pip and docker on debian + apt: + name: "{{ item }}" state: present + update_cache: yes + with_items: + - python-pip + - docker-engine + when: ansible_distribution == 'Debian' + +- name: install pip and docker on redhat + yum: + name: "{{ item }}" + state: present + with_items: + - python-pip + - docker-engine when: ansible_os_family == 'RedHat' and ansible_pkg_mgr == "yum" -- name: install pip on redhat +- name: install pip and docker on redhat dnf: - name: python-pip + name: "{{ item }}" state: present + with_items: + - python-pip + - docker-engine when: ansible_os_family == 'RedHat' and ansible_pkg_mgr == "dnf" diff --git a/roles/ceph-osd/tasks/docker/fetch_configs.yml b/roles/ceph-osd/tasks/docker/fetch_configs.yml index 802b4b9d2..f8e4d0c27 100644 --- a/roles/ceph-osd/tasks/docker/fetch_configs.yml +++ b/roles/ceph-osd/tasks/docker/fetch_configs.yml @@ -6,7 +6,7 @@ - /var/lib/ceph/bootstrap-osd/ceph.keyring - name: stat for ceph config and keys - local_action: stat path={{ item }} + local_action: stat path={{ fetch_directory }}/docker_mon_files/{{ item }} with_items: ceph_config_keys changed_when: false become: false diff --git a/roles/ceph-osd/tasks/docker/pre_requisite.yml b/roles/ceph-osd/tasks/docker/pre_requisite.yml index 6797f6954..3f3a982c4 100644 --- a/roles/ceph-osd/tasks/docker/pre_requisite.yml +++ b/roles/ceph-osd/tasks/docker/pre_requisite.yml @@ -7,24 +7,45 @@ - /etc/ceph/ - /var/lib/ceph/bootstrap-osd -- name: install pip on debian +- name: install pip and docker on ubuntu apt: - name: python-pip + name: "{{ item }}" state: present - when: ansible_os_family == 'Debian' + update_cache: yes + with_items: + - python-pip + - docker + - docker.io + when: ansible_distribution == 'Ubuntu' -- name: install pip on redhat - yum: - name: python-pip +- name: install pip and docker on debian + apt: + name: "{{ item }}" state: present + update_cache: yes + with_items: + - python-pip + - docker-engine + when: ansible_distribution == 'Debian' + +- name: install pip and docker on redhat + yum: + name: "{{ item }}" + state: present + with_items: + - python-pip + - docker-engine when: ansible_os_family == 'RedHat' and ansible_pkg_mgr == "yum" -- name: install pip on redhat +- name: install pip and docker on redhat dnf: - name: python-pip + name: "{{ item }}" state: present + with_items: + - python-pip + - docker-engine when: ansible_os_family == 'RedHat' and ansible_pkg_mgr == "dnf" diff --git a/roles/ceph-restapi/tasks/docker/fetch_configs.yml b/roles/ceph-restapi/tasks/docker/fetch_configs.yml index 0b7e43dbb..c432478db 100644 --- a/roles/ceph-restapi/tasks/docker/fetch_configs.yml +++ b/roles/ceph-restapi/tasks/docker/fetch_configs.yml @@ -6,7 +6,7 @@ - /etc/ceph/ceph.client.admin.keyring - name: stat for ceph config and keys - local_action: stat path={{ item }} + local_action: stat path={{ fetch_directory }}/docker_mon_files/{{ item }} with_items: ceph_config_keys changed_when: false become: false diff --git a/roles/ceph-restapi/tasks/docker/pre_requisite.yml b/roles/ceph-restapi/tasks/docker/pre_requisite.yml index dd8b011ba..3eef68689 100644 --- a/roles/ceph-restapi/tasks/docker/pre_requisite.yml +++ b/roles/ceph-restapi/tasks/docker/pre_requisite.yml @@ -1,22 +1,43 @@ --- -- name: install pip on debian +- name: install pip and docker on ubuntu apt: - name: python-pip + name: "{{ item }}" state: present - when: ansible_os_family == 'Debian' + update_cache: yes + with_items: + - python-pip + - docker + - docker.io + when: ansible_distribution == 'Ubuntu' -- name: install pip on redhat - yum: - name: python-pip +- name: install pip and docker on debian + apt: + name: "{{ item }}" state: present + update_cache: yes + with_items: + - python-pip + - docker-engine + when: ansible_distribution == 'Debian' + +- name: install pip and docker on redhat + yum: + name: "{{ item }}" + state: present + with_items: + - python-pip + - docker-engine when: ansible_os_family == 'RedHat' and ansible_pkg_mgr == "yum" -- name: install pip on redhat +- name: install pip and docker on redhat dnf: - name: python-pip + name: "{{ item }}" state: present + with_items: + - python-pip + - docker-engine when: ansible_os_family == 'RedHat' and ansible_pkg_mgr == "dnf" diff --git a/roles/ceph-rgw/tasks/docker/fetch_configs.yml b/roles/ceph-rgw/tasks/docker/fetch_configs.yml index 0154d911c..7ee376823 100644 --- a/roles/ceph-rgw/tasks/docker/fetch_configs.yml +++ b/roles/ceph-rgw/tasks/docker/fetch_configs.yml @@ -6,7 +6,7 @@ - /var/lib/ceph/bootstrap-rgw/ceph.keyring - name: stat for ceph config and keys - local_action: stat path={{ item }} + local_action: stat path={{ fetch_directory }}/docker_mon_files/{{ item }} with_items: ceph_config_keys changed_when: false become: false diff --git a/roles/ceph-rgw/tasks/docker/pre_requisite.yml b/roles/ceph-rgw/tasks/docker/pre_requisite.yml index 2b322050e..48b57c252 100644 --- a/roles/ceph-rgw/tasks/docker/pre_requisite.yml +++ b/roles/ceph-rgw/tasks/docker/pre_requisite.yml @@ -7,24 +7,45 @@ - /etc/ceph/ - /var/lib/ceph/bootstrap-rgw -- name: install pip on debian + name: install pip and docker on ubuntu apt: - name: python-pip + name: "{{ item }}" state: present - when: ansible_os_family == 'Debian' + update_cache: yes + with_items: + - python-pip + - docker + - docker.io + when: ansible_distribution == 'Ubuntu' -- name: install pip on redhat - yum: - name: python-pip +- name: install pip and docker on debian + apt: + name: "{{ item }}" state: present + update_cache: yes + with_items: + - python-pip + - docker-engine + when: ansible_distribution == 'Debian' + +- name: install pip and docker on redhat + yum: + name: "{{ item }}" + state: present + with_items: + - python-pip + - docker-engine when: ansible_os_family == 'RedHat' and ansible_pkg_mgr == "yum" -- name: install pip on redhat +- name: install pip and docker on redhat dnf: - name: python-pip + name: "{{ item }}" state: present + with_items: + - python-pip + - docker-engine when: ansible_os_family == 'RedHat' and ansible_pkg_mgr == "dnf" diff --git a/site-docker.yml.sample b/site-docker.yml.sample new file mode 100644 index 000000000..4cba5a799 --- /dev/null +++ b/site-docker.yml.sample @@ -0,0 +1,28 @@ +--- +# Defines deployment design and assigns role to server groups + +- hosts: mons + become: True + roles: + - ceph-mon + serial: 1 # MUST be '1' WHEN DEPLOYING MONITORS ON DOCKER CONTAINERS + +- hosts: osds + become: True + roles: + - ceph-osd + +- hosts: mdss + become: True + roles: + - ceph-mds + +- hosts: rgws + become: True + roles: + - ceph-rgw + +- hosts: restapis + become: True + roles: + - ceph-restapi diff --git a/site.yml.sample b/site.yml.sample index b13c1c2ab..f74ace053 100644 --- a/site.yml.sample +++ b/site.yml.sample @@ -5,7 +5,6 @@ become: True roles: - ceph-mon - #serial: 1 # ENABLE THIS WHEN DEPLOYING MONITORS ON DOCKER CONTAINERS - hosts: osds become: True diff --git a/vagrant_variables.yml.sample b/vagrant_variables.yml.sample index a9e1e5fcb..28c8729b3 100644 --- a/vagrant_variables.yml.sample +++ b/vagrant_variables.yml.sample @@ -1,5 +1,8 @@ --- +# DEPLOY CONTAINERIZED DAEMONS +docker: false + # DEFINE THE NUMBER OF VMS TO RUN mon_vms: 3 osd_vms: 3