---
- name: Configure the client
  hosts: localhost
  become: false
  vars_files:
    - config.cfg

  tasks:
    - name: Add the droplet to an inventory group
      add_host:
        name: "{{ client_ip }}"
        groups: client-host
        ansible_ssh_user: "{{ 'root' if client_ip == 'localhost' else ssh_user }}"
        vpn_user: "{{ vpn_user }}"
        IP_subject_alt_name: "{{ server_ip }}"
        ansible_python_interpreter: /usr/bin/python3

- name: Configure the client and install required software
  hosts: client-host
  gather_facts: false
  become: true
  vars_files:
    - config.cfg
    - roles/strongswan/defaults/main.yml
  roles:
    - role: client
