-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenable_vnc_on_esxi_firewall.yml
45 lines (43 loc) · 1.39 KB
/
enable_vnc_on_esxi_firewall.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
---
- name: Enable vnc on ESXi host firewall
hosts: esxi
tasks:
- name: Add VNC rule to firewall
shell:
creates: "/etc/vmware/firewall/vnc.xml"
cmd: |
/bin/cat > /etc/vmware/firewall/vnc.xml << EOF
<ConfigRoot>
<!-- VNC -->
<service id="0222">
<id>VNC</id>
<rule id='0000'>
<direction>outbound</direction>
<protocol>tcp</protocol>
<porttype>dst</porttype>
<port>
<begin>5900</begin>
<end>5999</end>
</port>
</rule>
<rule id='0001'>
<direction>inbound</direction>
<protocol>tcp</protocol>
<porttype>dst</porttype>
<port>
<begin>5900</begin>
<end>5964</end>
</port>
</rule>
<enabled>true</enabled>
<required>false</required>
</service>
</ConfigRoot>
EOF
register: vnc_file
- name: Refresh ESXi firewall rules
command: "esxcli network firewall refresh"
when: vnc_file.changed
- name: Enable VNC firewall rule
command: "esxcli network firewall ruleset set --ruleset-id=VNC --enabled=true"
when: vnc_file.changed