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

setup module: Replace . by _ in interface name #5201

Closed
wants to merge 2 commits into from
Closed

setup module: Replace . by _ in interface name #5201

wants to merge 2 commits into from

Conversation

jpte
Copy link

@jpte jpte commented Dec 6, 2013

No description provided.

@jctanner
Copy link
Contributor

@jpte in testing this, I'm not actually seeing a difference in the results before and after your patch.

If I compare the regex versus simple string replace, it's doing the same thing:

jtanner@u1304:~/issues/5201-interface_rename$ cat testthis.py 
#!/usr/bin/python

import os
import sys
import re

def oldway(text):
    if ':' in text:
        text = text.replace(':','_')         
    return text    

def newway(text):
    to_replace = '[:\.]'
    if re.search(to_replace, text):
         text = re.sub(to_replace, '_', text)
    return text

textval = "eth0:0"
print oldway(textval)             
print newway(textval)             

jtanner@u1304:~/issues/5201-interface_rename$ python testthis.py 
eth0_0
eth0_0

What did this patch actually fix in your case?

@jpte
Copy link
Author

jpte commented Dec 17, 2013

This patch fix problem with jinja with vlan interface. Usually vlan interface has a dot (ie eth0.110) and jinja use dot to access attributes. So facts like ansible_eth0.110['ipv4']['address'] is not accessible.
Just try with: textval = "eth0.110"

@jctanner
Copy link
Contributor

@jpte if we implemented this, how would a user differentiate a vlan from a secondary interface?

[root@el6 ~]# ifconfig -a | egrep ^eth0
eth0      Link encap:Ethernet  HWaddr 52:54:00:EB:72:6F
eth0.100  Link encap:Ethernet  HWaddr 52:54:00:EB:72:6F
eth0:0    Link encap:Ethernet  HWaddr 52:54:00:EB:72:6F
eth0:1    Link encap:Ethernet  HWaddr 52:54:00:EB:72:6F

@jctanner
Copy link
Contributor

@jpte I'm closing this for the reason stated above. If you would like to propose a better solution for vlan interfaces, please start a thread on the ansible-devel mailing list for further collaboration.

@jctanner jctanner closed this Jan 20, 2014
samdoran pushed a commit to samdoran/ansible that referenced this pull request Oct 13, 2016
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bugfix_pull_request labels Mar 5, 2018
@ansible ansible locked and limited conversation to collaborators Apr 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug. needs_info This issue requires further information. Please answer any outstanding questions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants