summaryrefslogtreecommitdiff
path: root/cloudinit
AgeCommit message (Collapse)Author
2021-11-01Add LXD datasource (#1040)Chad Smith
Add DataSourceLXD which knows how to talk to the dev-lxd socket to obtain all instance metadata API: https://linuxcontainers.org/lxd/docs/master/dev-lxd. This first branch is to deliver feature parity with the existing NoCloud datasource which is currently used to intialize LXC instances on first boot. Introduce a SocketConnectionPool and LXDSocketAdapter to support performing HTTP GETs on the following routes which are surfaced by the LXD host to all containers: http://unix.socket/1.0/meta-data http://unix.socket/1.0/config/user.user-data http://unix.socket/1.0/config/user.network-config http://unix.socket/1.0/config/user.vendor-data These 4 routes minimally replace the static content provided in the following nocloud-net seed files: /var/lib/cloud/nocloud-net/{meta-data,vendor-data,user-data,network-config} The intent of this commit is to set a foundation for LXD socket communication that will allow us to build network hot-plug features by eventually consuming LXD's websocket upgrade route 1.0/events to react to network, meta-data and user-data config changes over time. In the event that no custom network-config is provided, default to the same network-config definition provided by LXD to the NoCloud network-config seed file. Supplemental features above NoCloud datasource: surface all custom instance data config keys via cloud-init query ds which aids in discoverability of features/tags/labels as well as conditional #cloud-config jinja templates operations based on custom config options. TBD: better cloud-init query support for dot-delimited keys
2021-11-01Fix unhandled apt_configure case. (#1065)Brett Holman
Don't throw an exception when mirror arch is unspecified.
2021-10-29Allow libexec for hotplug (#1088)James Falcon
When we added the install hotplug module, we forgot to update the redhet/cloud-init.spec.in file and allow for execution on /usr/libexec. This PR adds that functionality.
2021-10-29Remove (deprecated) apt-key (#1068)Brett Holman
Also, add the "signed by" option to source definitions. This enables users to limit the scope of trust for individual keys. LP: #1836336
2021-10-28distros: Remove a completed "TODO" comment (#1086)Daniel Watkins
This was fixed in 1bbc4908ff7a2be19483811b3b6fee6ebc916235
2021-10-27cc_ssh.py: Add configuration for controlling ssh-keygen output (#1083)dermotbradley
When ssh host keys are generated during initial boot the full output of ssh-keygen, including the randomart for the key, is displayed on the console for each of the generated key types, which takes up a large amount of screen output (17 lines per key type). With this change ssh-keygen output is still displayed by default. Setting ssh_quiet_keygen to True will prevent ssh-keygen output from appearing. If only the fingerprints of the host keys should be displayed then this can be achieved using the existing emit_keys_to_console and/or ssh_fp_console_blacklist settings.
2021-10-27Add "install hotplug" module (SC-476) (#1069)James Falcon
This commit removes automatically installing udev rules for hotplug and adds a module to install them instead. Automatically including the udev rules and checking if hotplug was enabled consumed too many resources in certain circumstances. Moving the rules to a module ensures we don't spend extra extra cycles on hotplug if hotplug functionality isn't desired. LP: #1946003
2021-10-26cloudinit/dmi.py: Change warning to debug to prevent console display (#1082)dermotbradley
Change DMI warning to a debug message to prevent it appearing on console during boot of machines, such as Raspberry Pi, that do not support DMI.
2021-10-25Add module 'write-files-deferred' executed in stage 'final' (#916)Lucendio
The main idea is to introduce a second module that takes care of writing files, but in the 'final' stage. While the introduction of a second module would allow for choosing the appropriate place withing the order of modules (and stages), there is no addition top-level directive being added to the cloud configuration schema. Instead, 'write-files' schema is being extended to include a 'defer' attribute used only by the 'write-deffered-files' modules. The new module 'write-deferred-files' reuses as much as possible of the 'write-files' functionality.
2021-10-22Add "Google" as possible system-product-name (#1077)vteratipally
In some of the cases, the system-product-name is just google. This is useful incase of nocloud where we use the disk to load the datasource
2021-10-20Leave the details of service management to the distro (#1074)Andy Fiddaman
Various modules restart services and they all have logic to try and detect if they are running on a system that needs 'systemctl' or 'service', and then have code to decide which order the arguments need to be etc. On top of that, not all modules do this in the same way. The duplication and different approaches are not ideal but this also makes it hard to add support for a new distribution that does not use either 'systemctl' or 'service'. This change adds a new manage_service() method to the distro class and updates several modules to use it.
2021-10-19Update Azure _unpickle (SC-500) (#1067)James Falcon
When self.failed_desired_api_version was added to DataSourceAzure, the attribute was never added to the _unpickle method using the upgrade framework. This commit adds the attribute. LP: #1946644
2021-10-19cc_ssh.py: fix private key group owner and permissions (#1070)Emanuele Giuseppe Esposito
When default host keys are created by sshd-keygen (/etc/ssh/ssh_host_*_key) in RHEL/CentOS/Fedora, openssh it performs the following: # create new keys if ! $KEYGEN -q -t $KEYTYPE -f $KEY -C '' -N '' >&/dev/null; then exit 1 fi # sanitize permissions /usr/bin/chgrp ssh_keys $KEY /usr/bin/chmod 640 $KEY /usr/bin/chmod 644 $KEY.pub Note that the group ssh_keys exists only in RHEL/CentOS/Fedora. Now that we disable sshd-keygen to allow only cloud-init to create them, we miss the "sanitize permissions" part, where we set the group owner as ssh_keys and the private key mode to 640. According to https://bugzilla.redhat.com/show_bug.cgi?id=2013644#c8, failing to set group ownership and permissions like openssh does makes the RHEL openscap tool generate an error. Signed-off-by: Emanuele Giuseppe Esposito eesposit@redhat.com RHBZ: 2013644
2021-10-18VMware: read network-config from ISO (#1066)Thomas Weißschuh
There is no reason for the ISO missing this functionality. As discussed in https://github.com/canonical/cloud-init/pull/947/files#r707338489
2021-10-18CloudStack: fix data-server DNS resolution (#1004)Olivier Lemasle
CloudStack DNS resolution should be done against the DNS search domain (with the final dot, DNS resolution does not work with e.g. Fedora 34) LP: #1942232
2021-10-15testing: add get_cloud function (SC-461) (#1038)James Falcon
Also added supporting distro/datasource classes and updated tests that have a `get_cloud` call.
2021-10-11VMWARE: search the deployPkg plugin in multiarch dir (#1061)xiaofengw-vmware
Due to multiarch, the libdeployPkgPlugin.so is deployed into dir /usr/lib/<multiarch name>/open-vm-tools, we need to add this path into search_paths. LP: #1944946
2021-10-08Fix set-name/interface DNS bug (#1058)Andrew Kutz
This patch addresses an issue caused when the v2 network config directive "set-name" was used in conjunction with interface- specific DNS settings. The patch adds a test to validate the fix. For more information please see bug 1946493 as well as the issue https://github.com/kubernetes-sigs/image-builder/issues/712. LP: #1946493
2021-10-08Use specified tmp location for growpart (#1046)jshen28
Growpart uses mktemp internally to save some date. This could lead to conflicts with tmpfile clean service during boot. This patch explicitly make it uses a tmp file under /var/tmp Signed-off-by: ushen <yshxxsjt715@gmail.com>
2021-10-07Allow comments in runcmd and report failed commands correctly (#1049)Brett Holman
Allow comments in runcmd and report failed commands correctly A `runcmd` script may fail to parse properly, but does not mark `runcmd` as failed when that occurs. Additionally `shellify()` fails to correctly parse scripts that contain a comment line. Rectify both issues and add unit tests to verify correct behavior. LP: #1853146
2021-10-07Allow disabling of network activation (SC-307) (#1048)James Falcon
In #919 (81299de), we refactored some of the code used to bring up networks across distros. Previously, the call to bring up network interfaces during 'init' stage unintentionally resulted in a no-op such that network interfaces were NEVER brought up by cloud-init, even if new network interfaces were found after crawling the metadata. The code was altered to bring up these discovered network interfaces. On ubuntu, this results in a 'netplan apply' call during 'init' stage for any ubuntu-based distro on a datasource that has a NETWORK dependency. On GCE, this additional 'netplan apply' conflicts with the google-guest-agent service, resulting in an instance that can no be connected to. This commit adds a 'disable_network_activation' option that can be enabled in /etc/cloud.cfg to disable the activation of network interfaces in 'init' stage. LP: #1938299
2021-10-07renderer: convert relative imports to absolute (#1052)Paride Legovini
Fixes the following pylint error: cloudinit/net/renderer.py:12: [E0611(no-name-in-module), ] No name 'generate_udev_rule' in module 'udev' Likely a false positive, but we don't really need to keep the imports relative, so let's convert them to absolute as a workaround.
2021-10-07Support ETHx_IP6_GATEWAY, SET_HOSTNAME on OpenNebula (#1045)Vlastimil Holer
OpenNebula 6.1.80 (current dev. version) is introducing new IPv6 gateway contextualization variable ETHx_IP6_GATEWAY, which mimics existing variable ETHx_GATEWAY6. The ETHx_GATEWAY6 used until now will be depracated in future relase (ET spring 2022). See: - new variable - https://github.com/OpenNebula/one/commit/e4d2cc11b9f3c6d01b53774b831f48d9d089c1cc - deprecation tracking issue - https://github.com/OpenNebula/one/issues/5536 Also, added support for SET_HOSTNAME context variable, which is currently widely used variable to configure guest VM hostname. See https://docs.opennebula.io/6.0/management_and_operations/references/template.html#context-section
2021-10-04Allow Vultr to set MTU and use as-is configs (#1037)eb3095
Add MTU, accept-ra, routes, options and a direct way to provide intact cloud configs for networking opposed to relying on configurations that may need changed often.
2021-09-29Make wording for module frequency consistent (#1039)Nicolas Bock
Some modules' frequency are documented as `always` while others as `per always`. The difference in wording can be confusing. This change updates all such modules to use `always`. Signed-off-by: Nicolas Bock <nicolas.bock@canonical.com>
2021-09-29Use ascii code for growpart (#1036)jshen28
growpart not working well for environment using UTF-8 encoding. This patch forces growpart command to use C locale. Root issue likely: https://bugs.launchpad.net/ubuntu/+source/cloud-utils/+bug/1928167
2021-09-24Cleanup Vultr support (#987)eb3095
Offload Vultr's vendordata assembly to the backend, correct vendordata storage and parsing, allow passing critical data via the useragent, better networking configuration for additional interfaces.
2021-09-22docs: update cc_disk_setup for fs to raw disk (#1017)James Falcon
2021-09-21tox: bump the pinned flake8 and pylint version (#1029)Paride Legovini
tox: bump the pinned flake8 and pylint version * pylint: fix W1406 (redundant-u-string-prefix) The u prefix for strings is no longer necessary in Python >=3.0. * pylint: disable W1514 (unspecified-encoding) From https://www.python.org/dev/peps/pep-0597/ (Python 3.10): The new warning stems form https://www.python.org/dev/peps/pep-0597, which says: Developers using macOS or Linux may forget that the default encoding is not always UTF-8. [...] Even Python experts may assume that the default encoding is UTF-8. This creates bugs that only happen on Windows. The warning could be fixed by always specifying encoding='utf-8', however we should be careful to not break environments which are not utf-8 (or explicitly state that only utf-8 is supported). Let's silence the warning for now. * _quick_read_instance_id: cover the case where load_yaml() returns None Spotted by pylint: - E1135 (unsupported-membership-test) - E1136 (unsubscriptable-object) LP: #1944414
2021-09-20Add retries to DataSourceGCE.py when connecting to GCE (#1005)vteratipally
Add retries to DatasourceGCE when connecting to GCE. Sometimes when the trying to fetch the metadata, cloud-init fails and the fallback datasource NoCloud is used which is not expected. Add retries to ensure loading of the data source.
2021-09-17Set Azure to apply networking config every BOOT (#1023)James Falcon
In #1006, we set Azure to apply networking config every BOOT_NEW_INSTANCE because the BOOT_LEGACY option was causing problems applying networking the second time per boot. However, BOOT_NEW_INSTANCE is also wrong as Azure needs to apply networking once per boot, during init-local phase.
2021-09-17Add connectivity_url to Oracle's EphemeralDHCPv4 (#988)James Falcon
Add connectivity_url to Oracle's EphemeralDHCPv4 On bionic, when trying to bring up the EphemeralDHCPv4, it's possible that we already have a route defined, which will result in an error when trying to add the DHCP route. Use the connectivity_url to check if we can reach the metadata service, and if so, skip the EphemeralDHCPv4. The has_url_connectivity function has also been modified to take a dict of kwargs to send to readurl. LP: #1939603
2021-09-17docs: fix typo and include sudo for report bugs commands (#1022)Renan Rodrigo
Remove a duplicate "a" in the docs, and change the bug reporting documentation to tell users to run the commands with sudo. LP: #1940236
2021-09-16VMware: Fix typo introduced in #947 and add test (#1019)PengpengSun
2021-09-13Improve ug_util.py (#1013)Shreenidhi Shedi
No functional changes.
2021-09-13Support openEuler OS (#1012)zhuzaifangxuele
openEuler Homepage: https://www.openeuler.org/en/
2021-09-07ssh_utils.py: ignore when sshd_config options are not key/value pairs (#1007)Emanuele Giuseppe Esposito
As specified in #LP 1845552, In cloudinit/ssh_util.py, in parse_ssh_config_lines(), we attempt to parse each line of sshd_config. This function expects each line to be one of the following forms: \# comment key value key=value However, options like DenyGroups and DenyUsers are specified to *optionally* accepts values in sshd_config. Cloud-init should comply to this and skip the option if a value is not provided. Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
2021-09-03Set Azure to only update metadata on BOOT_NEW_INSTANCE (#1006)James Falcon
In #834, we refactored the handling of events for fetching new metadata. Previously, in Azure's __init__, the BOOT event was added to the update_events, so it was assumed that Azure required the standard BOOT behavior, which is to apply metadata twice every boot: once during local-init, then again during standard init phase. https://github.com/canonical/cloud-init/blob/21.2/cloudinit/sources/DataSourceAzure.py#L356 However, this line was effectively meaningless. After the metadata was fetched in local-init, it was then pickled out to disk. Because "update_events" was a class variable, the EventType.BOOT was not persisted into the pickle. When the pickle was then unpickled in the init phase, metadata did not get re-fetched because EventType.BOOT was not present, so Azure is effectely only BOOT_NEW_INSTANCE. Fetching metadata twice during boot causes some issue for pre-provisioning on Azure because updating metadata during re-provisioning will cause cloud-init to poll for reprovisiondata again in DataSourceAzure, which will infinitely return 404(reprovisiondata is deleted from IMDS after health signal was sent by cloud-init during init-local). This makes cloud-init stuck in 'init'
2021-09-02cc_update_etc_hosts: Use the distribution-defined path for the hosts file (#983)Andy Fiddaman
The distribution class has a field that specifies the location of the system hosts file and this can be overridden in subclasses. While the field is correctly used in distro.update_etc_hosts(), the update_etc_hosts module does not use it and just assumes '/etc/hosts' This fixes the module to use the distribution-specific variable.
2021-09-01Add CloudLinux OS support (#1003)Alexandr Kravchenko
https://www.cloudlinux.com/
2021-09-01puppet config: add the start_agent option (#1002)Andrew Bogott
The current code starts the puppet agent and also sets autostart in all cases. This conflicts with a common pattern where puppet itself manages the agent and autostart state. For example, in my deploy puppet disables the puppet agent and replaces it with a cron. This causes various races both within this cloud-init unit and within puppet itself while cloud-init and puppet fight over whether or not to enable the service.
2021-09-01Fix `make style-check` errors (#1000)Shreenidhi Shedi
Using flake8 inplace of pyflakes Renamed run-pyflakes -> run-flake8 Changed target name to flake8 in Makefile With pyflakes we can't suppress warnings/errors in few required places. flake8 is flexible in that regard. Hence using flake8 seems to be a better choice here. flake8 does the job of pep8 anyway. So, removed pep8 target from Makefile along with tools/run-pep8 script. Included setup.py in flake8 checks
2021-08-30Add support to accept-ra in networkd renderer (#999)Shreenidhi Shedi
Also fix search path in networkd
2021-08-24Azure: Retry dhcp on timeouts when polling reprovisiondata (#998)aswinrajamannar
In the nic attach path, we skip doing dhcp since we already did it when bringing the interface up. However when polling for reprovisiondata, it is possible for the request to timeout due to platform issues. In those cases we still need to do dhcp and try again since we tear down the context. We can only skip the first dhcp attempt.
2021-08-23Release 21.3 (#993)James Falcon
Bump the version in cloudinit/version.py to 21.3 and update ChangeLog. LP: #1940839
2021-08-20Azure: During primary nic detection, check interface status continuously ↵aswinrajamannar
before rebinding again (#990) Add 10 second polling loop in wait_for_link_up after performing an unbind and re-bind of primary NIC in hv_netvsc driver. Also reduce cloud-init logging levels to debug for these operations.
2021-08-20Fix home permissions modified by ssh module (SC-338) (#984)James Falcon
Fix home permissions modified by ssh module In #956, we updated the file and directory permissions for keys not in the user's home directory. We also unintentionally modified the permissions within the home directory as well. These should not change, and this commit changes that back. LP: #1940233
2021-08-19Ignore hotplug socket when collecting logs (#985)James Falcon
Update "cloud-init collect-logs" to ignore /run/cloud-init/hook-hotplug-cmd as this will raise the error "/run/cloud-init/hook-hotplug-cmd` is a named pipe" if included. Also updated logs.py to continue writing the tarball if it fails collecting a file rather than let the exception bubble up. LP: #1940235
2021-08-13Only invoke hotplug socket when functionality is enabled (#952)James Falcon
Alters hotplug hook to have a query mechanism checking if the functionality is enabled. This allows us to avoid using the hotplug socket and service when hotplug is disabled.
2021-08-12cc_resolv_conf: fix typos (#969)Shreenidhi Shedi
Add tests for cc_resolv_conf handler