diff --git a/nodepool/driver/aws/config.py b/nodepool/driver/aws/config.py index 951bd1bc6..c927d7e9c 100644 --- a/nodepool/driver/aws/config.py +++ b/nodepool/driver/aws/config.py @@ -230,6 +230,7 @@ class AwsProviderConfig(ProviderConfig): pool.update({ v.Required('name'): str, v.Required('labels'): [pool_label], + 'host-key-checking': bool, 'security-group-id': str, 'subnet-id': str, }) diff --git a/nodepool/driver/aws/handler.py b/nodepool/driver/aws/handler.py index 5867a283a..1d01043ee 100644 --- a/nodepool/driver/aws/handler.py +++ b/nodepool/driver/aws/handler.py @@ -80,6 +80,7 @@ class AwsInstanceLauncher(NodeLauncher): self.node.connection_port = self.label.cloud_image.connection_port self.node.connection_type = self.label.cloud_image.connection_type + keys = [] if self.pool.host_key_checking: try: if (self.node.connection_type == 'ssh' or diff --git a/nodepool/tests/fixtures/aws.yaml b/nodepool/tests/fixtures/aws.yaml index 8011c0300..e8a614996 100644 --- a/nodepool/tests/fixtures/aws.yaml +++ b/nodepool/tests/fixtures/aws.yaml @@ -9,6 +9,7 @@ labels: - name: ubuntu1404-by-filters - name: ubuntu1404-by-capitalized-filters - name: ubuntu1404-bad-config + - name: ubuntu1404-non-host-key-checking providers: - name: ec2-us-west-2 @@ -66,3 +67,13 @@ providers: cloud-image: ubuntu1404-bad-config instance-type: t3.medium key-name: zuul + - name: non-host-key-checking + max-servers: 1 + subnet-id: null + security-group-id: null + host-key-checking: false + labels: + - name: ubuntu1404-non-host-key-checking + cloud-image: ubuntu1404 + instance-type: t3.medium + key-name: zuul diff --git a/nodepool/tests/unit/test_driver_aws.py b/nodepool/tests/unit/test_driver_aws.py index cbf9ecce5..fcaf87daf 100644 --- a/nodepool/tests/unit/test_driver_aws.py +++ b/nodepool/tests/unit/test_driver_aws.py @@ -63,8 +63,12 @@ class TestDriverAws(tests.DBTestCase): } raw_config['providers'][0]['pools'][0]['subnet-id'] = subnet_id raw_config['providers'][0]['pools'][0]['security-group-id'] = sg_id + raw_config['providers'][0]['pools'][1]['subnet-id'] = subnet_id + raw_config['providers'][0]['pools'][1]['security-group-id'] = sg_id - def _test_run_node(label, is_valid_config=True): + def _test_run_node(label, + is_valid_config=True, + host_key_checking=True): with tempfile.NamedTemporaryFile() as tf: tf.write(yaml.safe_dump( raw_config, default_flow_style=False).encode('utf-8')) @@ -95,11 +99,12 @@ class TestDriverAws(tests.DBTestCase): self.assertEqual(node.state, zk.READY) self.assertIsNotNone(node.launcher) self.assertEqual(node.connection_type, 'ssh') - nodescan.assert_called_with( - node.interface_ip, - port=22, - timeout=180, - gather_hostkeys=True) + if host_key_checking: + nodescan.assert_called_with( + node.interface_ip, + port=22, + timeout=180, + gather_hostkeys=True) # A new request will be paused and for lack of quota # until this one is deleted @@ -136,8 +141,11 @@ class TestDriverAws(tests.DBTestCase): {"label": "ubuntu1404-by-capitalized-filters"}, {"label": "ubuntu1404-bad-ami-name", "is_valid_config": False}, {"label": "ubuntu1404-bad-config", "is_valid_config": False}, + {"label": "ubuntu1404-non-host-key-checking", + "host_key_checking": False}, ] for cloud_image in cloud_images: _test_run_node(cloud_image["label"], - cloud_image.get("is_valid_config")) + cloud_image.get("is_valid_config"), + cloud_image.get("host_key_checking"))