summaryrefslogtreecommitdiff
path: root/roles/gre_tunnel/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'roles/gre_tunnel/tasks')
-rw-r--r--roles/gre_tunnel/tasks/main.yml20
-rw-r--r--roles/gre_tunnel/tasks/verify.yml15
2 files changed, 35 insertions, 0 deletions
diff --git a/roles/gre_tunnel/tasks/main.yml b/roles/gre_tunnel/tasks/main.yml
new file mode 100644
index 0000000..5f8a90a
--- /dev/null
+++ b/roles/gre_tunnel/tasks/main.yml
@@ -0,0 +1,20 @@
+---
+- name: Create the tunnel interfaces
+ # vyos_interfaces cannot set encapsulation or endpoints, and a tunnel must
+ # be created with them in one commit, so this goes through vyos_config.
+ vyos.vyos.vyos_config:
+ lines: "{{ _gre_tunnel_cli_lines }}"
+ register: _gre_tunnel_r_cli
+ when: not (vyos_blueprints_render_only | default(false) | bool)
+
+- name: Address the tunnel interfaces
+ vyos.vyos.vyos_l3_interfaces:
+ config: "{{ _gre_tunnel_l3 }}"
+ state: "{{ _gre_tunnel_state }}"
+ register: _gre_tunnel_r_l3
+ when: _gre_tunnel_l3 | length > 0
+
+- name: Collect rendered commands # noqa: var-naming[no-role-prefix] - shared across roles by design
+ ansible.builtin.set_fact:
+ vyos_blueprints_rendered: "{{ vyos_blueprints_rendered | default([]) + _gre_tunnel_cli_lines + (_gre_tunnel_r_l3.rendered | default([])) }}"
+ when: vyos_blueprints_render_only | default(false) | bool
diff --git a/roles/gre_tunnel/tasks/verify.yml b/roles/gre_tunnel/tasks/verify.yml
new file mode 100644
index 0000000..52cb45f
--- /dev/null
+++ b/roles/gre_tunnel/tasks/verify.yml
@@ -0,0 +1,15 @@
+---
+- name: Read interfaces
+ vyos.vyos.vyos_command:
+ commands:
+ - show interfaces
+ register: _gre_tunnel_v
+
+- name: Every tunnel interface is up
+ ansible.builtin.assert:
+ that: _gre_tunnel_v.stdout[0] is search('(?m)^' ~ (item.name | regex_escape) ~ '\s.*\bu/u\b')
+ fail_msg: "tunnel {{ item.name }} is not up"
+ quiet: true
+ loop: "{{ gre_tunnel_interfaces }}"
+ loop_control:
+ label: "{{ item.name }}"