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

network_config redhat provider fails in case DEVICE parameter is not present in ifcfg-* file #89

Closed
stzilli opened this issue Nov 26, 2014 · 4 comments

Comments

@stzilli
Copy link
Contributor

stzilli commented Nov 26, 2014

network_config parses all the ifcft-* files before applying any change to any of them. In case one any of these file have no DEVICE property the parsing will fail and puppet run will consequently fail. I've seen some of these cases in CentOS 7 machines.

On my side I applied the following patch but I can say it's not very elegant.

--- a/code/lib/puppet/provider/network_config/redhat.rb
+++ b/code/lib/puppet/provider/network_config/redhat.rb
@@ -121,6 +121,12 @@ Puppet::Type.type(:network_config).provide(:redhat) do
     #
     props.merge!({:family => :inet})

+    # If there is no DEVICE property in the interface configuration we retrieve
+    # the interface name from the file name itself
+    unless props.has_key?(:name)
+        props.merge!({:name => filename.split("ifcfg-")[1]})
+    end
+
     # The FileMapper mixin expects an array of providers, so we return the
     # single interface wrapped in an array
     [props]
@legooolas
Copy link

I've also found that setting a pre-existing device as absent with "ensure => absent" causes the ifcfg-name file to be set to empty, and causes puppet to throw an error:

Error: Could not prefetch network_config provider 'redhat': No resource and no name in property hash in redhat instance
Notice: /Stage[main]/Site::Network::Interfaces/Network_config[eth1]/ensure: created
Error: /Stage[main]/Site::Network::Interfaces/Network_config[eth1]: Could not evaluate: No resource and no name in property hash in redhat instance

(eth0 is set as absent, eth1 is the next in the list of interfaces to configure)

If this file is removed entirely rather than left empty this does not occur.

Applying the same patch as above works around this for me too.

@igalic
Copy link
Contributor

igalic commented Dec 16, 2014

i think that's a sensible solution.

@igalic
Copy link
Contributor

igalic commented Dec 16, 2014

@stzilli would you mind turning this into a Pull Request?

@stzilli
Copy link
Contributor Author

stzilli commented Feb 4, 2015

PR #90 contains the patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants