From 08766a243a705626defd3988c6f58127efb4ae4a Mon Sep 17 00:00:00 2001 From: Daniel Lin Date: Mon, 6 Jun 2016 10:22:20 -0400 Subject: [PATCH] Allow ceph-ansible to be run on a locally built/installed Ceph -First install ceph into a directory with CMake cmake -DCMAKE_INSTALL_LIBEXECDIR=/usr/lib -DWITH_SYSTEMD=ON -DCMAKE_INSTALL_PREFIX:PATH:=/usr && make DESTDIR= install/strip -Ceph-ansible copies over the install_dir -User can use rundep_installer.sh to install any runtime dependencies that ceph needs onto the machine from rundep --- group_vars/all.sample | 18 ++++- roles/ceph-common/defaults/main.yml | 18 ++++- .../tasks/checks/check_mandatory_vars.yml | 1 + .../tasks/installs/install_on_redhat.yml | 72 ++++++++++++++++--- roles/ceph-mon/tasks/deploy_monitors.yml | 2 +- roles/ceph-mon/tasks/start_monitor.yml | 6 +- rundep.sample | 45 ++++++++++++ rundep_installer.sh | 27 +++++++ 8 files changed, 171 insertions(+), 18 deletions(-) create mode 100644 rundep.sample create mode 100755 rundep_installer.sh diff --git a/group_vars/all.sample b/group_vars/all.sample index 941a2da99..4d3e7e15a 100644 --- a/group_vars/all.sample +++ b/group_vars/all.sample @@ -84,12 +84,24 @@ dummy: ## Configure package origin # -#ceph_origin: 'upstream' # or 'distro' +#ceph_origin: 'upstream' #'distro' or 'local' # 'distro' means that no separate repo file will be added # you will get whatever version of Ceph is included in your Linux distro. -# -#ceph_use_distro_backports: false # DEBIAN ONLY +# 'local' means that the ceph binaries will be copied over from the local machine +# LOCAL CEPH INSTALLATION (ceph_origin==local) +# +# Path to DESTDIR of the ceph install +#ceph_installation_dir: "/path/to/ceph_installation/" +# Whether or not to use installer script rundep_installer.sh +# This script takes in rundep and installs the packages line by line onto the machine +# If this is set to false then it is assumed that the machine ceph is being copied onto will already have +# all runtime dependencies installed +#use_installer: false +# Root directory for ceph-ansible +#ansible_dir: "/path/to/ceph-ansible" + +#ceph_use_distro_backports: false # DEBIAN ONLY # STABLE ######## diff --git a/roles/ceph-common/defaults/main.yml b/roles/ceph-common/defaults/main.yml index bfc5d023b..fe9d16849 100644 --- a/roles/ceph-common/defaults/main.yml +++ b/roles/ceph-common/defaults/main.yml @@ -76,12 +76,24 @@ ceph_test: False ## Configure package origin # -ceph_origin: 'upstream' # or 'distro' +ceph_origin: 'upstream' # or 'distro' or 'local' # 'distro' means that no separate repo file will be added # you will get whatever version of Ceph is included in your Linux distro. -# -ceph_use_distro_backports: false # DEBIAN ONLY +# 'local' means that the ceph binaries will be copied over from the local machine +# LOCAL CEPH INSTALLATION (ceph_origin==local) +# +# Path to DESTDIR of the ceph install +#ceph_installation_dir: "/path/to/ceph_installation/" +# Whether or not to use installer script rundep_installer.sh +# This script takes in rundep and installs the packages line by line onto the machine +# If this is set to false then it is assumed that the machine ceph is being copied onto will already have +# all runtime dependencies installed +#use_installer: false +# Root directory for ceph-ansible +#ansible_dir: "/path/to/ceph-ansible" + +ceph_use_distro_backports: false # DEBIAN ONLY # STABLE ######## diff --git a/roles/ceph-common/tasks/checks/check_mandatory_vars.yml b/roles/ceph-common/tasks/checks/check_mandatory_vars.yml index 499d593c0..e317589b7 100644 --- a/roles/ceph-common/tasks/checks/check_mandatory_vars.yml +++ b/roles/ceph-common/tasks/checks/check_mandatory_vars.yml @@ -5,6 +5,7 @@ when: - ceph_origin != 'upstream' - ceph_origin != 'distro' + - ceph_origin != 'local' tags: - package-install diff --git a/roles/ceph-common/tasks/installs/install_on_redhat.yml b/roles/ceph-common/tasks/installs/install_on_redhat.yml index 93e6d045d..56b3c9121 100644 --- a/roles/ceph-common/tasks/installs/install_on_redhat.yml +++ b/roles/ceph-common/tasks/installs/install_on_redhat.yml @@ -39,13 +39,67 @@ include: redhat_ceph_repository.yml when: ceph_origin == 'upstream' +- name: make sure /tmp exists + file: + path: /tmp + state: directory + when: + - ceph_origin == 'local' + - use_installer + +- name: use mktemp to create name for rundep + command: "mktemp /tmp/rundep.XXXXXXXX" + register: rundep_location + when: + - ceph_origin == 'local' + - use_installer + +- name: copy rundep + copy: + src: "{{ansible_dir}}/rundep" + dest: "{{ item }}" + with_items: rundep_location.stdout_lines + when: + - ceph_origin == 'local' + - use_installer + +- name: install ceph dependencies + script: "{{ ansible_dir }}/rundep_installer.sh {{ item }}" + become: true + with_items: rundep_location.stdout_lines + when: + - ceph_origin == 'local' + - use_installer + - name: install ceph yum: name: ceph state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}" - when: not use_server_package_split + when: + - not use_server_package_split + - ansible_pkg_mgr == "yum" + - ceph_origin != 'local' -- name: install distro or red hat storage ceph mon +- name: synchronize ceph install + synchronize: + src: "{{ceph_installation_dir}}/" + dest: "/" + when: + - ceph_origin == 'local' + +- name: create user group ceph + group: + name: 'ceph' + when: + - ceph_origin == 'local' + +- name: create user ceph + user: + name: 'ceph' + when: + - ceph_origin == 'local' + +- name: install distro or red hat storage ceph mon via yum yum: name: "ceph-mon" state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}" @@ -57,7 +111,7 @@ or ceph_origin == "distro" or ceph_custom -- name: install distro or red hat storage ceph mon +- name: install distro or red hat storage ceph mon via dnf dnf: name: "ceph-mon" state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}" @@ -69,7 +123,7 @@ or ceph_dev or ceph_custom -- name: install distro or red hat storage ceph osd +- name: install distro or red hat storage ceph osd via yum yum: name: "ceph-osd" state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}" @@ -81,7 +135,7 @@ or ceph_dev or ceph_custom -- name: install distro or red hat storage ceph osd +- name: install distro or red hat storage ceph osd via dnf dnf: name: "ceph-osd" state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}" @@ -93,7 +147,7 @@ or ceph_dev or ceph_custom -- name: install distro or red hat storage ceph mds +- name: install distro or red hat storage ceph mds via yum yum: name: "ceph-mds" state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}" @@ -105,7 +159,7 @@ or ceph_dev or ceph_custom -- name: install distro or red hat storage ceph mds +- name: install distro or red hat storage ceph mds via dnf dnf: name: "ceph-mds" state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}" @@ -117,7 +171,7 @@ or ceph_dev or ceph_custom -- name: install distro or red hat storage ceph base +- name: install distro or red hat storage ceph base via yum yum: name: "ceph-base" state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}" @@ -129,7 +183,7 @@ or ceph_dev or ceph_custom -- name: install distro or red hat storage ceph base +- name: install distro or red hat storage ceph base via dnf dnf: name: "ceph-base" state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}" diff --git a/roles/ceph-mon/tasks/deploy_monitors.yml b/roles/ceph-mon/tasks/deploy_monitors.yml index 2f773ce5a..78518b4a3 100644 --- a/roles/ceph-mon/tasks/deploy_monitors.yml +++ b/roles/ceph-mon/tasks/deploy_monitors.yml @@ -53,7 +53,7 @@ - is_after_hammer - name: ceph monitor mkfs without keyring (for or after infernalis release) - command: ceph-mon --setuser ceph --setgroup ceph --mkfs -i {{ monitor_name }} --fsid {{ fsid }} + command: ceph-mon --cluster {{ cluster }} --setuser ceph --setgroup ceph --mkfs -i {{ monitor_name }} --fsid {{ fsid }} args: creates: /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/store.db when: diff --git a/roles/ceph-mon/tasks/start_monitor.yml b/roles/ceph-mon/tasks/start_monitor.yml index 9d00eecd3..846c77392 100644 --- a/roles/ceph-mon/tasks/start_monitor.yml +++ b/roles/ceph-mon/tasks/start_monitor.yml @@ -10,13 +10,15 @@ with_items: - done - upstart - when: not use_systemd + when: + - not use_systemd - name: start and add that the monitor service to the init sequence (ubuntu) command: initctl emit ceph-mon cluster={{ cluster }} id={{ monitor_name }} changed_when: false failed_when: false - when: not use_systemd + when: + - not use_systemd # NOTE (leseb): somehow the service ansible module is messing things up # as a safety measure we run the raw command diff --git a/rundep.sample b/rundep.sample new file mode 100644 index 000000000..2f76e1ed6 --- /dev/null +++ b/rundep.sample @@ -0,0 +1,45 @@ +#Package lines can be commented out with '#' +# +#boost-atomic +#boost-chrono +#boost-date-time +#boost-iostreams +#boost-program +#boost-random +#boost-regex +#boost-system +#boost-thread +#bzip2-libs +#cyrus-sasl-lib +#expat +#fcgi +#fuse-libs +#glibc +#hdparm +#keyutils-libs +#leveldb +#libaio +#libatomic_ops +#libattr +#libblkid +#libcap +#libcom_err +#libcurl +#libgcc +#libicu +#libidn +#libnghttp2 +#libpsl +#libselinux +#libssh2 +#libstdc++ +#libunistring +#nss-softokn-freebl +#openldap +#openssl-libs +#pcre +#python-nose +#python-sphinx +#snappy +#systemd-libs +#zlib diff --git a/rundep_installer.sh b/rundep_installer.sh new file mode 100755 index 000000000..6da916231 --- /dev/null +++ b/rundep_installer.sh @@ -0,0 +1,27 @@ +#!/bin/bash -e +# +# Copyright (C) 2014, 2015 Red Hat +# +# Author: Daniel Lin +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# + +if test -f /etc/redhat-release ; then + PACKAGE_INSTALLER=yum +elif type apt-get > /dev/null 2>&1 ; then + PACKAGE_INSTALLER=apt-get +else + echo "ERROR: Package Installer could not be determined" + exit 1 +fi + +while read p; do + if [[ $p =~ ^#.* ]] ; then + continue + fi + $PACKAGE_INSTALLER install $p -y +done < $1