Set variable according to result of another variable?

If I:

  • name: Copy SSL cert
    copy: src={{ ansible_hostname if ansible_hostname in valid_hosts else (‘test’) }}.crt
    dest=/etc/pki/tls/certs/
    mode=0644

How can I capture the name of the certificate that was actually copied for action in another task?

- name: Copy SSL cert
  copy: src={{ ansible_hostname if ansible_hostname in valid_hosts else
  ('test') }}.crt
        dest=/etc/pki/tls/certs/
        mode=0644
  register: cert_copy

- debug: var=cert_copy

http://docs.ansible.com/playbooks_variables.html#registered-variables

Giovanni