裸金属服务器 BMS-cloud-init-0.7.9及以上版本配置

时间:2025-02-12 15:09:30

cloud-init-0.7.9及以上版本配置

  1. 添加如下键值对,前后各空出一行:
    no_ssh_fingerprints: true
  2. 设置ssh_pwauth为false或0,该选项表示是否支持ssh密码登录。false或0为禁用。
    ssh_pwauth: true
  3. 修改disable_root为false。该参数表示是否禁用远程ssh root登录。
    disable_root: false
  4. 添加preserve_hostname: false。
    preserve_hostname: false
  5. 使用“#”注释掉以下语句(不存在忽略):
    mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2']resize_rootfs_tmp: /devssh_deletekeys:   0
  6. 修改ssh_genkeytypes为下面语句(不存在添加):
    ssh_genkeytypes: ['rsa', 'dsa']
  7. 修改syslog_fix_perms为下面语句(不存在添加):
    syslog_fix_perms: root:root
  8. 添加下面语句:
    network:   config: disableddatasource_list: [ OpenStack ]datasource:  OpenStack:    metadata_urls: ['http://169.254.169.254']    max_wait: 120    timeout: 10    retries: 5
  9. (可选)在“/etc/cloud/cloud.cfg”中配置“apply_network_config: False”。

    对于使用Cloud-Init 18.3及以上版本的用户,需执行本操作

  10. 在cloud_final_modules段的“- final-message”后面添加一句:
    -power_state_change
  11. 查看并修改system info中的信息:
    system_info:   distro: rhel   default_user:     name: root   //登录操作系统使用的用户名     lock_passwd: False   //True表示禁用密码登录方式,注意部分操作系统此处配置为1表示禁用

    其中,distro参数需要根据具体操作系统类型修改,比如distro: sles、distro: rhel、distro: ubuntu、distro: debian、dustro: fedora等。

  12. (可选)对于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=noWants=network-pre.targetWants=local-fs.targetAfter=local-fs.targetBefore=network-pre.targetBefore=shutdown.targetBefore=basic.targetConflicts=shutdown.target# Other distros use Before=sysinit.target. There is not a clearly identified# reason for usage of basic.target instead.
  13. (可选)对于Ubuntu 16.04操作系统,还需要执行以下命令,配置OpenStack源。

    dpkg-reconfigure cloud-init

    执行命令vim /etc/cloud/cloud.cfg.d/90_dpkg.cfg打开配置文件,检查配置项是否正确。

    # to update this file, run dpkg-reconfigure cloud-initdatasource_list: [ OpenStack ]~~~

    配置文件和以上回显信息一致,表示配置成功。

support.huaweicloud.com/bpicg-bms/zh-cn_topic_0000001359349984.html