Heat 相关,Cloud-init & Cloud-config

本文介绍了cloud-init如何在虚拟机启动后执行编排任务,并通过Nova USER DATA传递数据。同时深入探讨了cloud-config的常用功能,如更新软件、配置用户和SSH。接着讲解了HEAT用于部署虚拟环境的特性,包括资源类型、输出和常用函数。最后,讨论了如何将HEAT与cloud-init结合,利用OS::Heat::CloudConfig直接管理云配置。
摘要由CSDN通过智能技术生成

cloud-init

在虚拟机启动后执行编排任务, nova boot时指定 user-data 参数

Nova USER DATA

数据获取方式:
- 169.254.169.254
- config drive(In Heat set config_drive: true)

常见使用方式如下:

#nova boot \
    --image ubuntu-trusty-server-amd64
    --key_name testkey \
    --flavor m1.small \
    --user-data userdata.txt \
    --nic net-id=443434-dsx3-2323-dssx-43343434 \
    test

And, userdata.txt

#!/bin/sh -e
#Frobincate a newly booted box
initialize_box
for foo in forbnications; do
    frobincate_machine $foo || break
done

exit $?

But, stop doing this, and use cloud-config below which is better

cloud-config

Enables you to bootstrap a newly bootd VM. OpenStack’s most underrated feature, 100% YAML.

常用功能如下:

更新软件(apt-get update/yum update)

Update system on first boot

#cloud-config
package_update: true
package_upgrade: true
users

Configure users and groups

users:
- default
- name: foobar
  gecos: ""
  groups: users,adm
  lock-passwd: false
  passwd: 23lkjsflkas0923Da
  shell: /bin/bash
  sudo: "ALL=(ALL) NOPASSWD:ALL"
ssh_pwauth

Enable/disable SSH password authentication

ssh_pwauth: true
write_files

Write arbitrary files

write_files:
- path: /etc/demo
  permissions: '0644'
  content: |
    This 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值