Fixing some bugs found during testing in the host module

reviewable/pr18780/r1
James Cammarata 11 years ago
parent 339f17d560
commit d4ba1f9ded

@ -50,11 +50,10 @@ options:
EXAMPLES = ''' EXAMPLES = '''
# Example host command from Ansible Playbooks # Example host command from Ansible Playbooks
- host: ip=127.0.0.1 hostname=localhost aliases=foobar.com,localhost.foobar.com
- host: ip=127.0.0.1 hostname=localhost state=present - host: ip=127.0.0.1 hostname=localhost state=present
- host: ip=127.0.0.1 hostname=localhost aliases=foobar.com,localhost.foobar.com
- host: ip=192.168.1.1 state=absent - host: ip=192.168.1.1 state=absent
- host: hostname=localhost state=absent - host: ip=::1 hostname=localhost6 aliases=ip6-localhost,ip6-loopback
- host: ip=::1 hostname=localhost aliases=ip6-localhost,ip6-loopback
''' '''
import os import os
@ -126,10 +125,10 @@ class Host(object):
def full_entry_exists(self): def full_entry_exists(self):
if self._has_aliases and not self._aliases_matches: if self._has_aliases and not self._aliases_matches:
return False return False
return self._ip_matches and self.hostname_matches return self._ip_matches and self._hostname_matches
def entry_exists(self): def entry_exists(self):
return self._ip_matches or self.hostname_matches return self._ip_matches or self._hostname_matches
def remove_entry(self): def remove_entry(self):
self._hostsfile_lines.pop(self._found_on_line) self._hostsfile_lines.pop(self._found_on_line)
@ -165,7 +164,7 @@ def main():
result = {} result = {}
host = Host(module) host = Host(module)
result['state'] = host.state result['state'] = host.state
result['changed'] = false result['changed'] = False
err = host.validate_has_hostname_on_present() err = host.validate_has_hostname_on_present()
if err: if err:

Loading…
Cancel
Save