From 0647cad7be275a36a59e1a37fa31d65cbb68bf8a Mon Sep 17 00:00:00 2001 From: Huamin Chen Date: Wed, 13 Jan 2016 19:15:35 +0000 Subject: [PATCH] containerized mon --- group_vars/all.sample | 1 - roles/ceph-mon/tasks/docker/fetch_configs.yml | 3 +- roles/ceph-mon/tasks/docker/pre_requisite.yml | 41 +++++++++++++++++++ .../tasks/docker/start_docker_monitor.yml | 10 +++++ roles/ceph-osd/tasks/docker/fetch_configs.yml | 14 +++++-- roles/ceph-osd/tasks/docker/pre_requisite.yml | 41 +++++++++++++++++++ .../tasks/docker/start_docker_osd.yml | 4 ++ 7 files changed, 107 insertions(+), 7 deletions(-) diff --git a/group_vars/all.sample b/group_vars/all.sample index 48375f711..4284df595 100644 --- a/group_vars/all.sample +++ b/group_vars/all.sample @@ -337,4 +337,3 @@ dummy: ########## #docker: false - diff --git a/roles/ceph-mon/tasks/docker/fetch_configs.yml b/roles/ceph-mon/tasks/docker/fetch_configs.yml index 56e737aee..48438dfac 100644 --- a/roles/ceph-mon/tasks/docker/fetch_configs.yml +++ b/roles/ceph-mon/tasks/docker/fetch_configs.yml @@ -3,7 +3,6 @@ set_fact: ceph_config_keys: - /etc/ceph/ceph.client.admin.keyring - - /etc/ceph/ceph.conf - /etc/ceph/monmap - /etc/ceph/ceph.mon.keyring - /var/lib/ceph/bootstrap-osd/ceph.keyring @@ -20,7 +19,7 @@ - name: try to fetch ceph config and keys copy: - src: "{{ fetch_directory }}/docker_mon_files/{{ item.0 }}" + src: "{{ playbook_dir }}/{{ fetch_directory }}/{{ fsid }}/{{ item.0 }}" dest: "{{ item.0 }}" owner: root group: root diff --git a/roles/ceph-mon/tasks/docker/pre_requisite.yml b/roles/ceph-mon/tasks/docker/pre_requisite.yml index 41fb0e7fd..f09655f64 100644 --- a/roles/ceph-mon/tasks/docker/pre_requisite.yml +++ b/roles/ceph-mon/tasks/docker/pre_requisite.yml @@ -19,6 +19,8 @@ - docker - docker.io when: ansible_distribution == 'Ubuntu' + tags: + with_pkg - name: install pip and docker on debian apt: @@ -29,6 +31,8 @@ - python-pip - docker-engine when: ansible_distribution == 'Debian' + tags: + with_pkg - name: install pip and docker on redhat yum: @@ -40,6 +44,8 @@ when: ansible_os_family == 'RedHat' and ansible_pkg_mgr == "yum" + tags: + with_pkg - name: install pip and docker on redhat dnf: @@ -51,9 +57,44 @@ when: ansible_os_family == 'RedHat' and ansible_pkg_mgr == "dnf" + tags: + with_pkg + +- name: install epel-release on redhat + yum: + name: epel-release + state: present + when: ansible_os_family == 'RedHat' + tags: + with_pkg + +# NOTE (jimcurtis): need at least version 1.9.0 of six or we get: +# re:NameError: global name 'DEFAULT_DOCKER_API_VERSION' is not defined +- name: install six + pip: + name: six + version: 1.9.0 + tags: + with_pkg + +- name: pause after docker install before starting (on openstack vms) + pause: seconds=5 + when: ceph_docker_on_openstack + tags: + with_pkg + +- name: start docker service + service: + name: docker + state: started + enabled: yes + tags: + with_pkg # NOTE (leseb): for version 1.1.0 because https://github.com/ansible/ansible-modules-core/issues/1227 - name: install docker-py pip: name: docker-py version: 1.1.0 + tags: + with_pkg diff --git a/roles/ceph-mon/tasks/docker/start_docker_monitor.yml b/roles/ceph-mon/tasks/docker/start_docker_monitor.yml index e943fd9af..3d962822d 100644 --- a/roles/ceph-mon/tasks/docker/start_docker_monitor.yml +++ b/roles/ceph-mon/tasks/docker/start_docker_monitor.yml @@ -1,4 +1,7 @@ --- +- name: pull ceph daemon image + shell: "docker pull {{ ceph_mon_docker_username }}/{{ ceph_mon_docker_imagename }}" + - name: run the ceph Monitor docker image docker: image: "{{ ceph_mon_docker_username }}/{{ ceph_mon_docker_imagename }}" @@ -7,3 +10,10 @@ state: "running" env: "MON_IP={{ hostvars[inventory_hostname]['ansible_' + ceph_mon_docker_interface]['ipv4']['address'] }},CEPH_DAEMON=MON,CEPH_PUBLIC_NETWORK={{ ceph_mon_docker_subnet }},{{ ceph_mon_extra_envs }}" volumes: "/var/lib/ceph:/var/lib/ceph,/etc/ceph:/etc/ceph" + +- name: fetch ceph.conf from mon + fetch: + dest: "{{ playbook_dir }}/{{ fetch_directory }}/{{ fsid}}/etc/ceph/ceph.conf" + src: /etc/ceph/ceph.conf + flat: yes + \ No newline at end of file diff --git a/roles/ceph-osd/tasks/docker/fetch_configs.yml b/roles/ceph-osd/tasks/docker/fetch_configs.yml index f67200b44..970519807 100644 --- a/roles/ceph-osd/tasks/docker/fetch_configs.yml +++ b/roles/ceph-osd/tasks/docker/fetch_configs.yml @@ -5,6 +5,14 @@ - /etc/ceph/ceph.conf - /var/lib/ceph/bootstrap-osd/ceph.keyring +- name: wait for ceph.conf and keys + local_action: > + wait_for + path="{{ playbook_dir }}/{{ fetch_directory }}/docker_mon_files/{{ item.0 }}" + become: false + with_together: + - ceph_config_keys + - name: stat for ceph config and keys local_action: stat path={{ fetch_directory }}/docker_mon_files/{{ item }} with_items: ceph_config_keys @@ -13,9 +21,9 @@ failed_when: false register: statconfig -- name: try to fetch ceph config and keys +- name: try to copy ceph config and keys copy: - src: "{{ fetch_directory }}/docker_mon_files/{{ item.0 }}" + src: "{{ playbook_dir }}/{{ fetch_directory }}/docker_mon_files/{{ item.0 }}" dest: "{{ item.0 }}" owner: root group: root @@ -23,5 +31,3 @@ changed_when: false with_together: - ceph_config_keys - - statconfig.results - when: item.1.stat.exists == true diff --git a/roles/ceph-osd/tasks/docker/pre_requisite.yml b/roles/ceph-osd/tasks/docker/pre_requisite.yml index 3f3a982c4..a4837f11f 100644 --- a/roles/ceph-osd/tasks/docker/pre_requisite.yml +++ b/roles/ceph-osd/tasks/docker/pre_requisite.yml @@ -17,6 +17,8 @@ - docker - docker.io when: ansible_distribution == 'Ubuntu' + tags: + with_pkg - name: install pip and docker on debian apt: @@ -27,6 +29,8 @@ - python-pip - docker-engine when: ansible_distribution == 'Debian' + tags: + with_pkg - name: install pip and docker on redhat yum: @@ -38,6 +42,8 @@ when: ansible_os_family == 'RedHat' and ansible_pkg_mgr == "yum" + tags: + with_pkg - name: install pip and docker on redhat dnf: @@ -49,9 +55,44 @@ when: ansible_os_family == 'RedHat' and ansible_pkg_mgr == "dnf" + tags: + with_pkg + +- name: install epel-release on redhat + yum: + name: epel-release + state: present + when: ansible_os_family == 'RedHat' + tags: + with_pkg + +# NOTE (jimcurtis): need at least version 1.9.0 of six or we get: +# re:NameError: global name 'DEFAULT_DOCKER_API_VERSION' is not defined +- name: install six + pip: + name: six + version: 1.9.0 + tags: + with_pkg + +- name: pause after docker install before starting (on openstack vms) + pause: seconds=5 + when: ceph_docker_on_openstack + tags: + with_pkg + +- name: start docker service + service: + name: docker + state: started + enabled: yes + tags: + with_pkg # NOTE (leseb): for version 1.1.0 because https://github.com/ansible/ansible-modules-core/issues/1227 - name: install docker-py pip: name: docker-py version: 1.1.0 + tags: + with_pkg diff --git a/roles/ceph-osd/tasks/docker/start_docker_osd.yml b/roles/ceph-osd/tasks/docker/start_docker_osd.yml index 847b07ebe..64fccae03 100644 --- a/roles/ceph-osd/tasks/docker/start_docker_osd.yml +++ b/roles/ceph-osd/tasks/docker/start_docker_osd.yml @@ -1,4 +1,8 @@ --- +# (rootfs) for reasons I haven't figured out, docker pull and run will fail. +- name: pull ceph daemon image + shell: "docker pull {{ ceph_mon_docker_username }}/{{ ceph_mon_docker_imagename }}" + - name: run the ceph osd docker image docker: image: "{{ ceph_osd_docker_username }}/{{ ceph_osd_docker_imagename }}"