2017-03-18 09:22:07 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: Setup the config files from our templates
|
|
|
|
template:
|
|
|
|
src: "{{ item.src }}"
|
2019-03-10 17:16:34 +00:00
|
|
|
dest: "{{ config_prefix|default('/') }}etc/{{ item.dest }}"
|
2017-03-18 09:22:07 +00:00
|
|
|
owner: "{{ item.owner }}"
|
|
|
|
group: "{{ item.group }}"
|
|
|
|
mode: "{{ item.mode }}"
|
|
|
|
with_items:
|
|
|
|
- src: strongswan.conf.j2
|
2019-03-10 17:16:34 +00:00
|
|
|
dest: "strongswan.conf"
|
2017-03-18 09:22:07 +00:00
|
|
|
owner: root
|
|
|
|
group: "{{ root_group|default('root') }}"
|
|
|
|
mode: "0644"
|
|
|
|
- src: ipsec.conf.j2
|
2019-03-10 17:16:34 +00:00
|
|
|
dest: "ipsec.conf"
|
2017-03-18 09:22:07 +00:00
|
|
|
owner: root
|
|
|
|
group: "{{ root_group|default('root') }}"
|
|
|
|
mode: "0644"
|
|
|
|
- src: ipsec.secrets.j2
|
2019-03-10 17:16:34 +00:00
|
|
|
dest: "ipsec.secrets"
|
2017-03-18 09:22:07 +00:00
|
|
|
owner: strongswan
|
|
|
|
group: "{{ root_group|default('root') }}"
|
|
|
|
mode: "0600"
|
2019-04-09 12:37:08 +00:00
|
|
|
- src: charon.conf.j2
|
|
|
|
dest: "strongswan.d/charon.conf"
|
|
|
|
owner: root
|
|
|
|
group: "{{ root_group|default('root') }}"
|
|
|
|
mode: "0644"
|
2017-03-18 09:22:07 +00:00
|
|
|
notify:
|
|
|
|
- restart strongswan
|
|
|
|
|
|
|
|
- name: Get loaded plugins
|
2019-04-26 15:48:28 +00:00
|
|
|
shell: |
|
|
|
|
set -o pipefail
|
|
|
|
find {{ config_prefix|default('/') }}etc/strongswan.d/charon/ -type f -name '*.conf' -exec basename {} \; |
|
|
|
|
cut -f1 -d.
|
|
|
|
changed_when: false
|
|
|
|
args:
|
|
|
|
executable: bash
|
2017-03-18 09:22:07 +00:00
|
|
|
register: strongswan_plugins
|
|
|
|
|
|
|
|
- name: Disable unneeded plugins
|
2017-05-08 20:34:24 +00:00
|
|
|
lineinfile:
|
|
|
|
dest: "{{ config_prefix|default('/') }}etc/strongswan.d/charon/{{ item }}.conf"
|
|
|
|
regexp: '.*load.*'
|
|
|
|
line: 'load = no'
|
|
|
|
state: present
|
2017-03-18 09:22:07 +00:00
|
|
|
notify:
|
|
|
|
- restart strongswan
|
|
|
|
when: item not in strongswan_enabled_plugins and item not in strongswan_additional_plugins
|
|
|
|
with_items: "{{ strongswan_plugins.stdout_lines }}"
|
|
|
|
|
|
|
|
- name: Ensure that required plugins are enabled
|
|
|
|
lineinfile: dest="{{ config_prefix|default('/') }}etc/strongswan.d/charon/{{ item }}.conf" regexp='.*load.*' line='load = yes' state=present
|
|
|
|
notify:
|
|
|
|
- restart strongswan
|
|
|
|
when: item in strongswan_enabled_plugins or item in strongswan_additional_plugins
|
|
|
|
with_items: "{{ strongswan_plugins.stdout_lines }}"
|