EC2 Cloud Init / Networking

567 views
Skip to first unread message

Matthew Kettlewell

unread,
Jul 30, 2016, 10:30:16 PM7/30/16
to Packer
Hello -

I've been trying to build a custom CentOS packer image for a few weeks, and can get just about everything to work, except for the initial /etc/resolv.conf requires a network restart to pickup the DHCP .

I'm using latest Packer with Virtualbox OVA... uploading to S3, and importing the ova into and amazon AMI ... when I create the instance, the networking doesn't work because there are no DNS resolvers set. However, after restarting networking, my DHCP Option Sets from Amazon are picked up, and all is good.

It was my impression that including cloud-init was all that was required, and that networking should "just work", so clearly I'm doing something wrong.... not sure if it's the way I'm using packer, or if it's an AWS config setting ... 

Any assistance on what I'm doing wrong would be greatly appreciated.

Below is exactly what I see upon starting up a new instance with my AMI ... 


[centos@ip-10-0-0-7 ~]$ cat /etc/resolv.conf

# Generated by NetworkManager
search ec2
.internal

# No nameservers found; try putting DNS servers into your
# ifcfg files in /etc/sysconfig/network-scripts like so:
#
# DNS1=xxx.xxx.xxx.xxx
# DNS2=xxx.xxx.xxx.xxx
# DOMAIN=lab.foo.com bar.foo.com

[centos@ip-10-0-0-7 ~]$ sudo systemctl restart network

[centos@ip-10-0-0-7 ~]$ cat /etc/resolv.conf

; generated by /usr/sbin/dhclient-script
search ec2
.internal
nameserver
8.8.8.8
nameserver
8.8.4.4
nameserver
4.2.2.1





Thanks -

Matt










Alvaro Miranda Aguilera

unread,
Jul 30, 2016, 11:10:28 PM7/30/16
to packe...@googlegroups.com
hello, what version of centos is ? 

can you share the content of

/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-<eth*,e*>

thanks

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/4ba1dd61-203c-4913-b15e-fd3d28865b9e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Matthew Kettlewell

unread,
Jul 30, 2016, 11:28:32 PM7/30/16
to Packer

Hi Alvaro - 

Thanks for taking the time to take a look.   Here's the files you requested ... 

[centos@ip-10-0-0-11 ~]$ cat /etc/sysconfig/network                        
# Automatically generated by the vm import process
NETWORKING
=yes



[centos@ip-10-0-0-11 ~]$ ls /etc/sysconfig/network-scripts/ifcfg-e*
/etc/sysconfig/network-scripts/ifcfg-eth0
[centos@ip-10-0-0-11 ~]$ cat /etc/sysconfig/network-scripts/ifcfg-e*
# Automatically generated by the vm import process
DEVICE
=eth0
ONBOOT
=yes
BOOTPROTO
=dhcp
TYPE
=Ethernet
NM_CONTROLLED
=no



[centos@ip-10-0-0-11 ~]$ cat /etc/*release
CentOS Linux release 7.2.1511 (Core)
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"


CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"


CentOS Linux release 7.2.1511 (Core)
CentOS Linux release 7.2.1511 (Core)



On Saturday, July 30, 2016 at 10:10:28 PM UTC-5, Alvaro Miranda Aguilera wrote:
hello, what version of centos is ? 

can you share the content of

/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-<eth*,e*>

thanks
--

 

gork...@gmail.com

unread,
Sep 15, 2016, 10:33:24 AM9/15/16
to Packer
Hello,

I am having the same issue. Have you managed to sort this out?

Thanks.

Rickard von Essen

unread,
Sep 15, 2016, 5:08:09 PM9/15/16
to Packer
I must first ask why not use the amazon-ebs builder and use CentOS official api's?

To build from scratch seems like overly complicated.

If you still want to build from scratch I think it's good to carefully review the Kickstart for the official AMI's.

https://github.com/CentOS/sig-cloud-instance-build/blob/master/cloudimg/CentOS-7-x86_64-GenericCloud-201606-r1.ks

Alvaro Miranda Aguilera

unread,
Sep 15, 2016, 6:06:27 PM9/15/16
to packe...@googlegroups.com
hello

can you share what the issue you are having and whats messages you are seeing ?

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/f037c92a-11cb-4cfd-88a1-1dae8393dc0f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

gork...@gmail.com

unread,
Sep 19, 2016, 4:07:58 AM9/19/16
to Packer
I had the same "empty" /etc/resolv.conf as Matt had.
Thanks for the official ks.cfg I will check it out when I have time and rebuild my AMI. For now I stick with the Official CentOS AMI.

Thanks,

G.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.



--
Reply all
Reply to author
Forward
0 new messages