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 934aacd..6c9fb2b 100644 --- a/tasks/install-nvm.yml +++ b/tasks/install-nvm.yml @@ -18,17 +18,12 @@ 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" - become: true - become_user: "{{ kpi_system_user }}" args: chdir: "{{ kpi_checkout_path }}" 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 6d17980..c3ca2cc 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -11,24 +11,40 @@ - name: Install NVM and Global Node Packages include_tasks: install-nvm.yml + args: + apply: + become: true + become_user: "{{ kpi_system_user }}" tags: - - nvm + - 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 - command: "{{ kpi_nvm_npm_path }} run copy-fonts && {{ kpi_nvm_npm_path }} run build" +- name: Build client code (run copy-fonts) + become: true + become_user: "{{ kpi_system_user }}" + 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 }}" + +- 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: - 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 - name: Change ownership of all the KPI files file: @@ -38,13 +54,18 @@ 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