---
- name: Run inventory to add supplemental node
  hosts: undercloud
  gather_facts: false
  tags:
    - freeipa-setup
  tasks:

    - include_role:
        name: tripleo-inventory
      vars:
        inventory: extra_node

    - name: Add supplemental IP to /etc/hosts
      lineinfile:
        line: "{{ supplemental_node_ip }}  {{ freeipa_server_hostname }}"
        path: /etc/hosts
      become: true

    - name: set the freeipa_internal_ip
      set_fact:
        freeipa_internal_ip: "{{ supplemental_node_ip }}"
        cacheable: true

- name: Deploy the FreeIPA server
  hosts: supplemental
  gather_facts: true
  tags:
    - freeipa-setup
  tasks:

    - include_role:
        name: repo-setup
      vars:
        repo_setup_dir: /home/{{ supplemental_user|default('centos') }}

    - name: Set eth2 public IP address
      shell: |
        ip a add dev eth2 {{ supplemental_node_ip }}/24;
        ip l set eth2 up;
        ip link set dev eth2 mtu 1450;
        ping 10.0.0.1 -c 4 -q;
      become: true

    - include_role:
        name: freeipa-setup
