Skip to content
Snippets Groups Projects
main.yml 5.63 KiB
---

- name: Add wp content symlink
  file:
    src: "{{ WP_CONTENT_MOUNT }}"
    path: "{{ wordpress_homedir }}/wp-content"
    state: link
  when: WP_CONTENT_MOUNT != wordpress_homedir + "/wp-content"

- import_tasks: wp-content-repo.yml
  when: WP_CONTENT_REPO_ENABLED

- name: Add uploads symlink
  file:
    src: "{{ WP_UPLOAD_DIR }}"
    path: "{{ wordpress_homedir }}/wp-content/uploads"
    state: link
    # Force this, because the WP UPLOAD DIR is not mounted to the initContainer
    force: yes
  when: WP_UPLOAD_DIR != wordpress_homedir + "/wp-content/uploads"

- name: Download WordPress
  shell: wp {{ cli_args }} core download
          --version="{{ WP_VERSION }}"
          --skip-content --force

- name: Checksum WordPress
  shell: wp {{ cli_args }} core verify-checksums
  register: checksum

- name: Fail if checksum is invalid
  fail:
    msg: "Wordpress Core failed checksums"
  when: checksum is failed

- name: Check if wp-config exists
  stat:
    path: "{{ wordpress_homedir }}/wp-config.php"
  register: config

- name: Prepare wp-config permissions if it exists
  file:
    path: "{{ wordpress_homedir }}/wp-config.php"
    owner: "{{ wp_user }}"
    group: "{{ wp_group }}"
    mode: 0640
  ignore_errors: true
  when: config.stat.exists

- name: Create wp-config from zero
  shell:
    wp {{ cli_args }} config create
          --dbname="{{ DB_NAME }}"
          --dbuser="{{ DB_USER }}"
          --dbpass="{{ DB_PASS }}"
          --dbhost="{{ DB_HOST }}"
          --dbprefix="{{ DB_PREFIX }}"
          --dbcharset="{{ dbcharset }}"
          --dbcollate="{{ dbcollate }}"
          --skip-check
          --force
          --extra-php
  args:
    stdin: |
      /** Set HTTPS on for requests forwarded by the ingress **/
      if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
        $_SERVER['HTTPS'] = 'on';
      if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])){
        $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
      }