From: Kyr Shatskyy Date: Wed, 3 Oct 2018 14:21:26 +0000 (+0200) Subject: Add zypper support for pulpito role X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=64f533882379106ce92a0fdc00fb7aae402e9cc5;p=ceph-cm-ansible.git Add zypper support for pulpito role Signed-off-by: Kyr Shatskyy --- diff --git a/roles/pulpito/defaults/main.yml b/roles/pulpito/defaults/main.yml index 77ee93d0..5cfbba15 100644 --- a/roles/pulpito/defaults/main.yml +++ b/roles/pulpito/defaults/main.yml @@ -1 +1,2 @@ pulpito_repo: https://github.com/ceph/pulpito.git +pulpito_user: pulpito diff --git a/roles/pulpito/tasks/main.yml b/roles/pulpito/tasks/main.yml index d890fe68..ea4f8614 100644 --- a/roles/pulpito/tasks/main.yml +++ b/roles/pulpito/tasks/main.yml @@ -10,60 +10,24 @@ - 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 @@ -100,7 +64,7 @@ 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 index 00000000..ebf0a4e7 --- /dev/null +++ b/roles/pulpito/tasks/setup_pulpito.yml @@ -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 index 00000000..fe3505b5 --- /dev/null +++ b/roles/pulpito/tasks/zypper_systems.yml @@ -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 index 00000000..86df0552 --- /dev/null +++ b/roles/pulpito/vars/zypper_systems.yml @@ -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