OpenStack Image maker-centos

Source: Internet
Author: User

Mirroring in the cloud platform is also important, providing a variety of customized images to make the user experience even better.

The first time you played OpenStack was with the Cirros mentioned in the installation documentation, whose password Cubswin:) It was strange at first, and now it's ready to be played. PS: Playing is also very skilled:-)

Then slowly began to want to try a variety of mirrors, and so on the internet search a lot. As follows:

  • Official Document Http://docs.openstack.org/image-guide/content/ch_obtaining_images.html
    The official documentation gives a lot of links to the images, including
    Cirros (test) images
    Official Ubuntu Images
    Official Red Hat Enterprise Linux Images
    Official Fedora Images
    Official OpenSUSE and SLES images
    Official images from the other Linux distributions
    Rackspace Cloud Builders (multiple distros) images
    Microsoft Windows Images
  • CentOS Image http://cloud.centos.org/
  • Rackspace Cloud Builders Https://github.com/rcbops/oz-image-build
  • Radhat Mirror Https://openstack.redhat.com/Image_resources
  • CentOS Gold Image
    http://catn.com/labs/centos-images/
    http://catn.com/2013/04/18/building-a-virtual-machine-image-for-centos/
    Teach you how to create an image of CentOS and provide a ready-made image download
    Image: Http://mirror.catn.com/pub/catn/images/qcow2/centos6.4-x86_64-gold-master.img
    The image user name: root password: changeme1122

There are a few things to note about CentOS image production:

(1) Modify the network information/etc/sysconfig/network-scripts/ifcfg-eth0 (erase Mac information), as follows:

Type=Ethernetdevice=eth0onboot=Yesbootproto=dhcpnm_controlled=no

(2) Delete the generated network device rules, otherwise the created image cannot be connected to the Internet

rm -rf/etc/udev/rules.d/

(3) Add a line to/etc/sysconfig/network

Nozerconf=yes

(4) Install cloud-init (optional), cloud-init can be at boot-up key injection and modify hostname , and so on, about Cloud-init, Chen Shak a Boven introduction:/http www.chenshake.com/about-openstack-centos-mirror/

# Yum Install -y cloud-utils Cloud-init parted
To modify the configuration file/etc/cloud/cloud.cfg, add the following cloud_init_modules:
-Resolv-conf

(5) Setup system can automatically obtain hostname and Ssh-key specified by OpenStack (optional)
Edit the/etc/rc.local file, which will execute after booting and add the following code:

1 if[!-d/root/.SSH]; Then2 mkdir-p/root/.SSH3 chmod  the/root/.SSH4 fi5 # Fetch Public key using HTTP6attempts= -7Failed=08 9  Ten  One  while[!-f/root/.SSH/authorized_keys]; Do ACurl-f http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key >/tmp/metadata-key 2>/dev/null - if[$?-eq0]; Then - Cat/tmp/metadata-key >>/root/.SSH/Authorized_keys the chmod 0600/root/.SSH/Authorized_keys -restorecon/root/.SSH/Authorized_keys - RM-f/tmp/metadata-Key - Echo"Successfully retrieved public key from instance metadata" + Echo“*****************" - Echo"AUTHORIZED KEYS" + Echo“*****************" A Cat/root/.SSH/Authorized_keys at Echo“*****************" -  -Curl-f http://169.254.169.254/latest/meta-data/hostname >/tmp/metadata-hostname 2>/dev/null - if[$?-eq0]; Then -Temp_host= 'Cat/tmp/metadata-hostname` - sed-I "S/^hostname=.*$/hostname= $TEMP _host/g"/etc/sysconfig/Network in/bin/hostname$TEMP _host - Echo"Successfully retrievedhostnameFrom instance metadata " to Echo“*****************" + Echo"HOSTNAME CONFIG" - Echo“*****************" the Cat/etc/sysconfig/Network * Echo“*****************" $ Panax Notoginseng Else - Echo"Failed to retrievehostnameFrom instance metadata. This was a soft error so we ' ll continue " the fi + RM-f/tmp/metadata-hostname A Else thefailed=$ (($FAILED +1)) + if[$FAILED-ge $ATTEMPTS]; Then - Echo"Failed to retrieve public key from instance metadata after $FAILED attempts, quitting" $  Break $ fi - Echo"Could not retrieve public key from instance metadata (attempt # $FAILED/$ATTEMPTS), retryinginch 5seconds ... " - Sleep 5 the fi -  Done 

Or

1 # Set a random pass on first boot2 if[-f/root/firstrun]; Then3   DD if=/dev/urandom count= -|md5sum|passwd--stdin Root4   passwd-L Root5   RM/root/FirstRun6 fi7 8 if[!-d/root/.SSH]; Then9   mkdir-M0700-p/root/.SSHTenrestorecon/root/.SSH One fi A# Get The rootSSHKey Setup -# Get The rootSSHKey Setup -retry=0 the  while[!-f/root/.SSH/authorized_keys] && [$ReTry-ltTen]; Do -   Sleep 2 -Curl-f http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key >/root/.ssh/pubkey -   if[0-eq0]; Then +     MV/root/.SSH/pubkey/root/.SSH/Authorized_keys -   fi +retry=$[retry+1] A  Done at chmod  -/root/.SSH/authorized_keys && restorecon/root/.SSH/authorized_keys

The main goal is to get hostname and public keys

(6) Other

Route command to view the routing table

See if Permitrootlogin is yes in/etc/ssh/sshd_conf

OpenStack Image maker-centos

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.