summaryrefslogtreecommitdiffstats
path: root/roles/openvpn/tasks/config.yml
blob: 67fdfa1addbf6d32a45ca7376fe3eb3e355f5517 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
- name: create openvpn configuration directory
  file: path="{{openvpn_dir}}" state=directory

- name: create openvpn key directory
  file: path="{{openvpn_keydir}}" state=directory

- name: create openvpn client config directory
  file: path="{{openvpn_ccdir}}" state=directory
  when: openvpn_servers in group_names

- name: copy templates
  template: src="{{item}}" dest="{{openvpn_ccdir}}/{{ item | basename | regex_replace('\.j2','') }}" owner=root group=root mode="0644"
  with_fileglob: 
    - ../templates/{{ openvpn_config }}/ccd/*
  when: openvpn_servers in group_names

- name: generate cluster templates
  template: src="{{ openvpn_config }}/ccd.j2" dest="{{openvpn_ccdir}}/{{ hostvars[item]['ansible_hostname'] }}" owner=root group=root mode="0644"
  vars:
    id: "{{ hostvars[item]['ands_host_id'] }}"
  with_inventory_hostnames:
    - nodes:!{{openvpn_servers}}
  when: openvpn_servers in group_names

- name: create openvpn config file
  template: src="{{ openvpn_config }}/{{ (openvpn_servers in group_names) | ternary('openvpn_server.j2', 'openvpn_client.j2') }}" dest="{{ openvpn_config_file }}" owner=root group=root
  notify:
    - openvpn