From 8fb8af6b8b2e9fcc777ccb5dd8d4832197c1477c Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Wed, 9 Sep 2015 12:45:42 -0600 Subject: [PATCH] Add role to deploy pulpito Signed-off-by: Zack Cerza --- roles/pulpito/README.rst | 19 ++++++ roles/pulpito/defaults/main.yml | 1 + roles/pulpito/tasks/apt_systems.yml | 11 +++ roles/pulpito/tasks/main.yml | 100 ++++++++++++++++++++++++++++ roles/pulpito/tasks/yum_systems.yml | 9 +++ roles/pulpito/vars/apt_systems.yml | 10 +++ roles/pulpito/vars/yum_systems.yml | 10 +++ 7 files changed, 160 insertions(+) create mode 100644 roles/pulpito/README.rst create mode 100644 roles/pulpito/defaults/main.yml create mode 100644 roles/pulpito/tasks/apt_systems.yml create mode 100644 roles/pulpito/tasks/main.yml create mode 100644 roles/pulpito/tasks/yum_systems.yml create mode 100644 roles/pulpito/vars/apt_systems.yml create mode 100644 roles/pulpito/vars/yum_systems.yml diff --git a/roles/pulpito/README.rst b/roles/pulpito/README.rst new file mode 100644 index 00000000..17566a15 --- /dev/null +++ b/roles/pulpito/README.rst @@ -0,0 +1,19 @@ +Pulpito +======= + +This role is used to configure a node to run pulpito_. + +It has been tested on: + +- CentOS 7.x +- Debian 8.x (Jessie) +- Ubuntu 14.04 (Trusty) + +Dependencies +++++++++++++ + +Since pulpito_ is only useful as a frontend to paddles_, it requires a paddles_ instance to function. Additonally, you must set ``paddles_address`` in e.g. your secrets repository to the URL of your instance. + + +.. _pulpito: https://github.com/ceph/pulpito +.. _paddles: https://github.com/ceph/paddles diff --git a/roles/pulpito/defaults/main.yml b/roles/pulpito/defaults/main.yml new file mode 100644 index 00000000..77ee93d0 --- /dev/null +++ b/roles/pulpito/defaults/main.yml @@ -0,0 +1 @@ +pulpito_repo: https://github.com/ceph/pulpito.git diff --git a/roles/pulpito/tasks/apt_systems.yml b/roles/pulpito/tasks/apt_systems.yml new file mode 100644 index 00000000..899200c3 --- /dev/null +++ b/roles/pulpito/tasks/apt_systems.yml @@ -0,0 +1,11 @@ +--- +- name: Install packages via apt + apt: + name: "{{ item }}" + state: latest + update_cache: yes + cache_valid_time: 600 + no_log: true + with_items: "{{ pulpito_extra_packages }}" + tags: + - packages diff --git a/roles/pulpito/tasks/main.yml b/roles/pulpito/tasks/main.yml new file mode 100644 index 00000000..8590eff6 --- /dev/null +++ b/roles/pulpito/tasks/main.yml @@ -0,0 +1,100 @@ +--- +- name: Include package type specific vars. + include_vars: "{{ ansible_pkg_mgr }}_systems.yml" + tags: + - always + +- include: yum_systems.yml + when: ansible_pkg_mgr == "yum" + +- include: apt_systems.yml + when: ansible_pkg_mgr == "apt" + +- name: Create the user + user: + name: pulpito + state: present + shell: /bin/bash + +- name: Set repo location + set_fact: + pulpito_repo_path: "/home/pulpito/pulpito" + +- name: Checkout the repo + git: + repo: "{{ pulpito_repo }}" + dest: "{{ pulpito_repo_path }}" + sudo_user: pulpito + +- name: Look for the virtualenv + stat: + path: "{{ pulpito_repo_path }}/virtualenv" + get_checksum: no + get_md5: no + register: virtualenv + +- name: Create the virtualenv + shell: virtualenv ./virtualenv chdir={{ pulpito_repo_path }} + sudo_user: pulpito + when: virtualenv.stat.exists == false + +- name: Install requirements via pip + pip: + chdir: "{{ pulpito_repo_path }}" + requirements: "./requirements.txt" + virtualenv: "{{ pulpito_repo_path }}/virtualenv" + no_log: true + sudo_user: pulpito + +- name: Check for pulpito config + stat: + path: "{{ pulpito_repo_path }}/prod.py" + get_checksum: no + get_md5: no + register: pulpito_config + +- name: Copy pulpito config + shell: cp ./config.py.in prod.py chdir={{ pulpito_repo_path }} + when: pulpito_config.stat.exists == false + sudo_user: pulpito + +- name: Set paddles_address + lineinfile: + dest: "{{ pulpito_repo_path }}/prod.py" + regexp: "^paddles_address = " + line: "paddles_address = '{{ paddles_address|mandatory }}'" + when: pulpito_config.stat.exists == false + +- name: Enable supervisord + service: + name: "{{ supervisor_service }}" + enabled: yes + state: started + +- name: Set supervisord config path + set_fact: + supervisor_conf_path: "{{ supervisor_conf_d }}/pulpito.{{ supervisor_conf_suffix }}" + +- name: Look for supervisord config + stat: + path: "{{ supervisor_conf_path }}" + get_checksum: no + get_md5: no + register: supervisor_conf + +- name: Copy supervisord config + shell: cp ./supervisord_pulpito.conf {{ supervisor_conf_path }} chdir={{ pulpito_repo_path }} + when: supervisor_conf.stat.exists == false + register: supervisor_conf + +- name: Read supervisord config + command: supervisorctl update + when: supervisor_conf|changed + +- name: Check if pulpito is running + command: supervisorctl status pulpito + register: pulpito_status + +- name: Wait for pulpito to start + wait_for: + port: 8081 diff --git a/roles/pulpito/tasks/yum_systems.yml b/roles/pulpito/tasks/yum_systems.yml new file mode 100644 index 00000000..1f6624fd --- /dev/null +++ b/roles/pulpito/tasks/yum_systems.yml @@ -0,0 +1,9 @@ +--- +- name: Install packages via yum + yum: + name: "{{ item }}" + state: latest + no_log: true + with_items: "{{ pulpito_extra_packages }}" + tags: + - packages diff --git a/roles/pulpito/vars/apt_systems.yml b/roles/pulpito/vars/apt_systems.yml new file mode 100644 index 00000000..00a6a150 --- /dev/null +++ b/roles/pulpito/vars/apt_systems.yml @@ -0,0 +1,10 @@ +--- +pulpito_extra_packages: + - git-core + - supervisor + - python-pip + - python-virtualenv + +supervisor_service: supervisor +supervisor_conf_d: /etc/supervisor/conf.d/ +supervisor_conf_suffix: conf diff --git a/roles/pulpito/vars/yum_systems.yml b/roles/pulpito/vars/yum_systems.yml new file mode 100644 index 00000000..1a9678d3 --- /dev/null +++ b/roles/pulpito/vars/yum_systems.yml @@ -0,0 +1,10 @@ +--- +pulpito_extra_packages: + - git-all + - supervisor + - python-pip + - python-virtualenv + +supervisor_service: supervisord +supervisor_conf_d: /etc/supervisord.d +supervisor_conf_suffix: ini -- 2.47.3