Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change openvpn_client_config_dir to have openvpn_base_dir as a prefix (Fix Error on default openvpn_client_config_dir #197) #208

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion defaults/main/openvpn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ openvpn_service_name: "openvpn-server@{{ openvpn_config_file }}.service"

# Client config - settings the server will push
openvpn_client_config: false
openvpn_client_config_dir: ccd
openvpn_client_config_dir: "{{ openvpn_base_dir }}/ccd"
openvpn_client_configs: {}
# Example:
# openvpn_client_configs:
Expand Down
10 changes: 5 additions & 5 deletions tasks/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
- name: Create client config directory
ansible.builtin.file:
state: directory
path: "{{ openvpn_base_dir }}/{{ openvpn_client_config_dir }}"
path: "{{ openvpn_client_config_dir }}"
owner: "{{ openvpn_conf_user }}"
group: "{{ openvpn_conf_group }}"
mode: "0755"
Expand All @@ -87,22 +87,22 @@
- name: Create client configs
ansible.builtin.template:
src: client_ccd.j2
dest: "{{ openvpn_base_dir }}/{{ openvpn_client_config_dir }}/{{ item.key }}"
dest: "{{ openvpn_client_config_dir }}/{{ item.key }}"
owner: "{{ openvpn_conf_user }}"
group: "{{ openvpn_conf_group }}"
mode: "0644"
when: openvpn_client_config is truthy
with_dict: "{{ openvpn_client_configs }}"

- name: List client config directory
ansible.builtin.command: "ls -1 {{ openvpn_base_dir }}/{{ openvpn_client_config_dir }}"
ansible.builtin.command: "ls -1 {{ openvpn_client_config_dir }}"
register: __ccd_contents
changed_when: false
when: openvpn_client_config is truthy

- name: Delete undeclared configs in client config directory
ansible.builtin.file:
path: "{{ openvpn_base_dir }}/{{ openvpn_client_config_dir }}/{{ item }}"
path: "{{ openvpn_client_config_dir }}/{{ item }}"
state: absent
when:
- item not in (openvpn_client_configs.keys() | list)
Expand All @@ -111,7 +111,7 @@

- name: Delete client config directory
ansible.builtin.file:
path: "{{ openvpn_base_dir }}/{{ openvpn_client_config_dir }}"
path: "{{ openvpn_client_config_dir }}"
state: absent
when: openvpn_client_config is falsy

Expand Down
Loading