diff options
author | Daniil Baturin <daniil@baturin.org> | 2019-07-12 15:31:10 +0200 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2019-07-12 15:31:10 +0200 |
commit | 5c4e5e9a6a893aa2fb0df50cf327e942b52995b9 (patch) | |
tree | dab6065c413d336cd2b4f5be28996ad75ab150c3 | |
parent | 65b2f36a77f311a207b8e5406d222f4dbef177cf (diff) | |
download | vyos-1x-5c4e5e9a6a893aa2fb0df50cf327e942b52995b9.tar.gz vyos-1x-5c4e5e9a6a893aa2fb0df50cf327e942b52995b9.zip |
Do not try to verify the hostname config if the script is run by cloud-init.
-rwxr-xr-x | src/conf_mode/host_name.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/conf_mode/host_name.py b/src/conf_mode/host_name.py index eb4b339e9..1988f7b4f 100755 --- a/src/conf_mode/host_name.py +++ b/src/conf_mode/host_name.py @@ -117,6 +117,10 @@ def get_config(arguments): if conf.exists("system host-name"): hosts['hostname'] = conf.return_value("system host-name") + # This may happen if the config is not loaded yet, + # e.g. if run by cloud-init + if not hosts['hostname']: + hosts['hostname'] = default_config_data['hostname'] if conf.exists("system domain-name"): hosts['domain_name'] = conf.return_value("system domain-name") @@ -290,7 +294,12 @@ if __name__ == '__main__': try: c = get_config(args) - verify(c) + # If it's called from dhclient, then either: + # a) verification was already done at commit time + # b) it's run on an unconfigured system, e.g. by cloud-init + # Therefore, verification is either redundant or useless + if not args.dhclient: + verify(c) generate(c) apply(c) except ConfigError as e: |