---
output_dir: "/home/ubuntu/auth_mellon"
endpoint_url: "{{sp_protocol }}{{ sp_hostname }}/{{ sp_path }}"
entity_id: "{{ endpoint_url }}/metadata{% if sp_random_part != '' %}-\
            {{ sp_random_part }}{% endif %}"

sp_files:
  - { src: "{{ output_dir }}/{{ sp_hostname }}.xml",
      dest: "/etc/apache2/mellon/sp-metadata.xml",
      mode: "0644"
    }
  - { src: "{{ output_dir }}/{{ sp_hostname }}.key",
      dest: "/etc/apache2/mellon/sp-private-key.pem",
      mode: "0600"
    }
  - { src: "{{ output_dir }}/{{ sp_hostname }}.cert",
      dest: "/etc/apache2/mellon/sp-cert.pem",
      mode: "0600"
    }

auth_mellon_templates:
  - { src: auth-mellon.conf.j2,
      dest: /etc/apache2/conf-available/auth-mellon.conf
    }
  - { src: mod_auth_mellon.conf.j2,
      dest: /etc/apache2/mellon/mod_auth_mellon.conf
    }

---
output_dir: "/home/ubuntu/auth_mellon"
endpoint_url: "{{sp_protocol }}{{ sp_hostname }}/{{ sp_path }}"
entity_id: "{{ endpoint_url }}/metadata{% if sp_random_part is defined %}-\
            {{ sp_random_part }}{% endif %}"

sp_files:
  - { src: "{{ output_dir }}/{{ sp_hostname }}.xml",
      dest: "/etc/apache2/mellon/sp-metadata.xml",
      mode: "0644"
    }
  - { src: "{{ output_dir }}/{{ sp_hostname }}.key",
      dest: "/etc/apache2/mellon/sp-private-key.pem",
      mode: "0600"
    }
  - { src: "{{ output_dir }}/{{ sp_hostname }}.cert",
      dest: "/etc/apache2/mellon/sp-cert.pem",
      mode: "0600"
    }

auth_mellon_templates:
  - { src: auth-mellon.conf.j2,
      dest: /etc/apache2/conf-available/auth-mellon.conf
    }
  - { src: mod_auth_mellon.conf.j2,
      dest: /etc/apache2/mellon/mod_auth_mellon.conf
    }

Use better check for undefined variables
Use better check for undefined variables
