Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistently replace '_' with '-' in hostnames #1619

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion netsim/ansible/templates/initial/arcos.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
system hostname {{ inventory_hostname }}
system hostname {{ inventory_hostname.replace('_','-') }}
!
!
interface loopback0
Expand Down
2 changes: 1 addition & 1 deletion netsim/ansible/templates/initial/asa.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
hostname {{ inventory_hostname }}
hostname {{ inventory_hostname.replace('_','-') }}
domain-name lab.local
!
{% for k,v in hostvars.items() if k != inventory_hostname and v.af.ipv4|default(False) %}
Expand Down
2 changes: 1 addition & 1 deletion netsim/ansible/templates/initial/cumulus_nvue.j2
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

- set:
system:
hostname: {{ inventory_hostname }}
hostname: {{ inventory_hostname.replace("_","-") }}
interface:
eth0:
ip:
Expand Down
4 changes: 2 additions & 2 deletions netsim/ansible/templates/initial/frr.j2
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SCRIPT
#
# Configure system defaults on Ubuntu
#
hostnamectl set-hostname {{ inventory_hostname }}
hostnamectl set-hostname {{ inventory_hostname.replace('_','-') }}
sysctl -w net.ipv4.ip_forward=1
sysctl -w net.ipv6.conf.all.forwarding=1
#
Expand Down Expand Up @@ -107,7 +107,7 @@ ip link set {{ l.ifname }} mtu {{ l.mtu }}
# Rest of initial configuration done through VTYSH
#
cat >/tmp/config <<CONFIG
hostname {{ inventory_hostname }}
hostname {{ inventory_hostname.replace('_','-') }}
!
{% if clab is defined and netlab_mgmt_vrf|default(False) %}
vrf mgmt
Expand Down
2 changes: 1 addition & 1 deletion netsim/ansible/templates/initial/ios.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
hostname {{ inventory_hostname }}
hostname {{ inventory_hostname.replace('_','-') }}
!
no ip domain lookup
!
Expand Down
2 changes: 1 addition & 1 deletion netsim/ansible/templates/initial/iosxr.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
hostname {{ inventory_hostname }}
hostname {{ inventory_hostname.replace('_','-') }}
!
domain lookup disable
!
Expand Down
2 changes: 1 addition & 1 deletion netsim/ansible/templates/initial/junos.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
system {
host-name {{ inventory_hostname }};
host-name {{ inventory_hostname.replace('_','-') }};
static-host-mapping {
{% for k,v in hostvars.items() if k != inventory_hostname %}
{% if v.loopback.ipv4 is defined %}
Expand Down
2 changes: 1 addition & 1 deletion netsim/ansible/templates/initial/linux/ubuntu.j2
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ SCRIPT
systemctl restart systemd-resolved

# Set persistent hostname
hostnamectl set-hostname {{ inventory_hostname }}
hostnamectl set-hostname {{ inventory_hostname.replace('_','-') }}

NEED_APT_UPDATE=YES
{% if netlab_net_tools|default(False) %}
Expand Down
4 changes: 2 additions & 2 deletions netsim/ansible/templates/initial/nxos.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{#
NXOS hates single-character hostnames. Prepend 'nxos-' to hostname if it's too short
#}
hostname {{ 'nxos-' if inventory_hostname|length == 1 else '' }}{{ inventory_hostname }}
hostname {{ 'nxos-' if inventory_hostname|length == 1 else '' }}{{ inventory_hostname.replace('_','-') }}
!
no ip domain-lookup
!
Expand All @@ -10,7 +10,7 @@ feature lldp
username vagrant password vagrant
!
{% for hname,hdata in hosts.items() if 'ipv4' in hdata and hname != inventory_hostname %}
ip host {{ hname }} {{ hdata.ipv4[0] }}
ip host {{ hname.replace('_','') }} {{ hdata.ipv4[0] }}
{% endfor %}
!
{% if vlans is defined %}
Expand Down
2 changes: 1 addition & 1 deletion netsim/ansible/templates/initial/routeros.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

/system identity set name="{{ inventory_hostname }}"
/system identity set name="{{ inventory_hostname.replace('_','-') }}"

/interface bridge add name=loopback protocol-mode=none

Expand Down
2 changes: 1 addition & 1 deletion netsim/ansible/templates/initial/routeros7.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

/system identity set name="{{ inventory_hostname }}"
/system identity set name="{{ inventory_hostname.replace('_','-') }}"

/interface bridge add name=loopback protocol-mode=none

Expand Down
2 changes: 1 addition & 1 deletion netsim/ansible/templates/initial/sonic.j2
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fi
# And now let's configure the interfaces
#
cat >/etc/sonic/frr/do_config <<CONFIG
hostname {{ inventory_hostname }}
hostname {{ inventory_hostname.replace('_','-') }}
!
{% if 'ipv6' in af %}
ipv6 forwarding
Expand Down
2 changes: 1 addition & 1 deletion netsim/ansible/templates/isis/eos.macro.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ipv6 unicast-routing
!
router isis {{ isis.instance }}{% if vrf %} vrf {{ vrf }}{% endif +%}
log-adjacency-changes
is-hostname {{ inventory_hostname }}
is-hostname {{ inventory_hostname.replace('_','-') }}
is-type {{ isis.type }}
{% if isis.net is defined %}
net {{ isis.net }}
Expand Down
Loading