From 5237db91a43e04bf7535056ccbd42edbe7f5d1f8 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 24 Sep 2024 22:37:01 +0200 Subject: ipam --- ansible/group_vars/all/ipam.yml | 13 +++++----- ansible/plays/ipam-generate-dns.yml | 7 ++++- ansible/plays/ipam-generate-tf.yml | 4 ++- bin/requirements.txt | 3 ++- docs/2023-10-23 - tnet.drawio | 19 ++++++++------ terraform/dns/dn42.tf | 28 +++++++++++++++----- terraform/ipam6/ipam6.tf | 52 ++++++++++++++++++++++++++----------- 7 files changed, 87 insertions(+), 39 deletions(-) diff --git a/ansible/group_vars/all/ipam.yml b/ansible/group_vars/all/ipam.yml index 9954a21..ed41105 100644 --- a/ansible/group_vars/all/ipam.yml +++ b/ansible/group_vars/all/ipam.yml @@ -10,15 +10,16 @@ ipam6: range: "fdb1:4242:3538::/48" tnet_dn42: range: "fdb1:4242:3538:2000::/52" - conflatorio_dn42: - description: Internal network on host + unused_2001: range: "fdb1:4242:3538:2001::/64" - hosts: - conflatorio: "fdb1:4242:3538:2001::ffff/64" node1_dn42: range: "fdb1:4242:3538:2002::/64" + hosts: + node1: "fdb1:4242:3538:2002::/64" node2_dn42: range: "fdb1:4242:3538:2003::/64" + hosts: + node2: "fdb1:4242:3538:2003::/64" knot_dn42: range: "fdb1:4242:3538:2004::/64" hosts: @@ -34,8 +35,8 @@ ipam6: range: "fdb1:4242:3538:2006::/64" hosts: kv24ix: "fdb1:4242:3538:2006::ffff/64" - conflatorio_dn42_2: - range: "fdb1:4242:3538:2007:1001::/112" + unused_2007: + range: "fdb1:4242:3538:2007::/64" lhn2_dn42: range: "fdb1:4242:3538:2008::/64" hosts: diff --git a/ansible/plays/ipam-generate-dns.yml b/ansible/plays/ipam-generate-dns.yml index 7bdbfaa..d29b3e8 100644 --- a/ansible/plays/ipam-generate-dns.yml +++ b/ansible/plays/ipam-generate-dns.yml @@ -22,6 +22,11 @@ {% endfor %} - debug: msg: "{{ content }}" - - copy: + when: false + - name: Generating ../../terraform/dns/dn42.tf + register: tf + copy: dest: ../../terraform/dns/dn42.tf content: "{{ content }}" + - shell: terraform fmt ../../terraform/ipam6/ipam6.tf + when: "tf.changed" diff --git a/ansible/plays/ipam-generate-tf.yml b/ansible/plays/ipam-generate-tf.yml index f905b51..e43a559 100644 --- a/ansible/plays/ipam-generate-tf.yml +++ b/ansible/plays/ipam-generate-tf.yml @@ -1,6 +1,8 @@ - hosts: localhost gather_facts: no connection: local + collections: + - ansible.utils tasks: - name: Generate terraform/ipam6/ipam6.tf register: tf @@ -10,7 +12,7 @@ output "networks" { value = { {% for name, network in ipam6.networks.items() %} - {% if not (network.range | ipv6) %} + {% if not (network.range | ansible.utils.ipv6) %} Invalid network: {{ network.range }} {% endif %} {{ name }} = { diff --git a/bin/requirements.txt b/bin/requirements.txt index 8a88990..b47e2cd 100644 --- a/bin/requirements.txt +++ b/bin/requirements.txt @@ -1,4 +1,5 @@ -ansible==10.3.0 +ansible==10.4.0 gns3fy==0.8.0 netaddr==1.3.0 swiplserver==1.0.2 +jinja2<3.1 diff --git a/docs/2023-10-23 - tnet.drawio b/docs/2023-10-23 - tnet.drawio index 80d422c..7414262 100644 --- a/docs/2023-10-23 - tnet.drawio +++ b/docs/2023-10-23 - tnet.drawio @@ -1,4 +1,4 @@ - + @@ -458,7 +458,7 @@ - + @@ -516,19 +516,19 @@ - + - + - + @@ -537,7 +537,7 @@ - + @@ -545,7 +545,7 @@ - + @@ -553,7 +553,7 @@ - + @@ -562,6 +562,9 @@ + + + diff --git a/terraform/dns/dn42.tf b/terraform/dns/dn42.tf index 52a2628..2390d5d 100644 --- a/terraform/dns/dn42.tf +++ b/terraform/dns/dn42.tf @@ -7,13 +7,6 @@ resource "linode_domain_record" "dn42-conflatorio" { target = "fdb1:4242:3538:2008:8042:32ff:fe0c:7161" } -resource "linode_domain_record" "dn42-conflatorio-ix" { - domain_id = linode_domain.root.id - name = "conflatorio-ix.dn42" - record_type = "AAAA" - target = "fdb1:4242:3538:2001::ffff" -} - resource "linode_domain_record" "dn42-coregonus-ix" { domain_id = linode_domain.root.id name = "coregonus-ix.dn42" @@ -28,6 +21,13 @@ resource "linode_domain_record" "dn42-danneri" { target = "fdb1:4242:3538:2005:9422:d355:95b7:f170" } +resource "linode_domain_record" "dn42-hash" { + domain_id = linode_domain.root.id + name = "hash.dn42" + record_type = "AAAA" + target = "fdb1:4242:3538:2009::ffff" +} + resource "linode_domain_record" "dn42-knot" { domain_id = linode_domain.root.id name = "knot.dn42" @@ -48,3 +48,17 @@ resource "linode_domain_record" "dn42-lhn2pi" { record_type = "AAAA" target = "fdb1:4242:3538:2008::ffff" } + +resource "linode_domain_record" "dn42-node1" { + domain_id = linode_domain.root.id + name = "node1.dn42" + record_type = "AAAA" + target = "fdb1:4242:3538:2002::" +} + +resource "linode_domain_record" "dn42-node2" { + domain_id = linode_domain.root.id + name = "node2.dn42" + record_type = "AAAA" + target = "fdb1:4242:3538:2003::" +} diff --git a/terraform/ipam6/ipam6.tf b/terraform/ipam6/ipam6.tf index 88f8181..a41a6be 100644 --- a/terraform/ipam6/ipam6.tf +++ b/terraform/ipam6/ipam6.tf @@ -14,16 +14,11 @@ output "networks" { hosts = { } } - conflatorio_dn42 = { - description = "Internal network on host" - range = "fdb1:4242:3538:2001::/64" - address = "fdb1:4242:3538:2001::" - prefix = "64" + unused_2001 = { + range = "fdb1:4242:3538:2001::/64" + address = "fdb1:4242:3538:2001::" + prefix = "64" hosts = { - conflatorio = { - address : "fdb1:4242:3538:2001::ffff" - prefix : "64" - } } } node1_dn42 = { @@ -31,6 +26,10 @@ output "networks" { address = "fdb1:4242:3538:2002::" prefix = "64" hosts = { + node1 = { + address : "fdb1:4242:3538:2002::" + prefix : "64" + } } } node2_dn42 = { @@ -38,6 +37,10 @@ output "networks" { address = "fdb1:4242:3538:2003::" prefix = "64" hosts = { + node2 = { + address : "fdb1:4242:3538:2003::" + prefix : "64" + } } } knot_dn42 = { @@ -84,10 +87,10 @@ output "networks" { } } } - conflatorio_dn42_2 = { - range = "fdb1:4242:3538:2007:1001::/112" - address = "fdb1:4242:3538:2007:1001::" - prefix = "112" + unused_2007 = { + range = "fdb1:4242:3538:2007::/64" + address = "fdb1:4242:3538:2007::" + prefix = "64" hosts = { } } @@ -106,6 +109,17 @@ output "networks" { } } } + hash_dn42 = { + range = "fdb1:4242:3538:2009::/64" + address = "fdb1:4242:3538:2009::" + prefix = "64" + hosts = { + hash = { + address : "fdb1:4242:3538:2009::ffff" + prefix : "64" + } + } + } dn42 = { range = "fd00::/8" address = "fd00::" @@ -118,8 +132,12 @@ output "networks" { output "hosts" { value = { - conflatorio = { - address : "fdb1:4242:3538:2001::ffff" + node1 = { + address : "fdb1:4242:3538:2002::" + prefix : "64" + } + node2 = { + address : "fdb1:4242:3538:2003::" prefix : "64" } knot = { @@ -146,5 +164,9 @@ output "hosts" { address : "fdb1:4242:3538:2008:8042:32ff:fe0c:7161" prefix : "128" } + hash = { + address : "fdb1:4242:3538:2009::ffff" + prefix : "64" + } } } -- cgit v1.2.3