- name: AEM Author playbook
  hosts:
  - all

  vars:
    config_name: author

    dispatcher_any:
      - dispatcher_farm_name: "{{ config_name }}"
        dispatcher_farm_clientheaders:
          - "*"
        dispatcher_farm_virtualhosts:
          - "*"
        dispatcher_farm_renders:
          - dispatcher_render_name: rend01
            dispatcher_render_hostname: "{{ linked_author_ip }}"
            dispatcher_render_port: "{{ aem_port }}"
            dispatcher_render_timeout: 0
            dispatcher_render_secure: 0
        dispatcher_farm_filters:
          - '# allow everything'
          - '/0001 { /glob "*" /type "allow" }'
        dispatcher_farm_docroot: "{{ docroot_base_dir }}/{{ config_name }}"
        dispatcher_farm_statfileslevel: 0
        dispatcher_farm_allowAuthorized: 0
        dispatcher_farm_serveStaleOnError: 0
        dispatcher_farm_cache_rules:
          - '/0000 { /type "deny" /glob "*" }'
        dispatcher_farm_invalidate:
          - '/0000 { /type "deny"  /glob "*" }'
        dispatcher_farm_allowedClients:
          - '/0000 { /type "allow"  /glob "*" }'

    vhosts:
      - servername: "{{ config_name }}"
        docroot: "{{ docroot_base_dir }}/{{ config_name }}"
        serveralias:
          - "test-author.3sharecorp.com"
          - "*auth*"
        custom_directives:
          - "# Redirect all traffic to HTTPS"
          - "RewriteCond %{HTTP:X-Forwarded-Proto} !https"
          - "RewriteCond %{HTTPS} !=on"
          - "RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]"          
        logname: author
        log_dir: "{{ logs_base_dir }}"
        ssl:
          - "SSLCertificateFile       ssl/3share.crt"
          - "SSLCertificateKeyFile    ssl/3share.key"
          - "SSLCertificateChainFile  ssl/3share.ca.crt"

    ssl_files:
      - 3share.crt
      - 3share.key
      - 3share.ca.crt


  tasks:
  - name: AEM | Install local apache instance
    when: install_local_author_apache
    set_fact:
      install_local_apache: true

  - include: aem_tasks.yml
  - include: apache_tasks.yml
    when: install_local_apache
