Fix aws_ssm connection plugin. (#66393)

This commit is contained in:
Felix Fontein 2020-01-12 23:59:25 +01:00 committed by GitHub
parent 663f9cda25
commit a79ca57d22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View file

@ -146,7 +146,6 @@ EXAMPLES = r'''
''' '''
import os import os
import boto3
import getpass import getpass
import json import json
import os import os
@ -158,9 +157,17 @@ import string
import subprocess import subprocess
import time import time
try:
import boto3
HAS_BOTO_3 = True
except ImportError as e:
HAS_BOTO_3_ERROR = str(e)
HAS_BOTO_3 = False
from functools import wraps from functools import wraps
from ansible import constants as C from ansible import constants as C
from ansible.errors import AnsibleConnectionFailure, AnsibleError, AnsibleFileNotFound from ansible.errors import AnsibleConnectionFailure, AnsibleError, AnsibleFileNotFound
from ansible.module_utils.basic import missing_required_lib
from ansible.module_utils.six import PY3 from ansible.module_utils.six import PY3
from ansible.module_utils.six.moves import xrange from ansible.module_utils.six.moves import xrange
from ansible.module_utils._text import to_bytes, to_native, to_text from ansible.module_utils._text import to_bytes, to_native, to_text
@ -240,6 +247,8 @@ class Connection(ConnectionBase):
MARK_LENGTH = 26 MARK_LENGTH = 26
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
if not HAS_BOTO_3:
raise AnsibleError('{0}: {1}'.format(missing_required_lib("ncclient"), HAS_BOTO_3_ERROR))
super(Connection, self).__init__(*args, **kwargs) super(Connection, self).__init__(*args, **kwargs)
self.host = self._play_context.remote_addr self.host = self._play_context.remote_addr

View file

@ -4,4 +4,3 @@ shippable/aws/group1
non_local non_local
needs/root needs/root
needs/target/connection needs/target/connection
disabled