[virt-tools-list] [virt-manager PATCH] cloudinit: Add disable=yes|no
Athina Plaskasoviti
athina.plaskasoviti at gmail.com
Wed Jul 3 06:06:21 UTC 2019
Cli option to permanently disable cloud-init after first boot by user request.
Handled so that bare --cloud-init defaults to --cloud-init root-password=generate,disable=yes.
Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti at gmail.com>
---
virtinst/cli.py | 4 +++-
virtinst/install/cloudinit.py | 7 +++++--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/virtinst/cli.py b/virtinst/cli.py
index caa12289..c080dfcf 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -1614,14 +1614,16 @@ class ParserCloudInit(VirtCLIParser):
def _init_class(cls, **kwargs):
VirtCLIParser._init_class(**kwargs)
cls.add_arg("root-password", "root_password")
+ cls.add_arg("disable", "disable", is_onoff=True)
def parse_cloud_init(optstr):
ret = CloudInitData()
if optstr == 1:
# This means bare --cloud-init, so there's nothing to parse.
- log.warning("Defaulting to --cloud-init root-password=generate")
+ log.warning("Defaulting to --cloud-init root-password=generate,disable=yes")
ret.root_password = "generate"
+ ret.disable = True
return ret
parser = ParserCloudInit(optstr)
diff --git a/virtinst/install/cloudinit.py b/virtinst/install/cloudinit.py
index 8041cc86..032d65e4 100644
--- a/virtinst/install/cloudinit.py
+++ b/virtinst/install/cloudinit.py
@@ -6,6 +6,7 @@ from ..logger import log
class CloudInitData():
+ disable = None
root_password = None
@@ -40,8 +41,10 @@ def create_userdata(scratchdir, cloudinit_data):
content += " root:%s\n" % rootpass
content += " expire: True\n"
- content += "runcmd:\n"
- content += "- [ sudo, touch, /etc/cloud/cloud-init.disabled ]\n"
+ disable = cloudinit_data.disable
+ if disable is True:
+ content += "runcmd:\n"
+ content += "- [ sudo, touch, /etc/cloud/cloud-init.disabled ]\n"
log.debug("Generated cloud-init userdata:\n%s", content)
--
2.20.1
More information about the virt-tools-list
mailing list