Skip to content

Commit

Permalink
trying to figure out why route applying only works once.
Browse files Browse the repository at this point in the history
  • Loading branch information
XaverStiensmeier committed Oct 14, 2023
1 parent a5bd6d0 commit 6eb6e6a
Showing 1 changed file with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
#cloud-config
{% set cloud_identifier = item.cloud_identifier %}

bootcmd:
- /usr/bin/ip route add 10.0.0.0/24 via {{ hostvars[item].private_v4 }} dev ens3
{% for cluster_cidr in cluster_cidrs %}
{% if cluster_cidr.cloud_identifier != hostvars[item].cloud_identifier %}
{% for provider_cidr in cluster_cidr.provider_cidrs %}
- /usr/bin/ip route add {{ provider_cidr }} via {{ hostvars[item].private_v4 }} dev ens3
{% endfor %}
{% endif %}
{% endfor %}
# Create a shell script to apply routes
write_files:
- content: |
#!/bin/bash
echo Adding IP Routes
/usr/bin/ip route add 10.0.0.0/24 via {{ hostvars[item].private_v4 }}
{% for cluster_cidr in cluster_cidrs %}
{% if cluster_cidr.cloud_identifier != hostvars[item].cloud_identifier %}
{% for provider_cidr in cluster_cidr.provider_cidrs %}
/usr/bin/ip route add {{ provider_cidr }} via {{ hostvars[item].private_v4 }}
{% endfor %}
{% endif %}
{% endfor %}
echo "IP Routes Added"
path: /usr/local/bin/apply-routes.sh
permissions: '0755'

# Execute the shell script
runcmd:
- /usr/local/bin/apply-routes.sh

0 comments on commit 6eb6e6a

Please sign in to comment.