diff --git a/roles/proxy/tasks/main.yml b/roles/proxy/tasks/main.yml index fc3af8b..e1d8b9d 100644 --- a/roles/proxy/tasks/main.yml +++ b/roles/proxy/tasks/main.yml @@ -84,3 +84,29 @@ - restart apache2 - meta: flush_handlers + +- name: Set facts for mobileconfigs + set_fact: + proxy_enabled: true + +- name: Register p12 PayloadContent + shell: > + cat /{{ easyrsa_dir }}/easyrsa3//pki/private/{{ item }}.p12 | base64 + register: PayloadContent + with_items: "{{ users }}" + +- name: Register CA PayloadContent + shell: > + cat /{{ easyrsa_dir }}/easyrsa3/pki/ca.crt | base64 + register: PayloadContentCA + +- name: Build the mobileconfigs + template: src=roles/vpn/templates/mobileconfig.j2 dest=/{{ easyrsa_dir }}/easyrsa3//pki/private/{{ item.0 }}_proxy.mobileconfig mode=0600 + with_together: + - "{{ users }}" + - "{{ PayloadContent.results }}" + no_log: True + +- name: Fetch users mobileconfig + fetch: src=/{{ easyrsa_dir }}/easyrsa3//pki/private/{{ item }}_proxy.mobileconfig dest=configs/{{ IP_subject_alt_name }}_{{ item }}_proxy.mobileconfig flat=yes + with_items: "{{ users }}" diff --git a/roles/vpn/tasks/main.yml b/roles/vpn/tasks/main.yml index b152c7a..fbe4b94 100644 --- a/roles/vpn/tasks/main.yml +++ b/roles/vpn/tasks/main.yml @@ -167,6 +167,10 @@ cat /{{ easyrsa_dir }}/easyrsa3/pki/ca.crt | base64 register: PayloadContentCA +- name: Set facts for mobileconfigs + set_fact: + proxy_enabled: false + - name: Build the mobileconfigs template: src=mobileconfig.j2 dest=/{{ easyrsa_dir }}/easyrsa3//pki/private/{{ item.0 }}.mobileconfig mode=0600 with_together: diff --git a/roles/vpn/templates/mobileconfig.j2 b/roles/vpn/templates/mobileconfig.j2 index 3fc3668..be5b071 100644 --- a/roles/vpn/templates/mobileconfig.j2 +++ b/roles/vpn/templates/mobileconfig.j2 @@ -76,12 +76,24 @@ Proxies HTTPEnable - 0 +{% if proxy_enabled is defined and proxy_enabled == true %} + 1 + HTTPPort + 8118 + HTTPProxy + {{ local_service_ip }} + {% else %} + 1 +{% endif %} HTTPSEnable 0 UserDefinedName +{% if proxy_enabled is defined and proxy_enabled == true %} + {{ IP_subject_alt_name }} IKEv2 with proxy + {% else %} {{ IP_subject_alt_name }} IKEv2 +{% endif %} VPNType IKEv2 @@ -129,9 +141,17 @@ PayloadDisplayName +{% if proxy_enabled is defined and proxy_enabled == true %} + {{ IP_subject_alt_name }} IKEv2 with proxy + {% else %} {{ IP_subject_alt_name }} IKEv2 +{% endif %} PayloadIdentifier +{% if proxy_enabled is defined and proxy_enabled == true %} + donut.local.37CA79B1-FC6A-421F-960A-90F91FC983BA + {% else %} donut.local.37CA79B1-FC6A-421F-960A-90F91FC983BE +{% endif %} PayloadRemovalDisallowed PayloadType