diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e1de1f4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +*.swa +*.swp +*.swo + +vagrant +.vagrant + diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d90445a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,19 @@ +--- +language: python +python: "2.7" + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ + +before_install: + - sudo apt-get update -qq + +install: + - sudo pip install ansible==2.3.0.0 + +script: + # Test functionality with default values + - ansible-playbook tests/test_defaults.yml -i localhost, --syntax-check + - ansible-playbook tests/test_defaults.yml -i localhost, --connection=local --sudo + +# vi:ts=2:sw=2:et:ft=yaml diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8dada3e --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..70cda5b --- /dev/null +++ b/README.md @@ -0,0 +1,114 @@ +# Ansible role for StrongSwan + +[![Build Status](https://travis-ci.org/torian/ansible-role-strongswan.svg)](https://travis-ci.org/torian/ansible-role-strongswan) + +An Ansible Role that installs and configures StrongSwan on Red Hat/CentOS or Debian/Ubuntu. + +## Tested On + + * EL / Centos (7 / 6) + * Ubuntu (Xenial / Trusty / Precise) + * Amazon Linux + + +## Role Variables + +Defaults defined in `defaults/main.yml`: + +``` +strongswan_config_file: {{strongswan_prefix}}/ipsec.conf +strongswan_secrets_file: {{strongswan_prefix}}/ipsec.secrets +``` + +The var `strongswan_prefix` is defined based on `ansible_os_family`. + +The `ipsec.conf` file is configured through the following vars (and their default values): + +``` +strongswan_config_setup: + uniqueids: yes + charonstart: yes + charondebug: '' + +strongswan_conn_default: {} + +strongswan_conns: {} +``` + +Secrets are specified using `strongswan_secrets`. It is a list where each +element might contain the following attributes: +``` + left: Optional - Any valid ID selector + right: Optional - Any valid ID selector + type: Optional (defaults to PSK) - any valid secret type + credential: Required - Connection's credentials +``` + +## Usage + +The vars used for the `config setup` and `conn %default` sections are a hash that accept +any valid configuration option for strongswan. An example: + +``` +strongswan_conn_default: + type: tunnel + ikelifetime: 1h + lifetime: 30m + left: 1.2.3.4 +``` + +Connections are configured with `strongswan_conns` hash: + +``` +strongswan_conns: + conn1: + right: 2.3.4.5 + rightsubnet: 2.3.4.0/24 + ike: aes256-sha1-modp1024 + esp: aes256-sha1-modp1024 + auto: start + + conn2: + right: 3.4.5.6 + rightsubnet: 3.4.5.0/24 + auto: route +``` + +Setting up secrets can be done in the following way: + +``` +strongswan_secrets: + - left: 1.2.3.4 + right: 2.3.4.5 + type: PSK + credentials: '"super wooper passw0rd"' + + - right: 3.4.5.6 + type: RSA + credentials: cert.pem +``` + +The double quotes inside the simple ones is meant to escape any special chars. + +`RSA` private keys (or any secret type that requires a key file) might be specified +through `strongswan_private_keys` (TODO): + +``` +strongswan_private_keys: + - filename: cert.pem + key: | + --- begin your key --- + --- end your key --- + - filename: more_secure.pem + key: "{{var_from_a_vault}}" +``` + +## License + +See [License](LICENSE) + + +## Author Information + +This role was created in 2017 by Emiliano Castagnari. + diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..920895d --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,119 @@ +VAGRANTFILE_API_VERSION = '2' + +ANSIBLE_VERSION = "2.3.0.0" + +ANSIBLE_ROLE = 'ansible-role-strongswan' + +EPEL_REPO_6 = ''' +[epel] +name = EPEL 6 - \$basearch +baseurl = http://mirror.globo.com/epel/6/\$basearch +enabled = 1 +gpgcheck = 0 +''' + +EPEL_REPO_7 = ''' +[epel] +name = EPEL 7 - \$basearch +baseurl = http://mirror.globo.com/epel/7/\$basearch +enabled = 1 +gpgcheck = 0 +''' + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + + config.vm.provider :virtualbox do |vb| + vb.gui = false + vb.customize [ 'modifyvm', :id, '--memory', '512' ] + vb.customize [ 'modifyvm', :id, '--nictype1', 'virtio' ] + vb.customize [ 'modifyvm', :id, '--natdnshostresolver1', 'on' ] + vb.customize [ 'modifyvm', :id, '--natdnsproxy1', 'on' ] + end + + config.vm.define 'ubuntu-xenial' do |ubuntu_x| + ubuntu_x.vm.box = 'ubuntu/xenial64' + #ubuntu_x.vm.hostname = 'ubuntu-xenial' + + ubuntu_x.vm.provision 'shell', inline: 'apt-get update' + ubuntu_x.vm.provision 'shell', inline: 'apt-get install -y -qq python-pip libffi-dev libssl-dev python-dev' + ubuntu_x.vm.provision 'shell', inline: "pip install -q ansible==#{ANSIBLE_VERSION} jinja2" + ubuntu_x.vm.provision 'shell', inline: "ln -sf /vagrant /vagrant/#{ANSIBLE_ROLE}" + + ubuntu_x.vm.provision 'ansible_local' do |ansible| + ansible.playbook = 'tests/test_vagrant.yml' + end + + end + + config.vm.define 'ubuntu-trusty' do |ubuntu_t| + ubuntu_t.vm.box = 'ubuntu/trusty64' + ubuntu_t.vm.hostname = 'ubuntu-trusty' + + ubuntu_t.vm.provision 'shell', inline: 'apt-get update' + ubuntu_t.vm.provision 'shell', inline: 'apt-get install -y -qq python-pip libffi-dev libssl-dev python-dev' + ubuntu_t.vm.provision 'shell', inline: "pip install -q ansible==#{ANSIBLE_VERSION} ansible-lint jinja2" + ubuntu_t.vm.provision 'shell', inline: "ln -sf /vagrant /vagrant/#{ANSIBLE_ROLE}" + + ubuntu_t.vm.provision 'ansible_local' do |ansible| + ansible.playbook = 'tests/test_vagrant.yml' + ansible.extra_vars = { + } + end + + end + + config.vm.define 'ubuntu-precise' do |ubuntu_p| + ubuntu_p.vm.box = 'ubuntu/precise64' + ubuntu_p.vm.hostname = 'ubuntu-precise' + + ubuntu_p.vm.provision 'shell', inline: 'apt-get update' + ubuntu_p.vm.provision 'shell', inline: 'apt-get install -y -qq python-pip libffi-dev libssl-dev python-dev' + ubuntu_p.vm.provision 'shell', inline: "pip install -q ansible==#{ANSIBLE_VERSION} ansible-lint jinja2" + ubuntu_p.vm.provision 'shell', inline: "ln -sf /vagrant /vagrant/#{ANSIBLE_ROLE}" + + ubuntu_p.vm.provision 'ansible_local' do |ansible| + ansible.playbook = 'tests/test_vagrant.yml' + ansible.extra_vars = { + } + end + + end + + config.vm.define 'centos-7' do |centos7| + centos7.vm.box = 'centos/7' + centos7.vm.hostname = 'centos-7' + + centos7.vm.provision 'shell', inline: 'yum install -y ca-certificates' + centos7.vm.provision 'shell', inline: "echo \"#{EPEL_REPO_7}\" > /etc/yum.repos.d/epel.repo" + centos7.vm.provision 'shell', inline: 'yum install -y python-pip python-devel gcc libffi-devel openssl-devel' + centos7.vm.provision 'shell', inline: "pip install -q pip --upgrade" + centos7.vm.provision 'shell', inline: "pip install -q ansible==#{ANSIBLE_VERSION} ansible-lint jinja2" + centos7.vm.provision 'shell', inline: "ln -sf /vagrant /vagrant/#{ANSIBLE_ROLE}" + + centos7.vm.provision 'ansible_local' do |ansible| + ansible.playbook = 'tests/test_vagrant.yml' + ansible.extra_vars = { + } + end + end + + config.vm.define 'centos-6' do |centos6| + centos6.vm.box = "puppetlabs/centos-6.6-64-nocm" + centos6.vm.hostname = 'centos-6' + + centos6.vm.provision 'shell', inline: 'yum install -y ca-certificates' + centos6.vm.provision 'shell', inline: "echo \"#{EPEL_REPO_6}\" > /etc/yum.repos.d/epel.repo" + centos6.vm.provision 'shell', inline: 'yum install -y python-pip python-devel gcc libffi-devel openssl-devel' + centos6.vm.provision 'shell', inline: "pip install -q pip --upgrade" + centos6.vm.provision 'shell', inline: "pip install -q ansible==#{ANSIBLE_VERSION} ansible-lint jinja2" + + centos6.vm.provision 'ansible_local' do |ansible| + ansible.playbook = 'tests/test_vagrant.yml' + ansible.extra_vars = { + } + end + end + +end + +# vi:ts=2:sw=2:et:ft=ruby: diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..6462621 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,2 @@ +[defaults] +roles_path=../ diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..b47223b --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,54 @@ +--- + +strongswan_config_file: "{{strongswan_prefix}}/ipsec.conf" + +strongswan_secrets_file: "{{strongswan_prefix}}/ipsec.secrets" + +strongswan_config_setup: + uniqueids: yes + charonstart: yes + charondebug: '' + +# strongswan_conn_default: Defaults for connections +# This will populate the default conn (%default) +# An example can be: +# +# strongswan_conn_default: +# type: tunnel +# ikelifetime: 1h +# lifetime: 30m +# left: 1.2.3.4 +# +strongswan_conn_default: {} + +# strongswan_conns: Dict to specify connections +# Each key represents the name of a connection. The subelemets that the +# connection has is any valid directive for a connection +# +# strongswan_conns: +# conn1: +# right: 2.3.4.5 +# rightsubnet: 2.3.4.0/24 +# ike: aes256-sha1-modp1024 +# esp: aes256-sha1-modp1024 +# auto: start +# +strongswan_conns: {} + +# strongswan_secrets: List of secrets to define +# A list that contains the following attributes: +# left: Optional - Any valid ID selector +# right: Optional - Any valid ID selector +# type: Optional (defaults to PSK) - any valid secret type +# credential: Required - Connection's credentials +# +# strongswan_secrets: +# - left: 1.2.3.4 +# right: 2.3.4.5 +# type: PSK +# credentials: '"some private PSK here"' +# + +strongswan_secrets: [] + +# vi:ts=2:sw=2:et:ft=yaml diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..8d002b4 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,12 @@ +--- + +- name: ipsec reload + command: > + {{strongswan_ipsec_bin}} reload + +- name: ipsec secrets reload + command: > + {{strongswan_ipsec_bin}} rereadsecrets + + +# vi:ts=2:sw=2:et:ft=yaml diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..f54c56c --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,26 @@ +--- +galaxy_info: + author: Emiliano Castagnari + description: Ansible role for StrongSwan + license: Apache + min_ansible_version: 2.3 + platforms: + - name: EL + versions: + - 6 + - 7 + - name: Debian + versions: + - wheezy + - name: Ubuntu + versions: + - precise + - trusty + - xenial + - name: Amazon Linux + + galaxy_tags: + - system + - security + +dependencies: [] diff --git a/tasks/config.yml b/tasks/config.yml new file mode 100644 index 0000000..a558895 --- /dev/null +++ b/tasks/config.yml @@ -0,0 +1,21 @@ +--- + +- name: Strongswan ipsec.conf + template: + src: etc/ipsec.conf.j2 + dest: "{{strongswan_config_file}}" + owner: "root" + group: "root" + mode: "0644" + notify: ipsec reload + +- name: Strongswan ipsec.secrets + template: + src: etc/ipsec.secrets.j2 + dest: "{{strongswan_secrets_file}}" + owner: "root" + group: "root" + mode: "0640" + notify: ipsec secrets reload + +# vi:ts=2:sw=2:et:ft=yaml diff --git a/tasks/install.yml b/tasks/install.yml new file mode 100644 index 0000000..9640d7a --- /dev/null +++ b/tasks/install.yml @@ -0,0 +1,11 @@ +--- + +- include: "install/{{ansible_os_family}}.yml" + +- name: Strongswan packages + package: + name: "{{item}}" + state: present + with_items: "{{strongswan_packages}}" + +# vi:ts=2:sw=2:et:ft=yaml diff --git a/tasks/install/Debian.yml b/tasks/install/Debian.yml new file mode 100644 index 0000000..d016ef5 --- /dev/null +++ b/tasks/install/Debian.yml @@ -0,0 +1,3 @@ +--- + +# vi:ts=2:sw=2:et:ft=yaml diff --git a/tasks/install/RedHat.yml b/tasks/install/RedHat.yml new file mode 100644 index 0000000..eb03f64 --- /dev/null +++ b/tasks/install/RedHat.yml @@ -0,0 +1,8 @@ +--- + +- name: EPEL Repository (RedHat) + yum: + name: "{{strongswan_epel_url}}" + state: present + +# vi:ts=2:sw=2:et:ft=yaml diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..08f51fb --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,16 @@ +--- + +- name: Include OS Family vars + include_vars: "{{ansible_os_family}}.yml" + tags: always + +- include: install.yml + tags: strongswan_install + +- include: config.yml + tags: strongswan_config + +- include: service.yml + tags: strongswan_service + +# vi:ts=2:sw=2:et:ft=yaml diff --git a/tasks/service.yml b/tasks/service.yml new file mode 100644 index 0000000..3d766de --- /dev/null +++ b/tasks/service.yml @@ -0,0 +1,9 @@ +--- + +- name: Enable Strongswan at boot + service: + name: strongswan + enabled: true + state: started + +# vi:ts=2:sw=2:et:ft=yaml diff --git a/templates/etc/ipsec.conf.j2 b/templates/etc/ipsec.conf.j2 new file mode 100644 index 0000000..4278a85 --- /dev/null +++ b/templates/etc/ipsec.conf.j2 @@ -0,0 +1,20 @@ +# << Ansible managed file >> +# {{strongswan_config_file}} - strongSwan IPsec configuration file + +config setup +{% for k,v in strongswan_config_setup.iteritems() %} + {{k}} = {{v}} +{% endfor %} + +config %default +{% for k,v in strongswan_conn_default.iteritems() %} + {{k}} = {{v}} +{% endfor %} + +{% for conn,conn_settings in strongswan_conns.iteritems() %} +conn {{conn}} +{% for k,v in conn_settings.iteritems() %} + {{k}} = {{v}} +{% endfor %} +{% endfor %} + diff --git a/templates/etc/ipsec.secrets.j2 b/templates/etc/ipsec.secrets.j2 new file mode 100644 index 0000000..9eaa6c6 --- /dev/null +++ b/templates/etc/ipsec.secrets.j2 @@ -0,0 +1,7 @@ +# << Ansible managed file >> +# {{strongswan_secrets_file}} - strongSwan IPsec secrets file + +{% for s in strongswan_secrets %} +{{s.left|default()}} {{s.right|default()}} : {{s.type|default('PSK')}} {{s.credentials}} +{% endfor %} + diff --git a/tests/test_config.yml b/tests/test_config.yml new file mode 100644 index 0000000..7e92857 --- /dev/null +++ b/tests/test_config.yml @@ -0,0 +1,33 @@ +--- + +- name: Defaults + hosts: localhost + remote_user: root + + vars: + - strongswan_config_setup: + uniqueids: yes + charondebug: 'ike 2, knl 3, cfg 0' + - strongswan_conn_default: + left: "{{ansible_default_ipv4.address}}" + leftsourceip: "{{ansible_default_ipv4.address}}" + leftsubnet: 10.0.0.0/16 + type: tunnel + keyexchange: ikev2 + - strongswan_conns: + conn1: + right: 1.2.3.4 + rightsubnet: 2.3.4.0/24 + ike: aes256-sha1-modp1024 + esp: aes256-sha1-modp1024 + auto: route + - strongswan_secrets: + - left: "{{ansible_default_ipv4.address}}" + right: 1.2.3.4 + type: PSK + credentials: '"super wooper dooper secret"' + + roles: + - { role: ansible-role-strongswan, become: true } + +# vi:ts=2:sw=2:et:ft=yaml diff --git a/tests/test_defaults.yml b/tests/test_defaults.yml new file mode 100644 index 0000000..249fe58 --- /dev/null +++ b/tests/test_defaults.yml @@ -0,0 +1,10 @@ +--- + +- name: Defaults + hosts: localhost + remote_user: root + + roles: + - { role: ansible-role-strongswan, become: true } + +# vi:ts=2:sw=2:et:ft=yaml diff --git a/tests/test_vagrant.yml b/tests/test_vagrant.yml new file mode 100644 index 0000000..247c22f --- /dev/null +++ b/tests/test_vagrant.yml @@ -0,0 +1,33 @@ +--- + +- name: Defaults + hosts: all + become: true + + vars: + - strongswan_config_setup: + uniqueids: yes + charondebug: 'ike 2, knl 3, cfg 0' + - strongswan_conn_default: + left: "{{ansible_default_ipv4.address}}" + leftsourceip: "{{ansible_default_ipv4.address}}" + leftsubnet: 10.0.0.0/16 + type: tunnel + keyexchange: ikev2 + - strongswan_conns: + conn1: + right: 1.2.3.4 + rightsubnet: 2.3.4.0/24 + ike: aes256-sha1-modp1024 + esp: aes256-sha1-modp1024 + auto: route + - strongswan_secrets: + - left: "{{ansible_default_ipv4.address}}" + right: 1.2.3.4 + type: PSK + credentials: '"super wooper dooper secret"' + + roles: + - { role: ansible-role-strongswan, become: true } + +# vi:ts=2:sw=2:et:ft=yaml diff --git a/vars/Debian.yml b/vars/Debian.yml new file mode 100644 index 0000000..4d63be6 --- /dev/null +++ b/vars/Debian.yml @@ -0,0 +1,10 @@ +--- + +strongswan_packages: + - strongswan + +strongswan_prefix: /etc + +strongswan_ipsec_bin: /sbin/ipsec + +# vi:ts=2:sw=2:et:ft=yaml diff --git a/vars/RedHat.yml b/vars/RedHat.yml new file mode 100644 index 0000000..a7f0771 --- /dev/null +++ b/vars/RedHat.yml @@ -0,0 +1,14 @@ +--- + +strongswan_packages: + - strongswan + +strongswan_prefix: /etc/strongswan + +strongswan_ipsec_bin: /sbin/strongswan + +strongswan_epel_baseurl: "https://dl.fedoraproject.org" +strongswan_epel_package: "epel-release-latest-{{ansible_distribution_major_version}}.noarch.rpm" +strongswan_epel_url: "{{strongswan_epel_baseurl}}/pub/epel/{{strongswan_epel_package}}" + +# vi:ts=2:sw=2:et:ft=yaml