diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index a15f0b31f0..6b3badf806 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -122,8 +122,11 @@ def get_distribution(): if platform.system() == 'Linux': try: distribution = platform.linux_distribution()[0].capitalize() - if distribution == 'NA': - if os.path.is_file('/etc/system-release'): + if not distribution and os.path.is_file('/etc/system-release'): + distribution = platform.linux_distribution(supported_dists=['system'])[0].capitalize() + if 'Amazon' in distribution: + distribution = 'Amazon' + else: distribution = 'OtherLinux' except: # FIXME: MethodMissing, I assume? diff --git a/library/system/hostname b/library/system/hostname index cbe6ea654d..0dafdf778d 100644 --- a/library/system/hostname +++ b/library/system/hostname @@ -241,6 +241,11 @@ class CentOSHostname(Hostname): distribution = 'Centos' strategy_class = RedHatStrategy +class AmazonLinuxHostname(Hostname): + platform = 'Linux' + distribution = 'Amazon' + strategy_class = RedHatStrategy + # =========================================== class FedoraStrategy(GenericStrategy):