Skip to content

Commit

Permalink
html_fancy: Win2008 compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
fboender committed Jan 11, 2016
1 parent 4493b94 commit 0759be3
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 30 deletions.
4 changes: 4 additions & 0 deletions example/hosts
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ sol_host

[openbsd]
openbsd.dev.local

[windows]
win2k8r2.local
win.dev.local
39 changes: 39 additions & 0 deletions example/out/win2k8r2.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"ansible_facts": {
"ansible_architecture": "64-bit",
"ansible_date_time": {
"date": "08/01/2016",
"day": "08",
"hour": "23",
"iso8601": "2016-01-08T23:10:56",
"minute": "10",
"month": "01",
"year": "2016"
},
"ansible_distribution": "Microsoft Windows NT 6.1.7601 Service Pack 1",
"ansible_distribution_version": "6.1.7601.65536",
"ansible_fqdn": "win2k8r2.local",
"ansible_hostname": "win2k8r2",
"ansible_interfaces": [
{
"default_gateway": "192.168.1.1",
"dns_domain": "home",
"interface_index": 11,
"interface_name": "Intel(R) PRO/1000 MT Desktop Adapter"
}
],
"ansible_ip_addresses": [
"192.168.1.94",
"fe80::aca8:571c:f3e2:afd7"
],
"ansible_lastboot": "2016-01-08 23:08:57Z",
"ansible_os_family": "Windows",
"ansible_os_name": "Microsoft Windows Server 2008 R2 Standard",
"ansible_powershell_version": 3,
"ansible_system": "Win32NT",
"ansible_totalmem": 2147016704,
"ansible_uptime_seconds": 119,
"ansible_winrm_certificate_expires": "2016-10-10 19:34:00"
},
"changed": false
}
77 changes: 47 additions & 30 deletions src/ansiblecmdb/data/tpl/html_fancy.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,25 @@ if columns is not None:
${host['ansible_facts'].get('ansible_fqdn', '')}
</%def>
<%def name="col_main_ip(host)">
${host['ansible_facts'].get('ansible_default_ipv4', {}).get('address', '')}
<%
default_ipv4 = ''
if host['ansible_facts'].get('ansible_os_family', '') == 'Windows':
ipv4_addresses = [ip for ip in host['ansible_facts'].get('ansible_ip_addresses', []) if ':' not in ip]
if ipv4_addresses:
default_ipv4 = ipv4_addresses[0]
else:
default_ipv4 = host['ansible_facts'].get('ansible_default_ipv4', {}).get('address', '')
%>
${default_ipv4}
</%def>
<%def name="col_all_ip(host)">
${'<br>'.join(host['ansible_facts'].get('ansible_all_ipv4_addresses', []))}
<%
if host['ansible_facts'].get('ansible_os_family', '') == 'Windows':
ipv4_addresses = [ip for ip in host['ansible_facts'].get('ansible_ip_addresses', []) if ':' not in ip]
else:
ipv4_addresses = host['ansible_facts'].get('ansible_all_ipv4_addresses', [])
%>
${'<br>'.join(ipv4_addresses)}
</%def>
<%def name="col_os(host)">
% if host['ansible_facts'].get('ansible_distribution', '') in ["OpenBSD"]:
Expand All @@ -74,7 +89,7 @@ if columns is not None:
<%def name="col_cpu_type(host)">
<% cpu_type = host['ansible_facts'].get('ansible_processor', 0)%>
% if isinstance(cpu_type, list):
${ cpu_type[-1] }
${ cpu_type[-1] }
% endif
</%def>
<%def name="col_vcpus(host)">
Expand Down Expand Up @@ -216,34 +231,36 @@ if columns is not None:
<tr><th>FQDN</th><td>${host['ansible_facts'].get('ansible_fqdn', '')}</td></tr>
<tr><th>All IPv4</th><td>${'<br>'.join(host['ansible_facts'].get('ansible_all_ipv4_addresses', []))}</td></tr>
</table>
<table class="net_overview">
<tr>
<th>IPv4 Networks</th>
<td>
<table class="net_overview">
<tr>
<th>dev</th>
<th>address</th>
<th>network</th>
<th>netmask</th>
</tr>
% for iface_name in sorted(host['ansible_facts'].get('ansible_interfaces', [])):
<% iface = host['ansible_facts'].get('ansible_' + iface_name, {}) %>
% for net in [iface.get('ipv4', {})] + iface.get('ipv4_secondaries', []):
% if 'address' in net:
<tr>
<td>${iface_name}</td>
<td>${net['address']}</td>
<td>${net['network']}</td>
<td>${net['netmask']}</td>
</tr>
% endif
% if host['ansible_facts'].get('ansible_os_family', '') != "Windows":
<table class="net_overview">
<tr>
<th>IPv4 Networks</th>
<td>
<table class="net_overview">
<tr>
<th>dev</th>
<th>address</th>
<th>network</th>
<th>netmask</th>
</tr>
% for iface_name in sorted(host['ansible_facts'].get('ansible_interfaces', [])):
<% iface = host['ansible_facts'].get('ansible_' + iface_name, {}) %>
% for net in [iface.get('ipv4', {})] + iface.get('ipv4_secondaries', []):
% if 'address' in net:
<tr>
<td>${iface_name}</td>
<td>${net['address']}</td>
<td>${net['network']}</td>
<td>${net['netmask']}</td>
</tr>
% endif
% endfor
% endfor
% endfor
</table>
</td>
</tr>
</table>
</table>
</td>
</tr>
</table>
% endif
<table class="net_iface_details">
<tr>
<th>Interface details</th>
Expand Down

0 comments on commit 0759be3

Please sign in to comment.