Centos 7 desativa nomes de interface de rede previsíveis com packer / vagrant

3

Eu estou tentando atualizar nossa caixa local dev devrant para o CentOS 7.2 (de 6.8), mas tive um problema com os novos "nomes de interface de rede previsíveis". Minha configuração de boneco está esperando eth0 e eth1, mas está ficando enp0s3 e enp0s8.

Consegui desabilitar nomes de interface de rede previsíveis no arquivo de kickstart adicionando:

bootloader --location=mbr --append="net.ifnames=0"

e removendo o pacote biosdevname

Agora, quando minha caixa vagrant é inicializada, tem eth0 e eth1 (mostradas quando faço um ip -a), mas não tenho os scripts de rede em / etc / sysconfig / network-scripts / (apenas ifcfg-enp0s3 e ifcfg-lo).

Quando o vagrant inicializa esta VM, mostra este erro:

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

# Update sysconfig
sed -i 's/\(HOSTNAME=\).*/vm.example.com/' /etc/sysconfig/network

# Update DNS
sed -i 's/\(DHCP_HOSTNAME=\).*/"vm"/' /etc/sysconfig/network-scripts/ifcfg-*

# Set the hostname - use hostnamectl if available
echo 'vm.example.com' > /etc/hostname
if command -v hostnamectl; then
  hostnamectl set-hostname --static 'vm.example.com'
  hostnamectl set-hostname --transient 'vm.example.com'
else
  hostname -F /etc/hostname
fi

# Remove comments and blank lines from /etc/hosts
sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts

# Prepend ourselves to /etc/hosts
grep -w 'vm.example.com' /etc/hosts || {
  sed -i'' '1i 127.0.0.1\tvm.example.com\tvm' /etc/hosts
}

# Restart network
service network restart


Stdout from the command:

/bin/hostnamectl
Restarting network (via systemctl):  [FAILED]


Stderr from the command:

Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details.

journalctl -xe mostra:

-- Unit network.service has begun starting up.
Oct 11 04:28:59 vm.example.com network[3130]: Bringing up loopback interface:  Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'
Oct 11 04:28:59 vm.example.com network[3130]: Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'
Oct 11 04:28:59 vm.example.com network[3130]: Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'
Oct 11 04:28:59 vm.example.com network[3130]: Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'
Oct 11 04:28:59 vm.example.com network[3130]: [  OK  ]
Oct 11 04:28:59 vm.example.com network[3130]: Bringing up interface enp0s3:  Error: Connection activation failed: No suitable device found for this connection.
Oct 11 04:28:59 vm.example.com network[3130]: [FAILED]
Oct 11 04:28:59 vm.example.com network[3130]: RTNETLINK answers: File exists
Oct 11 04:28:59 vm.example.com network[3130]: RTNETLINK answers: File exists
Oct 11 04:28:59 vm.example.com network[3130]: RTNETLINK answers: File exists
Oct 11 04:28:59 vm.example.com network[3130]: RTNETLINK answers: File exists
Oct 11 04:28:59 vm.example.com network[3130]: RTNETLINK answers: File exists
Oct 11 04:28:59 vm.example.com network[3130]: RTNETLINK answers: File exists
Oct 11 04:28:59 vm.example.com network[3130]: RTNETLINK answers: File exists
Oct 11 04:28:59 vm.example.com network[3130]: RTNETLINK answers: File exists
Oct 11 04:28:59 vm.example.com network[3130]: RTNETLINK answers: File exists
Oct 11 04:28:59 vm.example.com systemd[1]: network.service: control process exited, code=exited status=1
Oct 11 04:28:59 vm.example.com systemd[1]: Failed to start LSB: Bring up/down networking.

Como posso manter eth0 e eth1, mas fazer isso funcionar corretamente?

Obrigado

    
por Noodles 11.10.2016 / 06:42

2 respostas

1

Eu adicionei um script de provisionador no empacotador que parece ter corrigido esse problema:

#!/bin/bash

mv /etc/sysconfig/network-scripts/ifcfg-enp0s3 /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i -e 's/enp0s3/eth0/' /etc/sysconfig/network-scripts/ifcfg-eth0
bash -c 'echo NM_CONTROLLED=\"no\" >> /etc/sysconfig/network-scripts/ifcfg-eth0'
    
por 02.11.2016 / 04:25
0

How can I keep eth0 and eth1, but make this work correctly?

Acredito que posso ajudar a responder a primeira parte sobre como manter eth0 e eth1 (ou pelo menos obter uma boa referência). De acordo com Nomeação consistente de dispositivos de rede no Linux , você deve ser capaz de desativar a nova nomenclatura com o seguindo a seção 9 do manual:

Disable during install time

To disable the use of the new naming scheme, during installation (attended or automated), pass the kernel command line parameter biosdevname=0 on the boot command line. The parameter should be passed on the boot command line after installation to ensure that a new network adapter plugged in post installation has a traditional "eth" name.

Tem sido a minha experiência a sua tentativa ou erro se realmente funciona. Veja, por exemplo, Problemas de nomenclatura de dispositivos de rede e aliases para p2p1 e p3p1 de volta para eth0 e eth1 no Super User.

    
por 08.11.2016 / 05:21