如何阻止 cloud-init 在 AWS (CentOS) 上覆盖我的主机名 [英] How do I stop cloud-init from overwriting my hostname on AWS (CentOS)

查看:45
本文介绍了如何阻止 cloud-init 在 AWS (CentOS) 上覆盖我的主机名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在启动时运行的脚本(通过 rc.local)并根据它从 AWS CLI 查询的实例名称设置我的主机名.它可以工作,并且在引导日志的末尾显示登录:"

I have a script that runs at boot (via rc.local) and sets my hostname based on the instance name it queries from the AWS CLI. It works, and at the end of the boot log it says " login:"

我发现 cloud-init 覆盖了我的主机名,所以我:

At figured that cloud-init was overwriting my hostname, so I:

  • 在/etc/cloud/cloud.cfg中设置preserve_hostname: true
  • 注释掉/etc/cloud/cloud.cfg.d/00_defaults.cfg 的 cloud_config_modules 部分中的 set-hostname 和 update-hostname

但在 cloud-init 日志中,我仍然看到运行模块更新主机名"和迁移信号量 update_hostname.always 到 config-update-hostname 频率总是",并且在启动后一两分钟主机名返回到AWS 默认值.

But in the cloud-init logs I still see "Running module update-hostname" and " Migrated semaphore update_hostname.always to config-update-hostname with frequency always", and a minute or two after boot the hostname returns to the AWS default.

这是怎么回事?我如何阻止它?

What is going on? How do I stop it?

推荐答案

我真正讨厌的 hack-around 是创建一个每分钟设置一次主机名的 cron 作业.改进的建议表示赞赏.

My really nasty hack-around is to create a cron job that sets the hostname every minute. Improved suggestions appreciated.

这篇关于如何阻止 cloud-init 在 AWS (CentOS) 上覆盖我的主机名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆