debops / ansible-ifupdown

Manage network interface configuration in /etc/network/interfaces
GNU General Public License v3.0
25 stars 14 forks source link

dhclient left dangling #47

Closed sxpert closed 7 years ago

sxpert commented 8 years ago

start point is pxe-installed ubuntu with eth0 configured with dhcp when configuring the following

  - role: 'debops.ifupdown'
    ifupdown_ignore_cap12s: True
    ifupdown_ignore_static: True
    ifupdown_interfaces:
      - iface: 'eth0'
        type: 'interface'
        inet: 'static'
        addresses: '{{ machine.public_ip }}'
        gateway: '{{ bridge.ip_addr|ipaddr("address") }}'
        options: 'dns-nameservers {{ machine.priv_ip|ipaddr("address") }}'
      - iface: 'eth1'
        type: 'interface'
        inet: 'static'
        addresses: '{{ machine.priv_ip }}'

this process is left dangling :

dhclient -1 -v -pf /run/dhclient.eth0.pid -lf /var/lib/dhcp/dhclient.eth0.leases eth0

it should probably be killed by the bash script

drybjed commented 8 years ago

@sxpert Did you try it without setting ifupdown_ignore_cap12s and ifupdown_ignore_static?

sxpert commented 8 years ago

if I do that, nothing happens, all is skipped

TASK [debops.ifupdown : include] ***********************************************
task path: /etc/ansible/roles/debops.ifupdown/tasks/main.yml:4
skipping: [jmmc-ctrl-1] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true}

TASK [debops.ifupdown : Create directory] **************************************
task path: /etc/ansible/roles/debops.ifupdown/tasks/main.yml:7
skipping: [jmmc-ctrl-1] => (item={u'path': u'/etc/network/interfaces.d'})  => {"changed": false, "item": {"path": "/etc/network/interfaces.d"}, "skip_reason": "Conditional check failed", "skipped": true}
skipping: [jmmc-ctrl-1] => (item={u'path': u'/etc/network/interfaces.config.d'})  => {"changed": false, "item": {"path": "/etc/network/interfaces.config.d"}, "skip_reason": "Conditional check failed", "skipped": true}

TASK [debops.ifupdown : include] ***********************************************
task path: /etc/ansible/roles/debops.ifupdown/tasks/main.yml:19
skipping: [jmmc-ctrl-1] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true}

TASK [debops.ifupdown : include] ***********************************************
task path: /etc/ansible/roles/debops.ifupdown/tasks/main.yml:22
skipping: [jmmc-ctrl-1] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true}

TASK [debops.ifupdown : include] ***********************************************
task path: /etc/ansible/roles/debops.ifupdown/tasks/main.yml:25
skipping: [jmmc-ctrl-1] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true}

TASK [debops.ifupdown : include] ***********************************************
task path: /etc/ansible/roles/debops.ifupdown/tasks/main.yml:28
included: /etc/ansible/roles/debops.ifupdown/tasks/revert_interfaces.yml for jmmc-ctrl-1

TASK [debops.ifupdown : Move interfaces out of the way before reversion] *******
task path: /etc/ansible/roles/debops.ifupdown/tasks/revert_interfaces.yml:3
<10.11.0.5> ESTABLISH SSH CONNECTION FOR USER: ansible
<10.11.0.5> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/home/sxpert/.ansible/cp/ansible-ssh-%h-%p-%r -tt 10.11.0.5 '/bin/sh -c '"'"'( umask 22 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1456824988.73-170800470595563 `" && echo "` echo $HOME/.ansible/tmp/ansible-tmp-1456824988.73-170800470595563 `" )'"'"''
<10.11.0.5> PUT /tmp/tmp9zgpFJ TO /home/ansible/.ansible/tmp/ansible-tmp-1456824988.73-170800470595563/command
<10.11.0.5> SSH: EXEC sftp -b - -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/home/sxpert/.ansible/cp/ansible-ssh-%h-%p-%r '[10.11.0.5]'
<10.11.0.5> ESTABLISH SSH CONNECTION FOR USER: ansible
<10.11.0.5> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/home/sxpert/.ansible/cp/ansible-ssh-%h-%p-%r -tt 10.11.0.5 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-nppnkefxailnqvpxnoldernzaiuqnkhg; /bin/sh -c '"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /home/ansible/.ansible/tmp/ansible-tmp-1456824988.73-170800470595563/command; rm -rf "/home/ansible/.ansible/tmp/ansible-tmp-1456824988.73-170800470595563/" > /dev/null 2>&1'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"''"'"'"'"'"'"'"'"''"'"''
ok: [jmmc-ctrl-1] => {"changed": false, "cmd": "rm -f /etc/network/interfaces", "invocation": {"module_args": {"_raw_params": "rm -f /etc/network/interfaces", "_uses_shell": false, "chdir": null, "creates": null, "executable": null, "removes": "/etc/network/interfaces.dpkg-divert", "warn": true}, "module_name": "command"}, "rc": 0, "stderr": false, "stdout": "skipped, since /etc/network/interfaces.dpkg-divert does not exist", "stdout_lines": ["skipped, since /etc/network/interfaces.dpkg-divert does not exist"]}

TASK [debops.ifupdown : Revert original /etc/network/interfaces] ***************
task path: /etc/ansible/roles/debops.ifupdown/tasks/revert_interfaces.yml:6
<10.11.0.5> ESTABLISH SSH CONNECTION FOR USER: ansible
<10.11.0.5> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/home/sxpert/.ansible/cp/ansible-ssh-%h-%p-%r -tt 10.11.0.5 '/bin/sh -c '"'"'( umask 22 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1456824988.86-169964816586425 `" && echo "` echo $HOME/.ansible/tmp/ansible-tmp-1456824988.86-169964816586425 `" )'"'"''
<10.11.0.5> PUT /tmp/tmp7uRKmy TO /home/ansible/.ansible/tmp/ansible-tmp-1456824988.86-169964816586425/command
<10.11.0.5> SSH: EXEC sftp -b - -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/home/sxpert/.ansible/cp/ansible-ssh-%h-%p-%r '[10.11.0.5]'
<10.11.0.5> ESTABLISH SSH CONNECTION FOR USER: ansible
<10.11.0.5> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/home/sxpert/.ansible/cp/ansible-ssh-%h-%p-%r -tt 10.11.0.5 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-dfhfflqiwbkvssxrspesxovzendkhcsu; /bin/sh -c '"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /home/ansible/.ansible/tmp/ansible-tmp-1456824988.86-169964816586425/command; rm -rf "/home/ansible/.ansible/tmp/ansible-tmp-1456824988.86-169964816586425/" > /dev/null 2>&1'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"''"'"'"'"'"'"'"'"''"'"''
ok: [jmmc-ctrl-1] => {"changed": false, "cmd": "dpkg-divert --quiet --local --rename --remove /etc/network/interfaces", "invocation": {"module_args": {"_raw_params": "dpkg-divert --quiet --local --rename --remove /etc/network/interfaces", "_uses_shell": false, "chdir": null, "creates": null, "executable": null, "removes": "/etc/network/interfaces.dpkg-divert", "warn": true}, "module_name": "command"}, "rc": 0, "stderr": false, "stdout": "skipped, since /etc/network/interfaces.dpkg-divert does not exist", "stdout_lines": ["skipped, since /etc/network/interfaces.dpkg-divert does not exist"]}
drybjed commented 8 years ago

OK, so what's the configuration like? Is that a VM, a container, hardware? What does the default /etc/network/interfaces have? Is this system using systemd or other init?

The interface configuration process is designed roughly like this:

So, in other words, dhclient should have been killed automatically by ifupdown scripts. But it depends on the initial configuration.

Did you try configuring that host with DebOps without any config, just for testing?

sxpert commented 8 years ago

the system is a qemu/kvm vm, running ubuntu 14.04 minimal setup, the install is pxe-booted. initially /etc/network/interfaces contains :

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

manually running ifdown eth0 indeed removes the dhclient process

what do you mean in the last question ?

drybjed commented 8 years ago

@sxpert Do you try to use the debops.ifupdown role on its own in your custom setup, or do you use full DebOps playbook to configure the system?

This configuration should be handled without issue (dangling dhclient), and without the two ignore variables set.

sxpert commented 8 years ago

yes, I use debops.ifupdown by itself. I guess I could look into using debops.bootstrap, considering lots of the work I did does the same thing ;-) (I only recently discovered debops) If I remove the 2 ignore variable, then ifupdown does nothing

drybjed commented 8 years ago

@sxpert So, what ifupdown_* variables do you have set? Check the main.yml file, there is a set of conditions, without any variables set it should automatically detect the environment and run different configurations according to it. Is Network Manager installed, since that's Ubuntu?

Add a bunch of debug tasks and check all the variables included in when conditions, check which one makes the conditions not valid.

sxpert commented 8 years ago

no, I don't have network manager. not touching that one with a 10m pole on a server ;-) will try

sxpert commented 8 years ago

here's what I have in syslog:

syslog:Mar  1 11:22:02 jmmc-ctrl-1 ifupdown-reconfigure-interfaces: Interface state: removed=// generated=/eth0 eth1/ auto=/eth0 eth1/ hotplug=/eth0 eth1/ start=/eth0 eth1/ list=/eth0 eth1/
syslog:Mar  1 11:22:02 jmmc-ctrl-1 ifupdown-reconfigure-interfaces: Stopping networking service
syslog:Mar  1 11:22:02 jmmc-ctrl-1 ifupdown-reconfigure-interfaces: Starting up eth0 interface
syslog:Mar  1 11:22:02 jmmc-ctrl-1 ifupdown-reconfigure-interfaces: Starting up eth1 interface
drybjed commented 8 years ago

Yup, so as I just explained above, script stops all networking (the first time) and starts up interfaces separately. Not sure why that dhclient stays there.

Can you try with Debian Stable instead? See if it works there? It has systemd, so it should "take care" of that dhclient better than sysvinit.