26d9341891
* Add win_hosts module added win_hosts module for easier manipulation of hosts entries in "%windir%\system32\drivers\etc\hosts" for windows systems * Update win_hosts.py * Add alias support to win_hosts module (#1) * win_hosts supports aliases added support for adding / removing aliases from a host entry, rather than adding a new entry added ability for win_hosts to detect aliases: `192.168.1.1 alias1 alias2 alias3` ``` win_hosts: host_name: alias2 ip_address: 192.168.1.1 ``` will result in `192.168.1.1 alias1 alias3` also includes `replace` and `add` as options for `ip_action` (`replace` is default) for example: ``` 192.168.1.1 my_reused_alias 192.168.1.2 my_reused_alias ``` with ``` win_hosts: host_name: my_reused_alias ip_address: 192.168.1.3 ip_action: add ``` the result will be ``` 192.168.1.1 my_reused_alias 192.168.1.2 my_reused_alias ``` but with `ip_action=replace` the result would be ``` 192.168.1.3 my_reused_alias ``` * fixed metadata version and version added * fix line endings * upload fixed line endings try to upload the file with the fixed line endings * aliases and canonical names are separate entities. added IPv4 and IPv6 validation * only makes changes if "check_mode" is false * improved behavior for duplicate aliases/entries. * adding tests * missing aliases file * fix trailing whitespace and uses explicit paths * Tweak tests to copy and restore original hosts file
17 lines
394 B
YAML
17 lines
394 B
YAML
---
|
|
- name: take a copy of the original hosts file
|
|
win_copy:
|
|
src: C:\Windows\System32\drivers\etc\hosts
|
|
dest: '{{ remote_tmp_dir }}\hosts'
|
|
remote_src: yes
|
|
|
|
- block:
|
|
- name: run tests
|
|
include_tasks: tests.yml
|
|
|
|
always:
|
|
- name: restore hosts file
|
|
win_copy:
|
|
src: '{{ remote_tmp_dir }}\hosts'
|
|
dest: C:\Windows\System32\drivers\etc\hosts
|
|
remote_src: yes
|