This commit is contained in:
commit
f9578bd074
154
.drone.jsonnet
Normal file
154
.drone.jsonnet
Normal file
@ -0,0 +1,154 @@
|
||||
local PipelineLinting = {
|
||||
kind: 'pipeline',
|
||||
name: 'linting',
|
||||
platform: {
|
||||
os: 'linux',
|
||||
arch: 'amd64',
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
name: 'ansible-later',
|
||||
image: 'xoxys/ansible-later',
|
||||
commands: [
|
||||
'ansible-later',
|
||||
],
|
||||
},
|
||||
],
|
||||
trigger: {
|
||||
ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],
|
||||
},
|
||||
};
|
||||
|
||||
local PipelineDeployment(scenario='centos8') = {
|
||||
kind: 'pipeline',
|
||||
name: 'testing-' + scenario,
|
||||
platform: {
|
||||
os: 'linux',
|
||||
arch: 'amd64',
|
||||
},
|
||||
concurrency: {
|
||||
limit: 1,
|
||||
},
|
||||
workspace: {
|
||||
base: '/drone/src',
|
||||
path: '${DRONE_REPO_NAME}',
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
name: 'ansible-molecule',
|
||||
image: 'xoxys/molecule:3',
|
||||
environment: {
|
||||
DO_API_KEY: { from_secret: 'do_api_key' },
|
||||
MOLECULE_CUSTOM_MODULES_REPO: 'https://gitea.rknet.org/ansible/custom_modules',
|
||||
MOLECULE_CUSTOM_FILTERS_REPO: 'https://gitea.rknet.org/ansible/custom_filters',
|
||||
},
|
||||
commands: [
|
||||
'molecule test -s' + scenario,
|
||||
],
|
||||
},
|
||||
],
|
||||
depends_on: [
|
||||
'linting',
|
||||
],
|
||||
trigger: {
|
||||
ref: ['refs/heads/master', 'refs/tags/**'],
|
||||
},
|
||||
};
|
||||
|
||||
local PipelineDocumentation = {
|
||||
kind: 'pipeline',
|
||||
name: 'documentation',
|
||||
platform: {
|
||||
os: 'linux',
|
||||
arch: 'amd64',
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
name: 'generate',
|
||||
image: 'xoxys/ansible-doctor',
|
||||
environment: {
|
||||
ANSIBLE_DOCTOR_LOG_LEVEL: 'INFO',
|
||||
ANSIBLE_DOCTOR_FORCE_OVERWRITE: true,
|
||||
ANSIBLE_DOCTOR_EXCLUDE_FILES: 'molecule/',
|
||||
ANSIBLE_DOCTOR_TEMPLATE: 'hugo-book',
|
||||
ANSIBLE_DOCTOR_ROLE_NAME: '${DRONE_REPO_NAME#*.}',
|
||||
ANSIBLE_DOCTOR_OUTPUT_DIR: '_docs/',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'publish',
|
||||
image: 'plugins/gh-pages',
|
||||
settings: {
|
||||
remote_url: 'https://gitea.rknet.org/ansible/${DRONE_REPO_NAME}',
|
||||
netrc_machine: 'gitea.rknet.org',
|
||||
username: { from_secret: 'gitea_username' },
|
||||
password: { from_secret: 'gitea_token' },
|
||||
pages_directory: '_docs/',
|
||||
target_branch: 'docs',
|
||||
},
|
||||
when: {
|
||||
ref: ['refs/heads/master'],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'trigger',
|
||||
image: 'plugins/downstream',
|
||||
settings: {
|
||||
server: 'https://drone.rknet.org',
|
||||
token: { from_secret: 'drone_token' },
|
||||
fork: true,
|
||||
repositories: [
|
||||
'ansible/ansible-galaxy',
|
||||
],
|
||||
},
|
||||
when: {
|
||||
ref: ['refs/heads/master'],
|
||||
},
|
||||
},
|
||||
],
|
||||
trigger: {
|
||||
ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],
|
||||
},
|
||||
depends_on: [
|
||||
'testing-centos8',
|
||||
],
|
||||
};
|
||||
|
||||
local PipelineNotification = {
|
||||
kind: 'pipeline',
|
||||
name: 'notification',
|
||||
platform: {
|
||||
os: 'linux',
|
||||
arch: 'amd64',
|
||||
},
|
||||
clone: {
|
||||
disable: true,
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
name: 'matrix',
|
||||
image: 'plugins/matrix',
|
||||
settings: {
|
||||
homeserver: { from_secret: 'matrix_homeserver' },
|
||||
roomid: { from_secret: 'matrix_roomid' },
|
||||
template: 'Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}',
|
||||
username: { from_secret: 'matrix_username' },
|
||||
password: { from_secret: 'matrix_password' },
|
||||
},
|
||||
},
|
||||
],
|
||||
depends_on: [
|
||||
'documentation',
|
||||
],
|
||||
trigger: {
|
||||
status: ['success', 'failure'],
|
||||
ref: ['refs/heads/master', 'refs/tags/**'],
|
||||
},
|
||||
};
|
||||
|
||||
[
|
||||
PipelineLinting,
|
||||
PipelineDeployment(scenario='centos8'),
|
||||
PipelineDocumentation,
|
||||
PipelineNotification,
|
||||
]
|
151
.drone.yml
Normal file
151
.drone.yml
Normal file
@ -0,0 +1,151 @@
|
||||
---
|
||||
kind: pipeline
|
||||
name: linting
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: ansible-later
|
||||
image: xoxys/ansible-later
|
||||
commands:
|
||||
- ansible-later
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
- refs/pull/**
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: testing-centos8
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
concurrency:
|
||||
limit: 1
|
||||
|
||||
workspace:
|
||||
base: /drone/src
|
||||
path: ${DRONE_REPO_NAME}
|
||||
|
||||
steps:
|
||||
- name: ansible-molecule
|
||||
image: xoxys/molecule:3
|
||||
commands:
|
||||
- molecule test -scentos8
|
||||
environment:
|
||||
DO_API_KEY:
|
||||
from_secret: do_api_key
|
||||
MOLECULE_CUSTOM_FILTERS_REPO: https://gitea.rknet.org/ansible/custom_filters
|
||||
MOLECULE_CUSTOM_MODULES_REPO: https://gitea.rknet.org/ansible/custom_modules
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
|
||||
depends_on:
|
||||
- linting
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: documentation
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: generate
|
||||
image: xoxys/ansible-doctor
|
||||
environment:
|
||||
ANSIBLE_DOCTOR_EXCLUDE_FILES: molecule/
|
||||
ANSIBLE_DOCTOR_FORCE_OVERWRITE: true
|
||||
ANSIBLE_DOCTOR_LOG_LEVEL: INFO
|
||||
ANSIBLE_DOCTOR_OUTPUT_DIR: _docs/
|
||||
ANSIBLE_DOCTOR_ROLE_NAME: ${DRONE_REPO_NAME#*.}
|
||||
ANSIBLE_DOCTOR_TEMPLATE: hugo-book
|
||||
|
||||
- name: publish
|
||||
image: plugins/gh-pages
|
||||
settings:
|
||||
netrc_machine: gitea.rknet.org
|
||||
pages_directory: _docs/
|
||||
password:
|
||||
from_secret: gitea_token
|
||||
remote_url: https://gitea.rknet.org/ansible/${DRONE_REPO_NAME}
|
||||
target_branch: docs
|
||||
username:
|
||||
from_secret: gitea_username
|
||||
when:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
|
||||
- name: trigger
|
||||
image: plugins/downstream
|
||||
settings:
|
||||
fork: true
|
||||
repositories:
|
||||
- ansible/ansible-galaxy
|
||||
server: https://drone.rknet.org
|
||||
token:
|
||||
from_secret: drone_token
|
||||
when:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
- refs/pull/**
|
||||
|
||||
depends_on:
|
||||
- testing-centos8
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: notification
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
clone:
|
||||
disable: true
|
||||
|
||||
steps:
|
||||
- name: matrix
|
||||
image: plugins/matrix
|
||||
settings:
|
||||
homeserver:
|
||||
from_secret: matrix_homeserver
|
||||
password:
|
||||
from_secret: matrix_password
|
||||
roomid:
|
||||
from_secret: matrix_roomid
|
||||
template: "Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}"
|
||||
username:
|
||||
from_secret: matrix_username
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
status:
|
||||
- success
|
||||
- failure
|
||||
|
||||
depends_on:
|
||||
- documentation
|
||||
|
||||
---
|
||||
kind: signature
|
||||
hmac: f565ac4819e3b86185ee25d5dbde6d0844d282330ab45abe385ecdb83fedcc16
|
||||
|
||||
...
|
11
.gitignore
vendored
Normal file
11
.gitignore
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
# ---> Ansible
|
||||
*.retry
|
||||
plugins
|
||||
library
|
||||
|
||||
# ---> Python
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
18
.later.yml
Normal file
18
.later.yml
Normal file
@ -0,0 +1,18 @@
|
||||
---
|
||||
ansible:
|
||||
custom_modules:
|
||||
- iptables_raw
|
||||
- openssl_pkcs12
|
||||
- proxmox_kvm2
|
||||
- ucr
|
||||
- yum_versionlock
|
||||
|
||||
rules:
|
||||
exclude_files:
|
||||
- molecule/
|
||||
- "LICENSE*"
|
||||
- "**/*.md"
|
||||
- "**/*.ini"
|
||||
|
||||
exclude_filter:
|
||||
- LINT0009
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 Robert Kaussow <mail@geeklabor.de>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next
|
||||
paragraph) shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
||||
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
14
README.md
Normal file
14
README.md
Normal file
@ -0,0 +1,14 @@
|
||||
# xoxys.openvpn_client
|
||||
|
||||
[![Build Status](https://img.shields.io/drone/build/ansible/xoxys.openvpn_client?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/ansible/xoxys.openvpn_client)
|
||||
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?label=license)](LICENSE)
|
||||
|
||||
You can find the full documentation at [https://galaxy.geekdocs.de](https://galaxy.geekdocs.de/roles/security/openvpn_client/).
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
||||
|
||||
## Maintainers and Contributors
|
||||
|
||||
[Robert Kaussow](https://gitea.rknet.org/xoxys)
|
22
defaults/main.yml
Normal file
22
defaults/main.yml
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
openvpn_client_name: client
|
||||
openvpn_client_server: vpn.example.com
|
||||
|
||||
openvpn_client_packages_extra: []
|
||||
|
||||
openvpn_client_cipher: AES-256-CBC
|
||||
openvpn_client_auth: SHA512
|
||||
|
||||
# openvpn_client_x509_name:
|
||||
|
||||
openvpn_client_ca_file: "{{ openvpn_client_name }}_ca.crt"
|
||||
# openvpn_client_ca_source:
|
||||
|
||||
openvpn_client_key_file: "{{ openvpn_client_name }}.key"
|
||||
# openvpn_client_key_source:
|
||||
|
||||
openvpn_client_cert_file: "{{ openvpn_client_name }}.crt"
|
||||
# openvpn_client_cert_source:
|
||||
|
||||
openvpn_client_ta_file: "{{ openvpn_client_name }}_ta.key"
|
||||
# openvpn_client_ta_source:
|
21
meta/main.yml
Normal file
21
meta/main.yml
Normal file
@ -0,0 +1,21 @@
|
||||
# Standards: 0.1
|
||||
---
|
||||
galaxy_info:
|
||||
# @meta author:value: [Robert Kaussow](https://gitea.rknet.org/xoxys)
|
||||
author: "Robert Kaussow <mail@geeklabor.de>"
|
||||
# @meta description: >
|
||||
# [![Source Code](https://img.shields.io/badge/gitea-source%20code-blue?logo=gitea&logoColor=white)](https://gitea.rknet.org/ansible/xoxys.openvpn_client)
|
||||
# [![Build Status](https://img.shields.io/drone/build/ansible/xoxys.openvpn_client?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/ansible/xoxys.openvpn_client)
|
||||
# [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?label=license)](LICENSE)
|
||||
#
|
||||
# Configure OpenVPN client
|
||||
# @end
|
||||
description: Configure OpenVPN client
|
||||
license: MIT
|
||||
min_ansible_version: 2.8
|
||||
platforms:
|
||||
- name: EL
|
||||
versions:
|
||||
- 7
|
||||
galaxy_tags:
|
||||
dependencies: []
|
5
molecule/centos7/converge.yml
Normal file
5
molecule/centos7/converge.yml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
roles:
|
||||
- role: "xoxys.openvpn_client"
|
89
molecule/centos7/create.yml
Normal file
89
molecule/centos7/create.yml
Normal file
@ -0,0 +1,89 @@
|
||||
---
|
||||
|
||||
- name: Create
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
no_log: "{{ molecule_no_log }}"
|
||||
vars:
|
||||
ssh_user: root
|
||||
ssh_port: 22
|
||||
|
||||
keypair_name: molecule_key
|
||||
keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key"
|
||||
tasks:
|
||||
- name: Create local keypair
|
||||
user:
|
||||
name: "{{ lookup('env', 'USER') }}"
|
||||
generate_ssh_key: true
|
||||
ssh_key_file: "{{ keypair_path }}"
|
||||
register: local_keypair
|
||||
|
||||
- name: Create remote keypair
|
||||
digital_ocean_sshkey:
|
||||
name: "{{ keypair_name }}"
|
||||
ssh_pub_key: "{{ local_keypair.ssh_public_key }}"
|
||||
state: present
|
||||
register: remote_keypair
|
||||
|
||||
- name: Create molecule instance(s)
|
||||
digital_ocean_droplet:
|
||||
name: "{{ item.name }}"
|
||||
unique_name: true
|
||||
region: "{{ item.region_id }}"
|
||||
image: "{{ item.image_id }}"
|
||||
size: "{{ item.size_id }}"
|
||||
ssh_keys: "{{ remote_keypair.data.ssh_key.id }}"
|
||||
wait: true
|
||||
wait_timeout: 300
|
||||
state: present
|
||||
register: server
|
||||
loop: "{{ molecule_yml.platforms }}"
|
||||
async: 7200
|
||||
poll: 0
|
||||
|
||||
- name: Wait for instance(s) creation to complete
|
||||
async_status:
|
||||
jid: "{{ item.ansible_job_id }}"
|
||||
register: digitalocean_jobs
|
||||
until: digitalocean_jobs.finished
|
||||
retries: 300
|
||||
loop: "{{ server.results }}"
|
||||
|
||||
# Mandatory configuration for Molecule to function.
|
||||
|
||||
- name: Populate instance config dict
|
||||
set_fact:
|
||||
instance_conf_dict: {
|
||||
'instance': "{{ item.data.droplet.name }}",
|
||||
'address': "{{ item.data.ip_address }}",
|
||||
'user': "{{ ssh_user }}",
|
||||
'port': "{{ ssh_port }}",
|
||||
'identity_file': "{{ keypair_path }}",
|
||||
'droplet_id': "{{ item.data.droplet.id }}",
|
||||
'ssh_key_id': "{{ remote_keypair.data.ssh_key.id }}",
|
||||
}
|
||||
loop: "{{ digitalocean_jobs.results }}"
|
||||
register: instance_config_dict
|
||||
when: server.changed | bool
|
||||
|
||||
- name: Convert instance config dict to a list
|
||||
set_fact:
|
||||
instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}"
|
||||
when: server.changed | bool
|
||||
|
||||
- name: Dump instance config
|
||||
copy:
|
||||
content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}"
|
||||
dest: "{{ molecule_instance_config }}"
|
||||
when: server.changed | bool
|
||||
|
||||
- name: Wait for SSH
|
||||
wait_for:
|
||||
port: "{{ ssh_port }}"
|
||||
host: "{{ item.address }}"
|
||||
search_regex: SSH
|
||||
delay: 10
|
||||
timeout: 320
|
||||
loop: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}"
|
||||
|
56
molecule/centos7/destroy.yml
Normal file
56
molecule/centos7/destroy.yml
Normal file
@ -0,0 +1,56 @@
|
||||
---
|
||||
|
||||
- name: Destroy
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
no_log: "{{ molecule_no_log }}"
|
||||
tasks:
|
||||
- block:
|
||||
- name: Populate instance config
|
||||
set_fact:
|
||||
instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}"
|
||||
skip_instances: false
|
||||
rescue:
|
||||
- name: Populate instance config when file missing
|
||||
set_fact:
|
||||
instance_conf: {}
|
||||
skip_instances: true
|
||||
|
||||
- name: Destroy molecule instance(s)
|
||||
digital_ocean_droplet:
|
||||
name: "{{ item.instance }}"
|
||||
id: "{{ item.droplet_id }}"
|
||||
state: absent
|
||||
register: server
|
||||
loop: "{{ instance_conf | flatten(levels=1) }}"
|
||||
when: not skip_instances
|
||||
async: 7200
|
||||
poll: 0
|
||||
|
||||
- name: Wait for instance(s) deletion to complete
|
||||
async_status:
|
||||
jid: "{{ item.ansible_job_id }}"
|
||||
register: digitalocean_jobs
|
||||
until: digitalocean_jobs.finished
|
||||
retries: 300
|
||||
loop: "{{ server.results }}"
|
||||
|
||||
- name: Delete remote keypair
|
||||
digital_ocean_sshkey:
|
||||
fingerprint: "{{ item.ssh_key_id }}"
|
||||
state: absent
|
||||
loop: "{{ instance_conf | flatten(levels=1) }}"
|
||||
|
||||
# Mandatory configuration for Molecule to function.
|
||||
|
||||
- name: Populate instance config
|
||||
set_fact:
|
||||
instance_conf: {}
|
||||
|
||||
- name: Dump instance config
|
||||
copy:
|
||||
content: "{{ instance_conf | molecule_to_yaml | molecule_header }}"
|
||||
dest: "{{ molecule_instance_config }}"
|
||||
when: server.changed | bool
|
||||
|
16
molecule/centos7/molecule.yml
Normal file
16
molecule/centos7/molecule.yml
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: delegated
|
||||
platforms:
|
||||
- name: centos7-openvpn-client
|
||||
region_id: fra1
|
||||
image_id: centos-7-x64
|
||||
size_id: s-1vcpu-1gb
|
||||
lint: |
|
||||
flake8 --max-line-length=99
|
||||
provisioner:
|
||||
name: ansible
|
||||
verifier:
|
||||
name: testinfra
|
9
molecule/centos7/prepare.yml
Normal file
9
molecule/centos7/prepare.yml
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
- name: Prepare
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Install python for Ansible
|
||||
raw: test -e /usr/bin/python || (dnf -y install python3 && alternatives --set python /usr/bin/python3)
|
||||
become: true
|
||||
changed_when: false
|
16
molecule/centos7/tests/test_default.py
Normal file
16
molecule/centos7/tests/test_default.py
Normal file
@ -0,0 +1,16 @@
|
||||
import os
|
||||
|
||||
import testinfra.utils.ansible_runner
|
||||
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||
|
||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||
|
||||
|
||||
# TODO: add useful tests
|
||||
def test_hosts_file(host):
|
||||
hosts = host.file("/etc/hosts")
|
||||
|
||||
assert hosts.exists
|
3
molecule/pytest.ini
Normal file
3
molecule/pytest.ini
Normal file
@ -0,0 +1,3 @@
|
||||
[pytest]
|
||||
filterwarnings =
|
||||
ignore::DeprecationWarning
|
38
tasks/main.yml
Normal file
38
tasks/main.yml
Normal file
@ -0,0 +1,38 @@
|
||||
---
|
||||
- block:
|
||||
- name: Install dependencies
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
loop: "{{ openvpn_client_packages_extra }}"
|
||||
|
||||
- name: Install required packages
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
loop:
|
||||
- openvpn
|
||||
|
||||
- name: Write client config
|
||||
template:
|
||||
src: etc/openvpn/client.conf.j2
|
||||
dest: "/etc/openvpn/{{ openvpn_name }}.conf"
|
||||
mode: 0600
|
||||
notify: __openvpn_restart
|
||||
|
||||
- name: Copy cert files (if defined)
|
||||
copy:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: "{{ item.mode }}"
|
||||
state: "{{ 'absent' if not item.src else 'present' }}"
|
||||
loop:
|
||||
- { src: "{{ openvpn_client_ca_source | default(False) }}", dest: "/etc/openvpn/certs/{{ openvpn_client_ca_file }}", mode: "0650" }
|
||||
- { src: "{{ openvpn_client_cert_source | default(False) }}", dest: "/etc/openvpn/certs/{{ openvpn_client_cert_file }}", mode: "0650" }
|
||||
- { src: "{{ openvpn_client_key_source | default(False) }}", dest: "/etc/openvpn/certs/{{ openvpn_client_key_file }}", mode: "0600" }
|
||||
- { src: "{{ openvpn_client_ta_source | default(False) }}", dest: "/etc/openvpn/certs/{{ openvpn_client_ta_file }}", mode: "0600" }
|
||||
loop_control:
|
||||
label: "{{ item.dest }}"
|
||||
notify: __nginx_reload
|
||||
become: True
|
||||
become_user: root
|
31
templates/etc/openvpn/client.conf.j2
Normal file
31
templates/etc/openvpn/client.conf.j2
Normal file
@ -0,0 +1,31 @@
|
||||
#jinja2: lstrip_blocks: True
|
||||
{{ ansible_managed | comment }}
|
||||
dev tun
|
||||
persist-tun
|
||||
persist-key
|
||||
cipher {{ openvpn_client_cipher }}
|
||||
ncp-disable
|
||||
auth {{ openvpn_client_auth }}
|
||||
tls-client
|
||||
client
|
||||
resolv-retry infinite
|
||||
remote {{ openvpn_client_server }}
|
||||
nobind
|
||||
{% if openvpn_client_x509_name is defined %}
|
||||
verify-x509-name "{{ openvpn_client_x509_name }}" name
|
||||
{% endif %}
|
||||
{% if openvpn_client_ca_file is defined and openvpn_client_ca_source is defined %}
|
||||
ca /etc/openvpn/certs/{{ openvpn_client_ca_file }}
|
||||
{% endif %}
|
||||
{% if openvpn_client_cert_file is defined and openvpn_client_cert_source is defined %}
|
||||
cert /etc/openvpn/certs/{{ openvpn_client_cert_file }}
|
||||
{% endif %}
|
||||
{% if openvpn_client_key_file is defined and openvpn_client_key_source is defined %}
|
||||
key /etc/openvpn/certs/{{ openvpn_client_key_file }}
|
||||
{% endif %}
|
||||
{% if openvpn_client_ta_file is defined and openvpn_client_ta_source is defined %}
|
||||
tls-auth /etc/openvpn/certs/{{ openvpn_client_ta_file }}
|
||||
{% endif %}
|
||||
key-direction 1
|
||||
remote-cert-tls server
|
||||
comp-lzo adaptive
|
Loading…
Reference in New Issue
Block a user