From 46ba09dfc137ad54577781b61a1ae7bdbf32060c Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 5 Aug 2021 18:00:06 +0200 Subject: [PATCH] Update to 2021-08-05 18:00 --- roles/akeneo_pim/tasks/archive_post.yml | 10 ++++++++++ roles/akeneo_pim/tasks/archive_pre.yml | 11 +++++++++++ roles/akeneo_pim/tasks/cleanup.yml | 8 ++++++++ roles/akeneo_pim/tasks/conf.yml | 24 ++++++++++++++++++++++-- roles/akeneo_pim/tasks/install.yml | 16 +++++++--------- roles/akeneo_pim/tasks/main.yml | 3 +++ 6 files changed, 61 insertions(+), 11 deletions(-) create mode 100644 roles/akeneo_pim/tasks/archive_post.yml create mode 100644 roles/akeneo_pim/tasks/cleanup.yml diff --git a/roles/akeneo_pim/tasks/archive_post.yml b/roles/akeneo_pim/tasks/archive_post.yml new file mode 100644 index 0000000..0e1d306 --- /dev/null +++ b/roles/akeneo_pim/tasks/archive_post.yml @@ -0,0 +1,10 @@ +--- + +- name: Compress previous version + command: tar cf {{ pim_root_dir }}/archives/{{ pim_current_version }}.tar.zst ./ --use-compress-program=zstd + args: + chdir: "{{ pim_root_dir }}/archives/{{ pim_current_version }}" + warn: False + environment: + ZSTD_CLEVEL: 10 + tags: pim diff --git a/roles/akeneo_pim/tasks/archive_pre.yml b/roles/akeneo_pim/tasks/archive_pre.yml index c8275a6..82d59af 100644 --- a/roles/akeneo_pim/tasks/archive_pre.yml +++ b/roles/akeneo_pim/tasks/archive_pre.yml @@ -4,6 +4,17 @@ file: path={{ pim_root_dir }}/archives/{{ pim_current_version }} state=directory tags: pim +- name: Stop jobs and event API services + service: name={{ item }} state=stopped + loop: + - akeneo-pim_{{ pim_id }}-jobs + - akeneo-pim_{{ pim_id }}-events-api + tags: pim + +- name: Disable cron jobs + file: path=/etc/cron.d/akeneopim_{{ pim_id }} state=absent + tags: pim + - name: Archive current version synchronize: src: "{{ pim_root_dir }}/app" diff --git a/roles/akeneo_pim/tasks/cleanup.yml b/roles/akeneo_pim/tasks/cleanup.yml new file mode 100644 index 0000000..bcded67 --- /dev/null +++ b/roles/akeneo_pim/tasks/cleanup.yml @@ -0,0 +1,8 @@ +--- + +- name: Remove tmp and obsolete files + file: path={{ item }} state=absent + loop: + - "{{ pim_root_dir }}/archives/{{ pim_current_version }}" + tags: pim + diff --git a/roles/akeneo_pim/tasks/conf.yml b/roles/akeneo_pim/tasks/conf.yml index b67c663..5097311 100644 --- a/roles/akeneo_pim/tasks/conf.yml +++ b/roles/akeneo_pim/tasks/conf.yml @@ -11,16 +11,36 @@ - php_fpm_pool: "{{ pim_php_fpm_pool | default('') }}" tags: pim -- name: Build assets - command: scl enable php{{ pim_php_version }} -- make prod +- name: Build and update frontend components + command: scl enable php{{ pim_php_version }} -- make upgrade-front args: chdir: "{{ pim_root_dir }}/app" environment: NO_DOCKER: true + APP_ENV: prod become_user: "{{ pim_user }}" when: pim_install_mode != 'none' tags: pim +- name: Initialize the database + command: scl enable php{{ pim_php_version }} -- make database O="--catalog vendor/akeneo/pim-community-dev/src/Akeneo/Platform/Bundle/InstallerBundle/Resources/fixtures/minimal" + args: + chdir: "{{ pim_root_dir }}/app" + environment: + NO_DOCKER: true + APP_ENV: prod + become_user: "{{ pim_user }}" + when: pim_install_mode == 'install' + tags: pim + +- name: Upgrade database + command: /bin/php{{ pim_php_version }} {{ pim_root_dir }}/app/bin/console doctrine:migrations:migrate --no-interaction + args: + chdir: "{{ pim_root_dir }}/app" + become_user: "{{ pim_user }}" + when: pim_install_mode == 'upgrade' + tags: pim + - name: Deploy permission script template: src=perms.sh.j2 dest={{ pim_root_dir }}/perms.sh mode=755 register: pim_perm_script diff --git a/roles/akeneo_pim/tasks/install.yml b/roles/akeneo_pim/tasks/install.yml index 2b3bd6d..7ee7281 100644 --- a/roles/akeneo_pim/tasks/install.yml +++ b/roles/akeneo_pim/tasks/install.yml @@ -4,25 +4,21 @@ package: name: - make + - ghostscript + - aspell tags: pim - when: pim_install_mode == 'upgrade' block: - - name: Stop jobs and event API services - service: name={{ item }} state=stopped - loop: - - akeneo-pim_{{ pim_id }}-jobs - - akeneo-pim_{{ pim_id }}-events-api - - - name: Disable cron jobs - file: path=/etc/cron.d/akeneopim_{{ pim_id }} state=absent - - name: Wipe install on upgrades file: path={{ pim_root_dir }}/app state=absent - name: Create app subdir file: path={{ pim_root_dir }}/app state=directory owner={{ pim_user }} group={{ pim_user }} + - name: Link the var directory + file: src={{ pim_root_dir }}/data dest={{ pim_root_dir }}/app/var state=link + tags: pim - when: pim_install_mode != 'none' @@ -43,12 +39,14 @@ name: yarn path: "{{ pim_root_dir }}/app" global: True + state: latest - name: Install typescript globaly npm: name: typescript path: "{{ pim_root_dir }}/app" global: True + state: latest tags: pim diff --git a/roles/akeneo_pim/tasks/main.yml b/roles/akeneo_pim/tasks/main.yml index 8ef41bb..a541d76 100644 --- a/roles/akeneo_pim/tasks/main.yml +++ b/roles/akeneo_pim/tasks/main.yml @@ -8,3 +8,6 @@ - include: install.yml - include: conf.yml - include: write_version.yml +- include: archive_post.yml + when: pim_install_mode == 'upgrade' +- include: cleanup.yml