---
# Tasks to automate the stuffing of default Drupal VM variables for synced
# folders, databases, and webhosts. I pulled the arcane "union" syntax from
# https://github.com/ansible/ansible/pull/8019#issuecomment-152079657

- name: Programmatically add synced folders for all regular sites, plus one for
    the UCSF multisite, sorted alphabetically.
  with_items: "{{ (sites + ['ucsf'])|sort }}"
  set_fact:
    vagrant_synced_folders: "{{ vagrant_synced_folders|union([{
      'local_path':  sites_path + '/' + item,
      'destination': '/var/www/' + item,
      'type':        'nfs',
      'create':      true,
    }]) }}"

- name: Programmatically add database and webhost config for all regular sites
    and UCSF multisites, sorted alphabetically.
  with_items: "{{ (sites + ucsf_multisites)|sort }}"
  set_fact:
    mysql_databases: "{{ mysql_databases|union([{
      'name':      item + '_drupalvm',
      'encoding':  'utf8mb4',
      'collation': 'utf8mb4_general_ci',
    }]) }}"
    nginx_hosts: "{{ nginx_hosts|union([{
      'server_name': item + '.dvm',
      'root':        '/var/www/ucsf' if item in ucsf_multisites else '/var/www/' + item,
      'is_php':      true,
    }]) }}"

Add programmatic site configuration to Ansible
Add programmatic site configuration to Ansible

This task pulls the site list from `config.yml` and stuffs all the
appropriate Drupal VM variables for database, webhost, and synced folder
configurations.
