From 4e61c41fbd6a0540599f6a3b22259d023e75d80d Mon Sep 17 00:00:00 2001 From: "max.mehl" Date: Thu, 3 Mar 2022 09:04:00 +0100 Subject: [PATCH] get values of machine cidr by referencing them in group vars --- group_vars/all.yml | 9 ++++++++- roles/client/tasks/main.yml | 4 ++-- roles/server/tasks/main.yml | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/group_vars/all.yml b/group_vars/all.yml index 8d122d4..87f14e3 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -11,6 +11,7 @@ cidrs: ## 10.200.16.1 to 10.200.31.254 ## 4,096 usable IP addresses humans: + name: humans parent: fsfe cidr: 10.200.16.0/20 @@ -18,6 +19,7 @@ cidrs: ### 10.200.16.1 to 10.200.19.254 ### 1,024 usable IP addresses admins: + name: admins parent: humans cidr: 10.200.16.0/22 @@ -25,6 +27,7 @@ cidrs: ### 10.200.20.1 to 10.200.23.254 ### 1,024 usable IP addresses others: + name: others parent: humans cidr: 10.200.20.0/22 @@ -32,9 +35,14 @@ cidrs: ## 10.200.64.1 to 10.200.127.254 ## with 16,384 usable IP addresses machines: + name: machines parent: fsfe cidr: 10.200.64.0/18 +# key of the CIDR you want to use for the client role, +# so automatically configured peers (typically VMs) +machine_cidr: machines + manual_peers: linus: cidr: admins @@ -54,4 +62,3 @@ manual_peers: # - { "cidr": "others", "name": "fani", "admin": "false" } # machines, e.g. # - { "cidr": "machines", "name": "cont1-plutex", "admin": "false" } -machine_cidr: { "name": "machines", "cidr": "10.200.64.0/18", "admin": "false" } diff --git a/roles/client/tasks/main.yml b/roles/client/tasks/main.yml index 35834b6..93db997 100644 --- a/roles/client/tasks/main.yml +++ b/roles/client/tasks/main.yml @@ -75,8 +75,8 @@ shell: | innernet-server add-peer "{{ network_name }}" \ --name "{{ innernet_client }}" \ - --cidr "{{ machine_cidr.name }}" \ - --admin "{{ machine_cidr.admin }}" \ + --cidr "{{ cidrs[machine_cidr]['cidr'] }}" \ + --admin "false" \ --save-config "/root/{{ innernet_client }}.toml" \ --invite-expires "14d" \ --auto-ip \ diff --git a/roles/server/tasks/main.yml b/roles/server/tasks/main.yml index 2b219cb..bcb332d 100644 --- a/roles/server/tasks/main.yml +++ b/roles/server/tasks/main.yml @@ -68,7 +68,7 @@ tags: [cidr] shell: | innernet-server add-cidr "{{ network_name }}" \ - --name "{{ item.key }}" \ + --name "{{ item.name }}" \ --parent "{{ item.value.parent }}" \ --cidr "{{ item.value.cidr }}" \ --yes