---
- name: Configure ssh keys
  hosts: localhost
  tasks:
  - command: find /home/vagrant/sync/vagrant/.vagrant/machines -name private_key
    register: private_keys

  - file:
      src: "{{ item }}"
      dest: "/home/vagrant/.ssh/{{ item | regex_replace('^.*/machines/([^/]*)/.*', '\\1') }}.key"
      state: link
    with_items: "{{ private_keys.stdout_lines }}"


- name: Host bootstrapping
  hosts: all
  roles:
  - role: rhsm-subscription
    when: "{{ deployment_type == 'openshift-enterprise' }}"
  - role: rhsm-repos
    when: "{{ deployment_type == 'openshift-enterprise' }}"
  tasks:
  # Vagrant's "change host name" capability for Fedora/EL
  # maps hostname to loopback, conflicting with hostmanager.
  # We must repair /etc/hosts
  - replace:
      dest: /etc/hosts
      regexp: '^(127\.0\.0\.1\s*)\S*\.example\.com (.*)'
      replace: '\1\2'

- name: Configure ssh keys
  hosts: admin1
  tasks:
  - include: tasks/install_bootstrap_origin.yaml
    when: "{{ deployment_type == 'origin' }}"

  - include: tasks/install_bootstrap_enterprise.yaml
    when: "{{ deployment_type == 'openshift-enterprise' }}"
