diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index b0b66661d..476457db6 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -311,9 +311,13 @@ Options .. attr:: python-path :type: string - :default: /usr/bin/python2 + :default: auto - The path of the default python interpreter. + The path of the default python interpreter. Used by Zuul to set + ``ansible_python_interpreter``. The special value ``auto`` will + direct Zuul to use inbuilt Ansible logic to select the + interpreter on Ansible >=2.8, and default to + ``/usr/bin/python2`` for earlier versions. .. attr:: dib-cmd :type: string @@ -720,9 +724,13 @@ Selecting the OpenStack driver adds the following options to the .. attr:: python-path :type: str - :default: /usr/bin/python2 + :default: auto - The path of the default python interpreter. + The path of the default python interpreter. Used by Zuul to set + ``ansible_python_interpreter``. The special value ``auto`` will + direct Zuul to use inbuilt Ansible logic to select the + interpreter on Ansible >=2.8, and default to + ``/usr/bin/python2`` for earlier versions. .. attr:: connection-type :type: str @@ -1144,7 +1152,11 @@ Selecting the static driver adds the following options to the :type: str :default: /usr/bin/python2 - The path of the default python interpreter. + The path of the default python interpreter. Used by Zuul to set + ``ansible_python_interpreter``. The special value ``auto`` will + direct Zuul to use inbuilt Ansible logic to select the + interpreter on Ansible >=2.8, and default to + ``/usr/bin/python2`` for earlier versions. .. attr:: max-parallel-jobs :type: int @@ -1267,9 +1279,14 @@ Selecting the kubernetes driver adds the following options to the .. attr:: python-path :type: str - :default: /usr/bin/python2 + :default: auto + + The path of the default python interpreter. Used by Zuul to set + ``ansible_python_interpreter``. The special value ``auto`` will + direct Zuul to use inbuilt Ansible logic to select the + interpreter on Ansible >=2.8, and default to + ``/usr/bin/python2`` for earlier versions. - The path of the default python interpreter. Openshift Driver @@ -1394,9 +1411,13 @@ Selecting the openshift driver adds the following options to the .. attr:: python-path :type: str - :default: /usr/bin/python2 + :default: auto - The path of the default python interpreter. + The path of the default python interpreter. Used by Zuul to set + ``ansible_python_interpreter``. The special value ``auto`` will + direct Zuul to use inbuilt Ansible logic to select the + interpreter on Ansible >=2.8, and default to + ``/usr/bin/python2`` for earlier versions. .. attr:: cpu :type: int @@ -1639,9 +1660,13 @@ section of the configuration. .. attr:: python-path :type: str - :default: /usr/bin/python2 + :default: auto - The path of the default python interpreter. + The path of the default python interpreter. Used by Zuul to set + ``ansible_python_interpreter``. The special value ``auto`` will + direct Zuul to use inbuilt Ansible logic to select the + interpreter on Ansible >=2.8, and default to + ``/usr/bin/python2`` for earlier versions. .. attr:: connection-type :type: str diff --git a/nodepool/config.py b/nodepool/config.py index bb8b94075..0f1eeffef 100755 --- a/nodepool/config.py +++ b/nodepool/config.py @@ -119,7 +119,7 @@ class Config(ConfigValue): d.image_types = set(diskimage.get('formats', [])) d.pause = bool(diskimage.get('pause', False)) d.username = diskimage.get('username', 'zuul') - d.python_path = diskimage.get('python-path', '/usr/bin/python2') + d.python_path = diskimage.get('python-path', 'auto') d.build_timeout = diskimage.get('build-timeout', (8 * 60 * 60)) self.diskimages[d.name] = d diff --git a/nodepool/driver/aws/config.py b/nodepool/driver/aws/config.py index 345e92b2a..a359e17a9 100644 --- a/nodepool/driver/aws/config.py +++ b/nodepool/driver/aws/config.py @@ -192,7 +192,7 @@ class AwsProviderConfig(ProviderConfig): i.name = image['name'] i.image_id = image.get('image-id', None) i.username = image.get('username', None) - i.python_path = image.get('python-path', '/usr/bin/python2') + i.python_path = image.get('python-path', 'auto') i.connection_type = image.get('connection-type', 'ssh') i.connection_port = image.get( 'connection-port', diff --git a/nodepool/driver/kubernetes/config.py b/nodepool/driver/kubernetes/config.py index b258cc4be..f45021c85 100644 --- a/nodepool/driver/kubernetes/config.py +++ b/nodepool/driver/kubernetes/config.py @@ -56,7 +56,7 @@ class KubernetesPool(ConfigPool): pl.type = label['type'] pl.image = label.get('image') pl.image_pull = label.get('image-pull', 'IfNotPresent') - pl.python_path = label.get('python-path', '/usr/bin/python2') + pl.python_path = label.get('python-path', 'auto') pl.pool = self self.labels[pl.name] = pl full_config.labels[label['name']].pools.append(self) diff --git a/nodepool/driver/openshift/config.py b/nodepool/driver/openshift/config.py index 04a7186b7..5e455a8fc 100644 --- a/nodepool/driver/openshift/config.py +++ b/nodepool/driver/openshift/config.py @@ -61,7 +61,7 @@ class OpenshiftPool(ConfigPool): pl.image_pull = label.get('image-pull', 'IfNotPresent') pl.cpu = label.get('cpu') pl.memory = label.get('memory') - pl.python_path = label.get('python-path', '/usr/bin/python2') + pl.python_path = label.get('python-path', 'auto') pl.pool = self self.labels[pl.name] = pl full_config.labels[label['name']].pools.append(self) diff --git a/nodepool/driver/openstack/config.py b/nodepool/driver/openstack/config.py index 18ccbfe77..11ac6f379 100644 --- a/nodepool/driver/openstack/config.py +++ b/nodepool/driver/openstack/config.py @@ -332,7 +332,7 @@ class OpenStackProviderConfig(ProviderConfig): i.image_id = image.get('image-id', None) i.image_name = image.get('image-name', None) i.username = image.get('username', None) - i.python_path = image.get('python-path', '/usr/bin/python2') + i.python_path = image.get('python-path', 'auto') i.connection_type = image.get('connection-type', 'ssh') i.connection_port = image.get( 'connection-port', diff --git a/nodepool/driver/static/config.py b/nodepool/driver/static/config.py index 60904f57a..aa0e3d272 100644 --- a/nodepool/driver/static/config.py +++ b/nodepool/driver/static/config.py @@ -59,7 +59,7 @@ class StaticPool(ConfigPool): 'connection-type': node.get('connection-type', 'ssh'), 'username': node.get('username', 'zuul'), 'max-parallel-jobs': int(node.get('max-parallel-jobs', 1)), - 'python-path': node.get('python-path', '/usr/bin/python2'), + 'python-path': node.get('python-path', 'auto'), }) if isinstance(node['labels'], str): for label in node['labels'].split(): diff --git a/nodepool/tests/unit/test_launcher.py b/nodepool/tests/unit/test_launcher.py index 40a30fe34..8809a31c9 100644 --- a/nodepool/tests/unit/test_launcher.py +++ b/nodepool/tests/unit/test_launcher.py @@ -147,7 +147,7 @@ class TestLauncher(tests.DBTestCase): self.assertEqual(nodes[1].type, ['fake-label1']) self.assertEqual(nodes[2].type, ['fake-label4']) self.assertEqual(nodes[3].type, ['fake-label2']) - self.assertEqual(nodes[0].python_path, '/usr/bin/python2') + self.assertEqual(nodes[0].python_path, 'auto') def _test_node_assignment_at_quota(self, config, @@ -1370,7 +1370,7 @@ class TestLauncher(tests.DBTestCase): self.assertEqual('winrm', nodes[0].connection_type) self.assertEqual(5986, nodes[0].connection_port) self.assertEqual(nodes[0].host_keys, []) - self.assertEqual(nodes[0].python_path, '/usr/bin/python2') + self.assertEqual(nodes[0].python_path, 'auto') nodes = self.waitForNodes('fake-label-arbitrary-port') self.assertEqual(len(nodes), 1) diff --git a/releasenotes/notes/python-path-auto-83881e94d835ff83.yaml b/releasenotes/notes/python-path-auto-83881e94d835ff83.yaml new file mode 100644 index 000000000..0dcac0f8f --- /dev/null +++ b/releasenotes/notes/python-path-auto-83881e94d835ff83.yaml @@ -0,0 +1,23 @@ +--- +features: + - | + The default ``python-path`` is now ``auto`` (instead of + ``/usr/bin/python2``). With this, Zuul 3.11.1 and greater will set the + ``ansible_python_interpreter`` to ``auto`` when using Ansible + >=2.8 to use `automated interpreter discovery + `__. + When using earlier Ansible, it will remain the old default of + ``/usr/bin/python2``. + + This will remove the need to override python-path explicitly for + Python 3-only distributions, which should be detected correctly + automatically. + +upgrade: + - | + This release should only be run against Zuul 3.11.1 or greater. + Earlier Zuul releases will not convert the new default + ``python-path`` of ``auto`` to ``/usr/bin/python2`` for Ansible + <2.8, leading to a configuration error. It may be possible to use + earlier Zuul releases if you you are only using Ansible >= 2.8, or + explicitly set ``python-path`` for every image.