deploy_client.yml 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. - name: Configure the client
  2. hosts: localhost
  3. vars_files:
  4. - config.cfg
  5. tasks:
  6. - name: Add the droplet to an inventory group
  7. add_host:
  8. name: "{{ client_ip }}"
  9. groups: client-host
  10. ansible_ssh_user: "{{ ssh_user }}"
  11. vpn_user: "{{ vpn_user }}"
  12. server_ip: "{{ server_ip }}"
  13. - name: Configure the client and install required software
  14. hosts: client-host
  15. gather_facts: false
  16. become: true
  17. vars_files:
  18. - config.cfg
  19. - roles/vpn/defaults/main.yml
  20. pre_tasks:
  21. - name: Get the OS
  22. raw: uname -a
  23. register: distribution
  24. - name: Modify the server name fact
  25. set_fact:
  26. IP_subject_alt_name: "{{ server_ip }}"
  27. - name: Ubuntu Xenial | Install prerequisites
  28. raw: >
  29. test -x /usr/bin/python2.7 ||
  30. sudo apt-get update -qq && sudo apt-get install -qq -y python2.7 &&
  31. sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
  32. changed_when: false
  33. when: "'ubuntu' in distribution.stdout|lower"
  34. - name: Fedora 25 | Install prerequisites
  35. raw: >
  36. test -x /usr/bin/python2.7 ||
  37. sudo dnf install python2 -y &&
  38. sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1 &&
  39. rpm -ql python2-dnf || dnf install python2-dnf -y
  40. changed_when: false
  41. when: "'fedora' in distribution.stdout|lower"
  42. roles:
  43. - { role: client, tags: ['client'] }