summaryrefslogtreecommitdiff
path: root/cloudinit
AgeCommit message (Collapse)Author
2020-03-30net/cmdline: replace type comments with annotations (#294)Daniel Watkins
2020-03-27net: introduce is_ip_address function (#288)Daniel Watkins
This will be required for the mirror URL sanitisation work,
2020-03-27CiTestCase: remove now-unneeded parse_and_read helper method (#286)Daniel Watkins
(And sort some imports where I was changing them.)
2020-03-27sources/tests/test_init: drop use of deprecated inspect.getargspec (#285)Daniel Watkins
2020-03-26Identify SAP Converged Cloud as OpenStackSilvio Knizek
add SAP Converged Cloud as cloud provider
2020-03-26add Openbsd support (#147)Gonéri Le Bouder
- tested on OpenBSD 6.6 - tested on OpenStack without config drive, and NoCloud with ISO config drive
2020-03-26VMWware: support to update guest info gc status if enabled (#261)xiaofengw-vmware
2020-03-25set_passwords: avoid chpasswd on BSD (#268)Gonéri Le Bouder
Avoid chpasswd on all the BSD variants.
2020-03-25util: read_cc_from_cmdline handle urlencoded yaml content (#275)Ryan Harper
Add support for additional escaping of formatting characters in the YAML content between the 'cc:' and 'end_cc' tokens. On s390x legacy terminals the use of square brackets [] are not available limiting the ability to indicate lists of values in yaml content. Using #5B and #5D, [ and ] respectively enables s390x users to pass list yaml content into cloud-init via command line interface.
2020-03-25distros/tests/test_init: add tests for _get_package_mirror_info (#272)Daniel Watkins
2020-03-24freebsd: ensure package update works (#273)Gonéri Le Bouder
Currently, `cc_package_update_upgrade_install.py` fails because `package_command()` does not know how to do an update on FreeBSD. ``` 2020-03-23 20:01:53,995 - util.py[DEBUG]: Package update failed Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/cloud_init-20.1-py3.7.egg/cloudinit/config/cc_package_update_upgrade_install.py", line 85, in handle cloud.distro.update_package_sources() File "/usr/local/lib/python3.7/site-packages/cloud_init-20.1-py3.7.egg/cloudinit/distros/freebsd.py", line 158, in update_package_sources ["update"], freq=PER_INSTANCE) File "/usr/local/lib/python3.7/site-packages/cloud_init-20.1-py3.7.egg/cloudinit/helpers.py", line 185, in run results = functor(*args) File "/usr/local/lib/python3.7/site-packages/cloud_init-20.1-py3.7.egg/cloudinit/distros/bsd.py", line 102, in package_command cmd.extend(pkglist) UnboundLocalError: local variable 'cmd' referenced before assignment ``` This commit defines a new `pkg_cmd_update_prefix` key. If it's empty, we don't do any update, otherwise we use the value to update the package manager.
2020-03-23cc_disk_setup: fix RuntimeError (#270)Daniel Watkins
Addresses "Runtime Error: dictionary keys changed during iteration". Co-authored-by: Noah Meyerhans <noahm@debian.org> LP: #1868327
2020-03-23cc_apt_configure/util: combine search_for_mirror implementations (#271)Daniel Watkins
These two implementations had drifted away from one another very slightly. Reconcile them and then remove the one in cc_apt_configure.
2020-03-23bsd: boottime does not depend on the libc soname (#269)Gonéri Le Bouder
On NetBSD and OpenBSD, the libc soname and location are different. There is no reason to be to specific. Python is able to propely open the share library by itself.
2020-03-20test_oracle,DataSourceOracle: sort imports (#266)Daniel Watkins
* test_oracle: sort imports * DataSourceOracle: sort imports
2020-03-19DataSourceOracle: update .network_config docstring (#257)Daniel Watkins
Bring it into line with the current state of the code (by dropping the now-untrue caveat).
2020-03-19cloudinit/tests: remove unneeded with_logs configuration (#263)Daniel Watkins
These classes don't use `self.logs` anywhere in their body, so we can remove the `with_logs = True` setting from them. These instances were found using astpath[0], with the following invocation: astpath "//Name[@id='with_logs' and not(ancestor::ClassDef//Attribute[@attr='logs'])]" [0] https://github.com/hchasestevens/astpath
2020-03-18ec2: render network on all NICs and add secondary IPs as static (#114)Chad Smith
Add support for rendering secondary static IPv4/IPv6 addresses on any NIC attached to the machine. In order to see secondary IP addresses in Ec2 IMDS network config, cloud-init now reads metadata version 2018-09-24. Metadata services which do not support the Ec2 API version will not get secondary IP addresses configured. In order to discover secondary IP address config, cloud-init now relies on metadata API Parse local-ipv4s, ipv6s, subnet-ipv4-cidr-block and subnet-ipv6-cidr-block metadata keys to determine additional IPs and appropriate subnet prefix to set for a nic. Also add the datasource config option apply_full_imds_netork_config which defaults to true to allow cloud-init to automatically configure secondary IP addresses. Setting this option to false will tell cloud-init to avoid setting up secondary IP addresses. Also in this branch: - Shift Ec2 datasource to emit network config v2 instead of v1. LP: #1866930
2020-03-14util/netbsd: drop six usage (#252)Daniel Watkins
Drop remaining python six usage
2020-03-13cc_resolv_conf: introduce tests and stabilise output across Python versions ↵Daniel Watkins
(#251) This is a follow-up to #144 which fixed the rendering behaviour. While writing the tests, CI failed due to dict iteration differences across Python versions, so this also sorts output so that we will produce the same output across Python versions.
2020-03-12Add Netbsd support (#62)Gonéri Le Bouder
Add support for the NetBSD Operating System. Features in this branch: * Add BSD distro parent class from which NetBSD and FreeBSD can specialize * Add *bsd util functions to cloudinit.net and cloudinit.net.bsd_utils * subclass cloudinit.distro.freebsd.Distro from bsd.Distro * Add new cloudinit.distro.netbsd and cloudinit.net.renderer for netbsd * Add lru_cached util.is_NetBSD functions * Add NetBSD detection for ConfigDrive and NoCloud datasources This branch has been tested with: - NoCloud and OpenStack (with and without config-drive) - NetBSD 8.1. and 9.0 - FreeBSD 11.2 and 12.1 - Python 3.7 only, because of the dependency oncrypt.METHOD_BLOWFISH. This version is available in NetBSD 7, 8 and 9 anyway
2020-03-11Add pub_key_ed25519 to cc_phone_home (#237)Daniel Hensby
2020-03-10instance-data: add cloud-init merged_cfg and sys_info keys to json (#214)Chad Smith
Cloud-config userdata provided as jinja templates are now distro, platform and merged cloud config aware. The cloud-init query command will also surface this config data. Now users can selectively render portions of cloud-config based on: * distro name, version, release * python version * merged cloud config values * machine platform * kernel To support template handling of this config, add new top-level keys to /run/cloud-init/instance-data.json. The new 'merged_cfg' key represents merged cloud config from /etc/cloud/cloud.cfg and /etc/cloud/cloud.cfg.d/*. The new 'sys_info' key which captures distro and platform info from cloudinit.util.system_info. Cloud config userdata templates can render conditional content based on these additional environmental checks such as the following simple example: ``` ## template: jinja #cloud-config runcmd: {% if distro == 'opensuse' %} - sh /custom-setup-sles {% elif distro == 'centos' %} - sh /custom-setup-centos {% elif distro == 'debian' %} - sh /custom-setup-debian {% endif %} ``` To see all values: sudo cloud-init query --all Any keys added to the standardized v1 keys are guaranteed to not change or drop on future released of cloud-init. 'v1' keys will be retained for backward-compatibility even if a new standardized 'v2' set of keys are introduced The following standardized v1 keys are added: * distro, distro_release, distro_version, kernel_version, machine, python_version, system_platform, variant LP: #1865969
2020-03-05ec2: Do not fallback to IMDSv1 on EC2 (#216)Chad Smith
The EC2 Data Source needs to handle 3 states of the Instance Metadata Service configured for a given instance: 1. HttpTokens : optional & HttpEndpoint : enabled Either IMDSv2 or IMDSv1 can be used. 2. HttpTokens : required & HttpEndpoint : enabled Calls to IMDS without a valid token (IMDSv1 or IMDSv2 with expired token) will return a 401 error. 3. HttpEndpoint : disabled The IMDS http endpoint will return a 403 error. Previous work to support IMDSv2 in cloud-init handled case 1 and case 2. This commit handles case 3 by bypassing the retry block when IMDS returns HTTP status code >= 400 on official AWS cloud platform. It shaves 2 minutes when rebooting an instance that has its IMDS http token endpoint disabled but creates some inconsistencies. An instance that doesn't set "manual_cache_clean" to "True" will have its /var/lib/cloud/instance symlink removed altogether after it has failed to find a datasource.
2020-03-04instance-data: write redacted cfg to instance-data.json (#233)Chad Smith
When cloud-init persisted instance metadata to instance-data.json if failed to redact the sensitive value. Currently, the only sensitive key 'security-credentials' is omitted as cloud-init does not fetch this value from IMDS. Fix this by properly redacting the content from the public instance-metadata.json file while retaining the value in the root-only instance-data-sensitive.json file. LP: #1865947
2020-03-04net: support network-config:disabled on the kernel commandline (#232)Chad Smith
Allow disabling cloud-init's network configuration via a plain-text kernel cmdline Cloud-init docs indicate that users can disable cloud-init networking via kernel command line parameter 'network-config=<YAML>'. This does not work unless the <YAML> payload base64 encoded. Document the base64 encoding requirement and add a plain-text value for disabling cloud-init network config: network-config=disabled Also: - Log an error and ignore any plain-text network-config payloads that are not specifically 'network-config=disabled'. - Log a warning if network-config kernel param is invalid yaml but do not raise an exception, allowing boot to continue and use fallback networking. LP: #1862702
2020-03-03ec2: only redact token request headers in logs, avoid altering request (#230)Chad Smith
Our header redact logic was redacting both logged request headers and the actual source request. This results in DataSourceEc2 sending the invalid header "X-aws-ec2-metadata-token-ttl-seconds: REDACTED" which gets an HTTP status response of 400. Cloud-init retries this failed token request for 2 minutes before falling back to IMDSv1. LP: #1865882
2020-02-25Add physical network type: cascading to openstack helpers (#200)sab-systems
* Add physical network type: cascading to openstack helpers * add new helpers test for checking all openstack KNOWN_PHYSICAL_TYPES get type 'physical'.
2020-02-20Release 20.1 (#222)20.1Daniel Watkins
Bump the version in cloudinit/version.py to 20.1 and update ChangeLog. LP: #1863954
2020-02-19ec2: Do not log IMDSv2 token values, instead use REDACTED (#219)Ryan Harper
Instead of logging the token values used log the headers and replace the actual values with the string 'REDACTED'. This allows users to examine cloud-init.log and see that the IMDSv2 token header is being used but avoids leaving the value used in the log file itself. LP: #1863943
2020-02-18utils: use SystemRandom when generating random password. (#204)Dimitri John Ledkov
As noticed by Seth Arnold, non-deterministic SystemRandom should be used when creating security sensitive random strings.
2020-02-13docs: mount_default_files is a list of 6 items, not 7 (#212)Chad Smith
2020-02-10unittest: fix stderr leak in cc_set_password random unittest output. (#208)Ryan Harper
2020-02-07cc_disk_setup: add swap filesystem force flag (#207)Ryan Harper
2020-02-03sysconfig: distro-specific config rendering for BOOTPROTO option (#162)Robert Schweikert
- Introduce the "flavor" configuration option for the sysconfig renderer this is necessary to account for differences in the handling of the BOOTPROTO setting between distributions (lp#1858808) + Thanks to Petr Pavlu for the idea - Network config clean up for sysconfig renderer + The introduction of the "flavor" renderer configuration allows us to only write values that are pertinent for the given distro - Set the DHCPv6 client mode on SUSE (lp#1800854) Co-authored-by: Chad Smith <chad.smith@canonical.com> LP: #1800854
2020-01-31cloudinit: replace "from six import X" imports (except in util.py) (#183)Daniel Watkins
2020-01-30net/cmdline: correctly handle static ip= config (#201)Dimitri John Ledkov
It is proto 'none', not 'static' as was mistakenly implemented in initramfs-tools/cloud-init in the past, yet was never the case in the klibc ipconfig state file output. LP: #1861412
2020-01-29Replace mock library with unittest.mock (#186)Daniel Watkins
* cloudinit: replace "import mock" with "from unittest import mock" * test-requirements.txt: drop mock Co-authored-by: Chad Smith <chad.smith@canonical.com>
2020-01-29Scaleway: Fix DatasourceScaleway to avoid backtrace (#128)Louis Bouchard
Make sure network_config is created when self._network_config is unset. Co-authored-by: Scott Moser <smoser@brickies.net>
2020-01-28cloudinit/cmd/devel/net_convert.py: add missing space (#191)Daniel Watkins
2020-01-27Print ssh key fingerprints using sha256 hash (#188)Ryan Harper
LP: #1860789
2020-01-24cc_set_password: increase random pwlength from 9 to 20 (#189)Ryan Harper
Increasing the bits of security from 52 to 115. LP: #1860795
2020-01-23Do not use fallocate in swap file creation on xfs. (#70)Eduardo Otubo
When creating a swap file on an xfs filesystem, fallocate cannot be used. Doing so results in failure of swapon and a message like: swapon: swapfile has holes The solution here is to maintain a list (currently containing only XFS) of filesystems where fallocate cannot be used. The, on those fileystems use the slower but functional 'dd' method. Signed-off-by: Eduardo Otubo <otubo@redhat.com> Co-authored-by: Adam Dobrawy <naczelnik@jawnosc.tk> Co-authored-by: Scott Moser <smoser@brickies.net> Co-authored-by: Daniel Watkins <daniel@daniel-watkins.co.uk> LP: #1781781
2020-01-21Drop most of the remaining use of six (#179)Daniel Watkins
2020-01-21Start removing dependency on six (#178)Daniel Watkins
* url_helper: drop six * url_helper: sort imports * log: drop six * log: sort imports * handlers/__init__: drop six * handlers/__init__: sort imports * user_data: drop six * user_data: sort imports * sources/__init__: drop six * sources/__init__: sort imports * DataSourceOVF: drop six * DataSourceOVF: sort imports * sources/helpers/openstack: drop six * sources/helpers/openstack: sort imports * mergers/m_str: drop six This also allowed simplification of the logic, as we will never encounter a non-string text type. * type_utils: drop six * mergers/m_dict: drop six * mergers/m_list: drop six * cmd/query: drop six * mergers/__init__: drop six * net/cmdline: drop six * reporting/handlers: drop six * reporting/handlers: sort imports
2020-01-16util: rename get_architecture to get_dpkg_architecture (#173)Daniel Watkins
This makes it clearer that we should only use this in code paths that will definitely have dpkg available to them. - Rename get_architecture -> get_dpkg_architecture - Add docstring to get_dpkg_architecture
2020-01-16Ensure util.get_architecture() runs only once (#172)Ryan Harper
* Ensure util.get_architecture() runs only once util.get_architecture() recently was wrapped using python3's lru_cache() which will cache the result so we only invoke 'dpkg --print-architecture' once. In practice, cloud-init.log will show multiple invocations of the command. The source of this was that the debian Distro object implements the get_primary_arch() with this command, but it was not calling it from util, but issuing a util.subp() directly. This branch also updates cc_apt_configure methods to fetch the arch value from the distro class, and then ensure that the methods apt_configure calls pass the arch value around. * utils: remove lsb_release and get_architecture wrappers The original lsb_release wrapper was used to prevent polluting the single value we cached, however lru_cache() already handles this case by using args, kwargs values to cache different calls to the method. * rename_apt_list: use all positional parameters
2020-01-14Only use gpart if it is the BSD gpart (#131)Conrad Hoffmann
Currently, cloud-init will happily try to run `gpart` on Linux even though on most distributions this a different tool [1]. Extend the availability check to make sure the `gpart` present is really the BSD variant, to avoid accidental execution. Also add a pointer to the docs, so that people do not try to install gpart on Linux in the expectation it will work with this module. [1] https://github.com/baruch/gpart
2020-01-14freebsd: remove superflu exception mapping (#166)Gonéri Le Bouder
We often map exception when is not necessary. This commit clean up the FreeBSD distro file.
2020-01-09util: move uptime's else branch into its own boottime function (#53)Igor Galić
Also fix bugs: - pass binary instead of string to sysctlbyname(), and - unpack the "return value" in a struct, rather than in single integer. LP: #1853160 Co-Authored-By: Ryan Harper <ryan.harper@canonical.com>