diff --git a/tests/post-run.yaml b/tests/post-run.yaml new file mode 100644 index 0000000..c8518a5 --- /dev/null +++ b/tests/post-run.yaml @@ -0,0 +1,11 @@ +--- +- hosts: all + become: true + tasks: + - name: Extract journal contents + shell: journalctl > journal.log + + - name: Copy journal log to executor + fetch: + src: journal.log + dest: "{{ zuul.executor.log_root }}" diff --git a/tests/run.yaml b/tests/run.yaml new file mode 100644 index 0000000..34bd803 --- /dev/null +++ b/tests/run.yaml @@ -0,0 +1,60 @@ +--- +- hosts: all + become: true + tasks: + - name: Flush firewall rules + iptables: + flush: true + # NOTE(mnaser): Wireguard on CentOS requires EPEL, this role does not + # manage it for you. + - name: Enable EPEL + yum_repository: + name: epel + description: Extra Packages for Enterprise Linux 7 - $basearch + baseurl: "http://{{ zuul_site_mirror_fqdn }}/epel/7/$basearch" + enabled: true + when: ansible_os_family == 'RedHat' + # NOTE(mnaser): Glean interferes with the interfaces, disable for now + # Drop when https://review.openstack.org/651680 lands. + - name: Disable Glean + file: + path: /etc/udev/rules.d/99-glean.rules + state: absent + +- hosts: primary + roles: + - wireguard + vars: + wireguard_links: + - name: wg0 + address: 10.0.0.1 + port: 51820 + private_key: eCpvWOe8zI0HCj/KjK3TZP71kd+glDxvDo5JaQhw3mw= + peers: + - public_key: UB9Lhk0JgwAPFD8F3k3Dq9iS7r/jLD+oYMX98T+fmGw= + endpoint: "{{ hostvars['secondary']['ansible_host'] }}:51820" + allowed_ips: 10.0.0.2 + +- hosts: secondary + roles: + - wireguard + vars: + wireguard_links: + - name: wg0 + address: 10.0.0.2 + port: 51820 + private_key: aIPcdRd6ncwRa+DJLaiq0Jmbvx1FjtLnWE2EApgcr2E= + peers: + - public_key: E/MU5hNb1mQ55ww0H0luxigNTXNNo/x49MRm5AcHLSI= + endpoint: "{{ hostvars['primary']['ansible_host'] }}:51820" + allowed_ips: 10.0.0.1 + +- hosts: primary + tasks: + - name: Check if primary can reach secondary + shell: ping -c4 -W 1 10.0.0.2 + +- hosts: secondary + tasks: + - name: Check if secondary can reach primary + shell: ping -c4 -W 1 10.0.0.1 diff --git a/vars/ubuntu.yaml b/vars/ubuntu.yaml index bd333b2..881e10d 100644 --- a/vars/ubuntu.yaml +++ b/vars/ubuntu.yaml @@ -1,3 +1,4 @@ --- wireguard_packages: + - "linux-headers-{{ ansible_kernel }}" - wireguard \ No newline at end of file diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml new file mode 100644 index 0000000..3cf07f2 --- /dev/null +++ b/zuul.d/jobs.yaml @@ -0,0 +1,30 @@ +# Copyright 2019, VEXXHOST, Inc. +# +# 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. + +- job: + name: ansible-role-wireguard-integration + parent: base + abstract: true + run: tests/run.yaml + post-run: tests/post-run.yaml + +- job: + name: ansible-role-wireguard-integration-centos-7 + parent: ansible-role-wireguard-integration + nodeset: centos-7-2-node + +- job: + name: ansible-role-wireguard-integration-ubuntu-bionic + parent: ansible-role-wireguard-integration + nodeset: ubuntu-bionic-2-node \ No newline at end of file diff --git a/zuul.d/nodesets.yaml b/zuul.d/nodesets.yaml new file mode 100644 index 0000000..9e4d83d --- /dev/null +++ b/zuul.d/nodesets.yaml @@ -0,0 +1,29 @@ +# Copyright 2019, VEXXHOST, Inc. +# +# 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. + +- nodeset: + name: centos-7-2-node + nodes: + - name: primary + label: centos-7 + - name: secondary + label: centos-7 + +- nodeset: + name: ubuntu-bionic-2-node + nodes: + - name: primary + label: ubuntu-bionic + - name: secondary + label: ubuntu-bionic \ No newline at end of file diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index a0a2971..89e78b9 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -15,7 +15,9 @@ - project: check: jobs: - - noop + - ansible-role-wireguard-integration-centos-7 + - ansible-role-wireguard-integration-ubuntu-bionic gate: jobs: - - noop \ No newline at end of file + - ansible-role-wireguard-integration-centos-7 + - ansible-role-wireguard-integration-ubuntu-bionic