]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
Add role to deploy pulpito
authorZack Cerza <zack@redhat.com>
Wed, 9 Sep 2015 18:45:42 +0000 (12:45 -0600)
committerZack Cerza <zack@redhat.com>
Wed, 16 Sep 2015 00:17:36 +0000 (18:17 -0600)
Signed-off-by: Zack Cerza <zack@redhat.com>
roles/pulpito/README.rst [new file with mode: 0644]
roles/pulpito/defaults/main.yml [new file with mode: 0644]
roles/pulpito/tasks/apt_systems.yml [new file with mode: 0644]
roles/pulpito/tasks/main.yml [new file with mode: 0644]
roles/pulpito/tasks/yum_systems.yml [new file with mode: 0644]
roles/pulpito/vars/apt_systems.yml [new file with mode: 0644]
roles/pulpito/vars/yum_systems.yml [new file with mode: 0644]

diff --git a/roles/pulpito/README.rst b/roles/pulpito/README.rst
new file mode 100644 (file)
index 0000000..17566a1
--- /dev/null
@@ -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 (file)
index 0000000..77ee93d
--- /dev/null
@@ -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 (file)
index 0000000..899200c
--- /dev/null
@@ -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 (file)
index 0000000..8590eff
--- /dev/null
@@ -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 (file)
index 0000000..1f6624f
--- /dev/null
@@ -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 (file)
index 0000000..00a6a15
--- /dev/null
@@ -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 (file)
index 0000000..1a9678d
--- /dev/null
@@ -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