The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

Bug #6268

service{"network": ensure => running } fails on Redhat/Centos w/ dhcp interface

Added by Chip Schweiss almost 4 years ago. Updated almost 2 years ago.

Status:Needs More InformationStart date:02/09/2011
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-
Affected Puppet version: Branch:
Keywords:

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com

This ticket may be automatically exported to the PUP project on JIRA using the button below:


Description

Puppet is always reading the status as stopped and attempts to start the service on every run. If the interface is dhcp the start command fails because dhclient is already running.

Puppet needs to properly determine the status.

History

#1 Updated by James Turnbull almost 4 years ago

  • Target version changed from 2.6.x to 2.6.6

#2 Updated by Stefan Schulte almost 4 years ago

What is the output if you run service network status and what is its return value?

#3 Updated by Nan Liu almost 4 years ago

  • Status changed from Unreviewed to Needs More Information

I’m testing against a CentOS 5.5 system running dhcp and can not duplicate this issue:

puppet resource service network ensure=running hasstatus=true
service { 'network':
    ensure => 'running'
}

A bit more info would be beneficial. Can you provide your puppet manifest? Can you execute just the service resource with debug option? i.e. puppet apply -d dhcp.pp

$ puppet resource service network ensure=running hasstatus=true -d
debug: Service[network](provider=redhat): Executing '/sbin/service network status'
debug: Service[network](provider=redhat): Executing '/sbin/service network status'
service { 'network':
    ensure => 'running'
}

For example the output above shows it’s running the command /sbin/service network status to determine network interface status and it’s successfully detecting the interface is running.

#4 Updated by Chip Schweiss almost 4 years ago

The above commands execute successfully on my systems.

If I execute in my manifests the network service is in the “pre” stage and fails:

err: /Stage[pre]/Network/Service[network]/ensure: change from stopped to running failed: Could not start Service[network]: Execution of ‘/sbin/service network start’ returned 1: at /etc/puppetmaster/developement/modules/network/manifests/init.pp:92

I have written my own status command, so to reproduce the error I commented the lines to call my status script:

The init.pp from my network class:

# manifests/init.pp

class network {

    $ifs = $nrg_net["$fqdn"]['ifs']

    define config {
        $iface  = $nrg_net["$fqdn"]["$name"]
        case $iface['mode'] {
            'dhcp':{
                file { "/etc/sysconfig/network-scripts/ifcfg-$name":
                    owner => root,
                    group => root,
                    mode => 600,
                    content =>
                        template("network/sysconfig/network-scripts/ifcfg.interface.dhcp.erb"),
                    ensure => present,
                    before => Host["$hostname"],
                    notify => Service["network"],
                }
            }
            default: {
                $ip = $iface['ip']
                $mask   = $iface['mask']
                $defgw  = $iface['gw']
                $onboot = 'yes'
                $mule   = "macaddress_${name}"
                $macaddress = inline_template("<%= scope.lookupvar(mule) %>")

                file { "/etc/sysconfig/network-scripts/ifcfg-$name":
                    owner => root,
                    group => root,
                    mode => 600,
                    content =>
                        template("network/sysconfig/network-scripts/ifcfg.interface.new.erb"),
                    ensure => present,
                    before => Host["$hostname"],
                    notify => Service["network"],
                }

                if $defgw =~ /\./ {
                    if ! defined(File["/etc/sysconfig/network"]) {
                        file { "/etc/sysconfig/network":
                            owner => root,
                            group => root,
                            mode => 600,
                            content => template("network/sysconfig/network.new.erb"),
                            ensure => present,
                            before => Host["$hostname"],
                            notify => [ Service["network"], Exec["reboot"] ],
                        }
                    }
                }
            }
        }
    }

    config { $ifs: }

    $routes = $nrg_net["$fqdn"]['routes']

    if $routes =~ /\./ {
        file { "/etc/sysconfig/static-routes":
            owner => root,
            group => root,
            mode => 600,
            content => template("network/static-routes.erb"),
            ensure => present,
            before => Host["$hostname"],
            notify => Service["network"],
        }
    }

    file {
        '/etc/puppet/bin':
            ensure => directory;
        'network_status':
            path => "/etc/puppet/bin/network.status",
            source => "puppet:///modules/network/network.status",
            require => File['/etc/puppet/bin'];
    }

    file { '/etc/sysconfig/network-scripts/ifcfg-eth1.bak':
        ensure => absent,
    }

    service { "network":
        ensure => running,
        #status => "/etc/puppet/bin/network.status",
        before => Host["$hostname"],
        #require => File['network_status'],
    }

}

(Sorry could not get ‘inline code’ to properly include the comment and class lines.

#5 Updated by Jacob Helwig almost 4 years ago

Chip,

I edited your comment to get them showing up correctly. Indenting code blocks by 4 spaces seems to be the most robust way of handling code blocks in Redmine.

#6 Updated by Stefan Schulte almost 4 years ago

Can you please run puppet agent (or puppet apply) with --debug. This should give us info what provider puppet uses and what exact commands it runs. So I am not sure if puppet automatically uses service network status (hasstatus=>true) on CentOS to check if a service is running. If you see the provider running ps -ef this could be the problem. Because I guess the process that is started with service network start is not called network?

Can you then try to specify your service with hasstatus => true

#7 Updated by James Turnbull almost 4 years ago

  • Target version changed from 2.6.6 to 2.6.x

#8 Updated by Stefan Schulte over 3 years ago

If I’m correct with my assumption that the defaultvalue for hasstatus is false on CentOS and network is not a “program” that will show up when running ps -ef #7018 is the appropriate “fix”.

#9 Updated by Michael Stahnke almost 3 years ago

  • Target version changed from 2.6.x to 2.7.x

2.6.x is closed. Moving to 2.7.x

#10 Updated by Anonymous almost 2 years ago

  • Target version deleted (2.7.x)

#11 Updated by Anonymous almost 2 years ago

As the 2.7.x line is winding down, I am removing the target at 2.7.x from tickets in the system. The 2.7 line should only receive fixes for major problems (crashes, for instance) or security problems.

Also available in: Atom PDF