]> git.apps.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
Add zypper support for pulpito role 416/head
authorKyr Shatskyy <kyrylo.shatskyy@gmail.com>
Wed, 3 Oct 2018 14:21:26 +0000 (16:21 +0200)
committerKyr Shatskyy <kyrylo.shatskyy@gmail.com>
Wed, 3 Oct 2018 14:21:26 +0000 (16:21 +0200)
Signed-off-by: Kyr Shatskyy<kyrylo.shatskyy@suse.com>
roles/pulpito/defaults/main.yml
roles/pulpito/tasks/main.yml
roles/pulpito/tasks/setup_pulpito.yml [new file with mode: 0644]
roles/pulpito/tasks/zypper_systems.yml [new file with mode: 0644]
roles/pulpito/vars/zypper_systems.yml [new file with mode: 0644]

index 77ee93d07e450aed7272c386388a45abc5222518..5cfbba158e1e52eb046be8596e22da1c3fe18495 100644 (file)
@@ -1 +1,2 @@
 pulpito_repo: https://github.com/ceph/pulpito.git
+pulpito_user: pulpito
index d890fe68985516ca2d5ecfd9873df92b51e5cbae..ea4f8614fdc10ea27c4fe571043010a6beb382cf 100644 (file)
 - import_tasks: apt_systems.yml
   when: ansible_pkg_mgr == "apt"
 
+- import_tasks: zypper_systems.yml
+  when: ansible_pkg_mgr == "zypper"
+
 - name: Create the user
   user:
-    name: pulpito
+    name: "{{ pulpito_user }}"
     state: present
     shell: /bin/bash
+  tags:
+    - user
 
 - name: Set repo location
   set_fact:
-    pulpito_repo_path: "/home/pulpito/pulpito"
-
-- name: Checkout the repo
-  git:
-    repo: "{{ pulpito_repo }}"
-    dest: "{{ pulpito_repo_path }}"
-  become_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 }}
-  become_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
-  become_user: pulpito
-
-- name: Check for pulpito config
-  stat:
-    path: "{{ pulpito_repo_path }}/prod.py"
-    get_checksum: no
-    get_md5: no
-  register: pulpito_config
+    pulpito_repo_path: "/home/{{ pulpito_user }}/pulpito"
 
-- name: Copy pulpito config
-  shell: cp ./config.py.in prod.py chdir={{ pulpito_repo_path }}
-  when: pulpito_config.stat.exists == false
-  become_user: pulpito
+# Set up the actual pulpito project
+- import_tasks: setup_pulpito.yml
 
-- name: Set paddles_address
-  lineinfile:
-    dest: "{{ pulpito_repo_path }}/prod.py"
-    regexp: "^paddles_address = "
-    line: "paddles_address = '{{ paddles_address|mandatory }}'"
-  register: pulpito_config
 
 - name: Enable supervisord
   service:
@@ -89,7 +53,7 @@
 
 - name: Read supervisord config
   command: supervisorctl update
-  when: supervisor_conf|changed
+  when: supervisor_conf is changed
 
 - name: Check if pulpito is running
   command: supervisorctl status pulpito
   supervisorctl:
     name: pulpito
     state: restarted
-  when: pulpito_status.stdout|match('.*RUNNING.*') and pulpito_config|changed
+  when: pulpito_status.stdout is match('.*RUNNING.*') and pulpito_config is changed
 
 - name: Wait for pulpito to start
   wait_for:
diff --git a/roles/pulpito/tasks/setup_pulpito.yml b/roles/pulpito/tasks/setup_pulpito.yml
new file mode 100644 (file)
index 0000000..ebf0a4e
--- /dev/null
@@ -0,0 +1,56 @@
+---
+- name: Checkout the repo
+  git:
+    repo: "{{ pulpito_repo }}"
+    dest: "{{ pulpito_repo_path }}"
+  become_user: "{{ pulpito_user }}"
+  tags:
+    - repos
+
+- 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 }}
+  become_user: "{{ pulpito_user }}"
+  when: virtualenv.stat.exists == false
+
+- name: Self-upgrade pip
+  pip:
+    name: "pip"
+    state: "latest"
+    chdir: "{{ pulpito_repo_path }}"
+    virtualenv: "{{ pulpito_repo_path }}/virtualenv"
+  become_user: "{{ pulpito_user }}"
+
+- name: Install requirements via pip
+  pip:
+    chdir: "{{ pulpito_repo_path }}"
+    requirements: "./requirements.txt"
+    virtualenv: "{{ pulpito_repo_path }}/virtualenv"
+  #no_log: true
+  become_user: "{{ pulpito_user }}"
+
+- 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
+  become_user: "{{ pulpito_user }}"
+
+- name: Set paddles_address
+  lineinfile:
+    dest: "{{ pulpito_repo_path }}/prod.py"
+    regexp: "^paddles_address = "
+    line: "paddles_address = '{{ paddles_address|mandatory }}'"
+  register: pulpito_config
+
diff --git a/roles/pulpito/tasks/zypper_systems.yml b/roles/pulpito/tasks/zypper_systems.yml
new file mode 100644 (file)
index 0000000..fe3505b
--- /dev/null
@@ -0,0 +1,10 @@
+---
+- name: Install packages via zypper
+  zypper:
+    name: "{{ item }}"
+    state: latest
+    update_cache: yes
+  #no_log: true
+  with_items: "{{ pulpito_extra_packages }}"
+  tags:
+    - packages
diff --git a/roles/pulpito/vars/zypper_systems.yml b/roles/pulpito/vars/zypper_systems.yml
new file mode 100644 (file)
index 0000000..86df055
--- /dev/null
@@ -0,0 +1,10 @@
+---
+pulpito_extra_packages:
+  - git
+  - python-pip
+  - python-virtualenv
+  - supervisor
+
+supervisor_service: supervisord
+supervisor_conf_d: /etc/supervisord.d/
+supervisor_conf_suffix: conf