diff --git a/roles/akeneo_pim/defaults/main.yml b/roles/akeneo_pim/defaults/main.yml index 42aabe0..70c5e48 100644 --- a/roles/akeneo_pim/defaults/main.yml +++ b/roles/akeneo_pim/defaults/main.yml @@ -28,9 +28,9 @@ pim_db_user: akeneopim_{{ pim_id }} # Elasticsearch host pim_es_server: localhost:9200 -# Public URL used to reach AKeneo -pim_public_url: http://{{ inventory_hostname }}/pim_{{ pim_id }} +# Public URL used to reach AKeneo. Note that you'll have to define a vhost for Akeneo PIM to be reachable +pim_public_url: http://pim.{{ inventory_hostname }}/ -# If defined, an alias will be added in httpd's config to access pim -# Else, you'll have to defined a vhost to make pim accessible. See httpd_common role -pim_web_alias: /pim_{{ pim_id }} +# Define the initial admin password. If not defined, a random one will be generated ans stored under {{ pim_root_dir }}/meta/ansible_admin_pass +# Note that this is only used on initial install, and will be ignored for upgrades +# pim_admin_pass: p@ssw0rd diff --git a/roles/akeneo_pim/tasks/archive_pre.yml b/roles/akeneo_pim/tasks/archive_pre.yml index e1e495f..c8275a6 100644 --- a/roles/akeneo_pim/tasks/archive_pre.yml +++ b/roles/akeneo_pim/tasks/archive_pre.yml @@ -19,6 +19,7 @@ name: "{{ pim_db_name }}" target: "{{ pim_root_dir }}/archives/{{ pim_current_version }}/{{ pim_db_name }}.sql.xz" login_host: "{{ pim_db_server }}" + login_port: "{{ pim_db_port }}" login_user: "{{ pim_db_user }}" login_password: "{{ pim_db_pass }}" quick: True diff --git a/roles/akeneo_pim/tasks/conf.yml b/roles/akeneo_pim/tasks/conf.yml index e9770ff..b67c663 100644 --- a/roles/akeneo_pim/tasks/conf.yml +++ b/roles/akeneo_pim/tasks/conf.yml @@ -86,4 +86,12 @@ hour: '*/2' tags: pim +- name: Create the admin user + command: /bin/php{{ pim_php_version }} {{ pim_root_dir }}/app/bin/console pim:user:create --admin -n -- admin {{ pim_admin_pass | quote }} admin@example.org Admin Admin fr_FR + when: pim_install_mode == 'install' + become_user: "{{ pim_user }}" + tags: pim +- name: Deploy logrotate conf + template: src=logrotate.conf.j2 dest=/etc/logrotate.d/akeneopim_{{ pim_id }} + tags: pim diff --git a/roles/akeneo_pim/tasks/directories.yml b/roles/akeneo_pim/tasks/directories.yml index b444c78..906ef60 100644 --- a/roles/akeneo_pim/tasks/directories.yml +++ b/roles/akeneo_pim/tasks/directories.yml @@ -24,3 +24,7 @@ group: "{{ pim_user }}" mode: 700 tags: pim + +- name: Link the var directory to the data dir + file: src={{ pim_root_dir }}/data dest={{ pim_root_dir }}/app/var state=link + tags: pim diff --git a/roles/akeneo_pim/tasks/facts.yml b/roles/akeneo_pim/tasks/facts.yml index 7ccefd2..ee7b06a 100644 --- a/roles/akeneo_pim/tasks/facts.yml +++ b/roles/akeneo_pim/tasks/facts.yml @@ -27,3 +27,12 @@ - set_fact: pim_secret={{ rand_pass }} when: pim_secret is not defined tags: pim + +# Create a random admin pass if needed +- block: + - import_tasks: ../includes/get_rand_pass.yml + vars: + - pass_file: "{{ pim_root_dir }}/meta/ansible_admin_pass" + - set_fact: pim_admin_pass={{ rand_pass }} + when: pim_admin_pass is not defined + tags: pim diff --git a/roles/akeneo_pim/tasks/install.yml b/roles/akeneo_pim/tasks/install.yml index 8d64b87..2b3bd6d 100644 --- a/roles/akeneo_pim/tasks/install.yml +++ b/roles/akeneo_pim/tasks/install.yml @@ -8,6 +8,15 @@ - 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 diff --git a/roles/akeneo_pim/templates/httpd.conf.j2 b/roles/akeneo_pim/templates/httpd.conf.j2 index 7cd0abb..ed08363 100644 --- a/roles/akeneo_pim/templates/httpd.conf.j2 +++ b/roles/akeneo_pim/templates/httpd.conf.j2 @@ -1,9 +1,3 @@ -{% if pim_web_alias is defined and pim_web_alias != False %} -Alias /{{ pim_web_alias | regex_replace('^/','') }} {{ pim_root_dir }}/app/public -{% else %} -# No alias defined, create a vhost to access it -{% endif %} - AllowOverride All Options FollowSymLinks @@ -22,15 +16,9 @@ Alias /{{ pim_web_alias | regex_replace('^/','') }} {{ pim_root_dir }}/app/publi RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] - # Redirect Trailing Slashes If Not A Folder... - RewriteCond %{REQUEST_FILENAME} !-d - RewriteCond %{REQUEST_URI} (.+)/$ - RewriteRule ^ %1 [L,R=301] - # Send Requests To Front Controller... - RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^ index.php [L] + RewriteRule ^ index.php [QSA,L] Require all denied diff --git a/roles/akeneo_pim/templates/logrotate.conf.j2 b/roles/akeneo_pim/templates/logrotate.conf.j2 new file mode 100644 index 0000000..360d394 --- /dev/null +++ b/roles/akeneo_pim/templates/logrotate.conf.j2 @@ -0,0 +1,6 @@ +{{ pim_root_dir }}/data/logs/*.log { + daily + rotate 90 + compress + missingok +}