-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcloud-init-centos-7.6-ipv4-ena.yml
48 lines (48 loc) · 1.61 KB
/
cloud-init-centos-7.6-ipv4-ena.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#cloud-config
# vim: syntax=yaml
# cloud-init-centos-7-ipv4-ena.yml
#
# This one is intended for new instances where:
# * the ENA adapter is in use, for example for the t3 and m5 instance types.
# * you want IPv4 networking only
#
# This has both ens3 and ens5 in it, although only one of these usually appears in practice,
# due to variability people have reported in starting up ena instances when the grub command
# line parameter "net.ifnames=0" is not present.
#
# Partially derived from:
# * pakdel's sketch of a network service remediation script in https://bugs.centos.org/view.php?id=13836
# * ldennison's comment in https://bugs.centos.org/view.php?id=14760
# * hhsnow's comment in https://bugs.centos.org/view.php?id=14107
# * the cloud-init config in https://docs.aws.amazon.com/vpc/latest/userguide/vpc-migrate-ipv6.html#vpc-migrate-ipv6-instance-types
#
# Tested on CentOS Linux release 7.6.1810 (Core) and a t3.micro
# instance on 2019-05-19
#
# Author:
# Richard Bullington-Mcguire <[email protected]> / @obscurerichard
#
# Copyright (C) 2019 by The Obscure Organization
# MIT licensed. See the LICENSE file for details.
network:
version: 1
config:
- type: physical
name: ens3
subnets:
- type: dhcp4
- type: physical
name: ens5
subnets:
- type: dhcp4
bootcmd:
- |
rm -f /etc/sysconfig/network-scripts/ifcfg-eth0
for PATH_DHCLIENT_PID in /var/run/dhclient*; do
export PATH_DHCLIENT_PID
dhclient -r
# Making sure it really truly stopped
kill $(<PATH_DHCLIENT_PID) || true
rm -f "$PATH_DHCLIENT_PID"
done
systemctl restart network