更新时间:2022-07-12 GMT+08:00
        
          
          
        
      
      
      
      
      
      
      
      
  
      
      
      
        
cloud-init-0.7.9及以上版本配置
- 添加如下键值对,前后各空出一行:
   
no_ssh_fingerprints: true
 - 设置ssh_pwauth为false或0,该选项表示是否支持ssh密码登录。false或0为禁用。
   
ssh_pwauth: false
 - 修改disable_root为false。该参数表示是否禁用远程ssh root登录。
   
disable_root: true
 - 添加preserve_hostname: false。
   
preserve_hostname: false
 - 使用“#”注释掉以下语句(不存在忽略):
   
mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2'] resize_rootfs_tmp: /dev ssh_deletekeys: 0
 - 修改ssh_genkeytypes为下面语句(不存在添加):
   
ssh_genkeytypes: ['rsa', 'dsa']
 - 修改syslog_fix_perms为下面语句(不存在添加):
   
syslog_fix_perms: root:root
 - 添加下面语句:
   
network: config: disabled datasource_list: [ OpenStack ] datasource: OpenStack: metadata_urls: ['http://169.254.169.254'] max_wait: 120 timeout: 10 retries: 5 - (可选)在“/etc/cloud/cloud.cfg”中配置“apply_network_config: False”。
   
对于使用Cloud-Init 18.3及以上版本的用户,需执行本操作

 - 在cloud_final_modules段的“- final-message”后面添加一句:
   
- power-state-change
 - 查看并修改system info中的信息:
   
system_info: distro: rhel default_user: name: linux //登录操作系统使用的用户名 lock_passwd: True //True表示禁用密码登录方式,注意部分操作系统此处配置为1表示禁用其中,distro参数需要根据具体操作系统类型修改,比如distro: sles、distro: rhel、distro: ubuntu、distro: debian、dustro: fedora等。
 - (可选)对于SUSE 12 SP1和SUSE 12 SP2操作系统,还需要修改“/usr/lib/systemd/system/cloud-init-local.service”配置文件的[Unit]配置信息。
   
vi /usr/lib/systemd/system/cloud-init-local.service
保持[Unit]配置项与下面内容一致:
[Unit] Description=Initial cloud-init job (pre-networking) DefaultDependencies=no Wants=network-pre.target Wants=local-fs.target After=local-fs.target Before=network-pre.target Before=shutdown.target Before=basic.target Conflicts=shutdown.target # Other distros use Before=sysinit.target. There is not a clearly identified # reason for usage of basic.target instead.
 - (可选)对于Ubuntu 16.04操作系统,还需要执行以下命令,配置OpenStack源。
   
   

执行命令vim /etc/cloud/cloud.cfg.d/90_dpkg.cfg打开配置文件,检查配置项是否正确。
# to update this file, run dpkg-reconfigure cloud-init datasource_list: [ OpenStack ] ~ ~ ~
配置文件和以上回显信息一致,表示配置成功。
 
   父主题: 配置Cloud-Init