From: Zack Cerza Date: Tue, 29 Sep 2015 19:45:03 +0000 (-0600) Subject: teuthology: manage teuthology system users X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6c63105da1d9a3c99e8fd75504ef7464dcbb6fb8;p=ceph-cm-ansible.git teuthology: manage teuthology system users 'teuthology' for scheduling and 'teuthworker' for execution This is intended to mirror our existing setups Signed-off-by: Zack Cerza --- diff --git a/roles/teuthology/README.rst b/roles/teuthology/README.rst new file mode 100644 index 00000000..d8369738 --- /dev/null +++ b/roles/teuthology/README.rst @@ -0,0 +1,21 @@ +Teuthology +========== + +This role is used to manage the main teuthology node in a lab, e.g. +``teuthology.front.sepia.ceph.com``. + +It currently depends on the ``sudo`` and ``users`` roles. + +It also does the following: + +- Install dependencies required for ``teuthology`` +- Create the ``teuthology`` and ``teuthworker`` users which are used for + scheduling and executing tests, respectively +- Clone ``teuthology`` repos into ``~/src/teuthology_master`` under those user accounts +- Run ``teuthology``'s ``bootstrap`` script + +It currently does NOT do these things: + +- Manage crontab entries +- Manage ``teuthology-worker`` processes +- Run ``teuthology-nuke --stale`` diff --git a/roles/teuthology/defaults/main.yml b/roles/teuthology/defaults/main.yml new file mode 100644 index 00000000..430055f0 --- /dev/null +++ b/roles/teuthology/defaults/main.yml @@ -0,0 +1,8 @@ +--- +teuthology_users: + # for scheduling tests + - teuthology + # for executing tests + - teuthworker + +teuthology_repo: https://github.com/ceph/teuthology.git diff --git a/roles/teuthology/tasks/apt_systems.yml b/roles/teuthology/tasks/apt_systems.yml new file mode 100644 index 00000000..fb703809 --- /dev/null +++ b/roles/teuthology/tasks/apt_systems.yml @@ -0,0 +1,15 @@ +--- +- name: Include package type specific vars. + include_vars: "apt_systems.yml" + tags: + - always + +- name: Install packages via apt + apt: + name: "{{ item }}" + state: latest + update_cache: yes + cache_valid_time: 600 + with_items: "{{ teuthology_extra_packages }}" + tags: + - packages diff --git a/roles/teuthology/tasks/main.yml b/roles/teuthology/tasks/main.yml new file mode 100644 index 00000000..a4bc92a5 --- /dev/null +++ b/roles/teuthology/tasks/main.yml @@ -0,0 +1,10 @@ +--- +- include: apt_systems.yml + when: ansible_pkg_mgr == "apt" + +# Yum systems support is not implemented yet. +- include: yum_systems.yml + when: ansible_pkg_mgr == "yum" + +# Set up the different users that teuthology uses +- include: setup_users.yml diff --git a/roles/teuthology/tasks/setup_users.yml b/roles/teuthology/tasks/setup_users.yml new file mode 100644 index 00000000..620a3062 --- /dev/null +++ b/roles/teuthology/tasks/setup_users.yml @@ -0,0 +1,43 @@ +--- +- name: Create users + user: + name: "{{ item }}" + state: present + shell: /bin/bash + with_items: "{{ teuthology_users }}" + tags: + - user + +- name: Clone the teuthology repo + git: + repo: "{{ teuthology_repo }}" + dest: /home/{{ item }}/src/teuthology_master + sudo_user: "{{ item }}" + with_items: "{{ teuthology_users }}" + tags: + - repos + +- name: Run bootstrap + shell: NO_CLOBBER=true ./bootstrap + args: + chdir: /home/{{ item }}/src/teuthology_master/ + sudo_user: "{{ item }}" + with_items: "{{ teuthology_users }}" + register: bootstrap + changed_when: bootstrap.stdout_lines[-1]|length > 60 + +- name: Add teuthology scripts to PATH + lineinfile: + dest: /home/{{ item }}/.profile + regexp: teuthology_master + line: 'PATH="$HOME/src/teuthology_master/virtualenv/bin:$PATH"' + sudo_user: "{{ item }}" + with_items: "{{ teuthology_users }}" + +- name: Ensure teuthology is usable + shell: "./teuthology --version" + args: + chdir: /home/{{ item }}/src/teuthology_master/virtualenv/bin/ + sudo_user: "{{ item }}" + with_items: "{{ teuthology_users }}" + changed_when: false diff --git a/roles/teuthology/tasks/yum_systems.yml b/roles/teuthology/tasks/yum_systems.yml new file mode 100644 index 00000000..78a67105 --- /dev/null +++ b/roles/teuthology/tasks/yum_systems.yml @@ -0,0 +1,3 @@ +--- +- fail: + msg: "yum systems are not supported at this time" diff --git a/roles/teuthology/vars/apt_systems.yml b/roles/teuthology/vars/apt_systems.yml new file mode 100644 index 00000000..5711d6fa --- /dev/null +++ b/roles/teuthology/vars/apt_systems.yml @@ -0,0 +1,15 @@ +--- +teuthology_extra_packages: + # The following packages are requirements for bootstrapping teuthology + - git-all + - python-dev + - python-pip + - python-virtualenv + - libevent-dev + - python-libvirt + - beanstalkd + # The following packages are requirements for running teuthology + - libmysqlclient-dev + - libffi-dev + - libssl-dev + - libyaml-dev diff --git a/roles/teuthology/vars/yum_systems.yml b/roles/teuthology/vars/yum_systems.yml new file mode 100644 index 00000000..ed97d539 --- /dev/null +++ b/roles/teuthology/vars/yum_systems.yml @@ -0,0 +1 @@ +---