From 4e20615e03dadef5331d18dd05b3589cd463a768 Mon Sep 17 00:00:00 2001 From: Davis Raymond Muro Date: Thu, 2 Dec 2021 10:59:11 +0300 Subject: [PATCH 1/4] Run tasks as KPI user --- tasks/install-nvm.yml | 2 -- tasks/main.yml | 19 +++++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/tasks/install-nvm.yml b/tasks/install-nvm.yml index 934aacd..c7336e5 100644 --- a/tasks/install-nvm.yml +++ b/tasks/install-nvm.yml @@ -23,8 +23,6 @@ - name: Install npm dependencies in package.json # noqa 301 command: "{{ kpi_nvm_npm_path }} install" - become: true - become_user: "{{ kpi_system_user }}" args: chdir: "{{ kpi_checkout_path }}" environment: diff --git a/tasks/main.yml b/tasks/main.yml index 6d17980..6dddcb0 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -11,16 +11,24 @@ - name: Install NVM and Global Node Packages include_tasks: install-nvm.yml + args: + apply: + become: true + become_user: "{{ kpi_system_user }}" tags: - nvm - name: Copy client-side config file + become: true + become_user: "{{ kpi_system_user }}" template: src: templates/kpi/config.es6.j2 dest: "{{ kpi_static_path }}/js/config.es6" mode: 0644 - name: Build client code # noqa 301 + become: true + become_user: "{{ kpi_system_user }}" command: "{{ kpi_nvm_npm_path }} run copy-fonts && {{ kpi_nvm_npm_path }} run build" args: chdir: "{{ kpi_checkout_path }}" @@ -38,13 +46,20 @@ recurse: true - name: Migrate and collect static files + become: true + become_user: "{{ kpi_system_user }}" django_manage: command: "{{ item }}" app_path: "{{ kpi_checkout_path }}" virtualenv: "{{ kpi_venv_path }}" settings: "{{ kpi_settings_app_name }}" with_items: "{{ kpi_django_setup_commands }}" - become: true - become_user: "{{ kpi_system_user }}" notify: - restart_service + +- name: Ensure all KPI files are owned by the KPI user + file: + path: "{{ kpi_checkout_path }}" + owner: "{{ kpi_system_user }}" + group: "{{ kpi_system_group }}" + recurse: true From 34c65194fc3c921b878407fbf1a4673ecb5ce042 Mon Sep 17 00:00:00 2001 From: apiyo Date: Wed, 10 May 2023 19:18:29 +0300 Subject: [PATCH 2/4] Remove become directives from 'Copy client-side config file' task --- tasks/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 6dddcb0..a07cd34 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -16,24 +16,24 @@ become: true become_user: "{{ kpi_system_user }}" tags: - - nvm + - nvm - name: Copy client-side config file - become: true - become_user: "{{ kpi_system_user }}" + # become: true + # become_user: "{{ kpi_system_user }}" template: src: templates/kpi/config.es6.j2 dest: "{{ kpi_static_path }}/js/config.es6" mode: 0644 -- name: Build client code # noqa 301 +- name: Build client code become: true become_user: "{{ kpi_system_user }}" command: "{{ kpi_nvm_npm_path }} run copy-fonts && {{ kpi_nvm_npm_path }} run build" args: chdir: "{{ kpi_checkout_path }}" environment: - PATH: "{{ kpi_nvm_node_dir }}/bin:{{ ansible_env.PATH }}" + PATH: "{{ kpi_nvm_node_dir }}/bin:{{ ansible_env.PATH }}:{{kpi_system_user_home}}/.virtualenvs/kpi/bin" HOME: "{{ kpi_system_user_home }}" notify: - restart_service From 1b1b408d8b913183805acf54be7064dae9185b1e Mon Sep 17 00:00:00 2001 From: apiyo Date: Thu, 11 May 2023 10:23:03 +0300 Subject: [PATCH 3/4] Split run-build and copy fonts into seperate, consercutive steps --- tasks/main.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index a07cd34..f7974c0 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -26,10 +26,22 @@ dest: "{{ kpi_static_path }}/js/config.es6" mode: 0644 -- name: Build client code +- name: Build client code (run copy-fonts) become: true become_user: "{{ kpi_system_user }}" - command: "{{ kpi_nvm_npm_path }} run copy-fonts && {{ kpi_nvm_npm_path }} run build" + command: "{{ kpi_nvm_npm_path }} run copy-fonts" + args: + chdir: "{{ kpi_checkout_path }}" + environment: + PATH: "{{ kpi_nvm_node_dir }}/bin:{{ ansible_env.PATH }}:{{kpi_system_user_home}}/.virtualenvs/kpi/bin" + HOME: "{{ kpi_system_user_home }}" + notify: + - restart_service + +- name: Build client code (run build) + become: true + become_user: "{{ kpi_system_user }}" + command: "{{ kpi_nvm_npm_path }} run build" args: chdir: "{{ kpi_checkout_path }}" environment: From 801ec5bd1b2a94f2cc14d56d97963c478b4da6ca Mon Sep 17 00:00:00 2001 From: apiyo Date: Fri, 26 Apr 2024 15:06:20 +0300 Subject: [PATCH 4/4] Remove calls to handlers that have not been registered --- meta/main.yml | 2 +- tasks/install-nvm.yml | 5 +---- tasks/main.yml | 6 ------ 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/meta/main.yml b/meta/main.yml index 37fafe5..d6cf66c 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -48,7 +48,7 @@ dependencies: django_pip_paths: "{{ kpi_pip_paths }}" django_pip_packages: "{{ kpi_django_pip_packages }}" django_venv_path: "{{ kpi_venv_path }}" - django_pid_socks_dir: "{{ kpi_pid_socket_dir }}" + django_pid_socks_dir: "{{ kpi_pid_socket_dir }}" django_pid_file: "{{ kpi_pid_file }}" django_wsgi_socket: "{{ kpi_socket_file }}" django_service_group: "{{ kpi_service_group }}" diff --git a/tasks/install-nvm.yml b/tasks/install-nvm.yml index c7336e5..6c9fb2b 100644 --- a/tasks/install-nvm.yml +++ b/tasks/install-nvm.yml @@ -18,8 +18,6 @@ with_items: "{{ kpi_npm_requirements }}" environment: PATH: "{{ kpi_nvm_node_dir }}/bin:{{ ansible_env.PATH }}" - notify: - - restart_service - name: Install npm dependencies in package.json # noqa 301 command: "{{ kpi_nvm_npm_path }} install" @@ -28,5 +26,4 @@ environment: PATH: "{{ kpi_nvm_node_dir }}/bin:{{ ansible_env.PATH }}" HOME: "{{ kpi_system_user_home }}" - notify: - - restart_service + diff --git a/tasks/main.yml b/tasks/main.yml index f7974c0..c3ca2cc 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -35,8 +35,6 @@ environment: PATH: "{{ kpi_nvm_node_dir }}/bin:{{ ansible_env.PATH }}:{{kpi_system_user_home}}/.virtualenvs/kpi/bin" HOME: "{{ kpi_system_user_home }}" - notify: - - restart_service - name: Build client code (run build) become: true @@ -47,8 +45,6 @@ environment: PATH: "{{ kpi_nvm_node_dir }}/bin:{{ ansible_env.PATH }}:{{kpi_system_user_home}}/.virtualenvs/kpi/bin" HOME: "{{ kpi_system_user_home }}" - notify: - - restart_service - name: Change ownership of all the KPI files file: @@ -66,8 +62,6 @@ virtualenv: "{{ kpi_venv_path }}" settings: "{{ kpi_settings_app_name }}" with_items: "{{ kpi_django_setup_commands }}" - notify: - - restart_service - name: Ensure all KPI files are owned by the KPI user file: