Cloud-init

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

External

Internal

Overview

Cloud-init is an industry standard method for cross-platform cloud instance initialization. It is supported across all major cloud providers.

Cloud instances are initialized from a disk image and instance data. Instance data consists of:

  • Cloud metadata
  • User data
  • Vendor data

Cloud-init identifies during boot the cloud the instance is running, reads any provided cloud metadata from the cloud and initializes the system accordingly - sets up network, storage, SSH access, etc. Cloud-init then parses and processes user data, if available and vendor data, if available.

The cloud-init runtime is written in python.

Installation

yum install cloud-init

Configuration

cloud-init configuration is maintained in a YAML-format file:

/etc/cloud/cloud.cfg

Example

users:
 - default

disable_root: 1
ssh_pwauth:   0

mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2']
resize_rootfs_tmp: /dev
ssh_deletekeys:   0
ssh_genkeytypes:  ~
syslog_fix_perms: ~

cloud_init_modules:
 - migrator
 - bootcmd
 - write-files
 - growpart
 - resizefs
 - rsyslog
 - users-groups
 - ssh

cloud_config_modules:
 - mounts
 - locale
 - set-passwords
 - yum-add-repo
 - package-update-upgrade-install
 - timezone
 - puppet
 - chef
 - salt-minion
 - mcollective
 - disable-ec2-metadata
 - runcmd

cloud_final_modules:
 - rightscale_userdata
 - scripts-per-once
 - scripts-per-boot
 - scripts-per-instance
 - scripts-user
 - ssh-authkey-fingerprints
 - keys-to-console
 - phone-home
 - final-message

system_info:
  default_user:
    name: ec2-user
    lock_passwd: true
    gecos: Cloud User
    groups: [wheel, adm, systemd-journal]
    sudo: ["ALL=(ALL) NOPASSWD:ALL"]
    shell: /bin/bash
  distro: rhel
  paths:
    cloud_dir: /var/lib/cloud
    templates_dir: /etc/cloud/templates
  ssh_svcname: sshd

# vim:syntax=yaml

Concepts

Cloud Dir

The "cloud_dir" is configured in /etc/cloud/cloud.cfg and it is "/var/lib/cloud" by default.

Setting hostname

Done by the following modules, that work with systemd-hostnamed:

...

cloud_init_modules:
  
 ...

 - set_hostname
 - update_hostname
 - update_etc_hosts

 ...

Organizatorium