summaryrefslogtreecommitdiff
path: root/cloudinit/distros/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/distros/__init__.py')
-rw-r--r--cloudinit/distros/__init__.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py
index ea0bac23..6a684b89 100644
--- a/cloudinit/distros/__init__.py
+++ b/cloudinit/distros/__init__.py
@@ -24,7 +24,6 @@
from StringIO import StringIO
import abc
-import collections
import itertools
import os
import re
@@ -421,12 +420,16 @@ class Distro(object):
'',
"# User rules for %s" % user,
]
- if isinstance(rules, collections.Iterable):
+ if isinstance(rules, (list, tuple)):
for rule in rules:
lines.append("%s %s" % (user, rule))
- else:
+ elif isinstance(rules, (basestring, str)):
lines.append("%s %s" % (user, rules))
+ else:
+ msg = "Can not create sudoers rule addition with type %r"
+ raise TypeError(msg % (util.obj_name(rules)))
content = "\n".join(lines)
+ content += "\n" # trailing newline
self.ensure_sudo_dir(os.path.dirname(sudo_file))
if not os.path.exists(sudo_file):