Skip to content
Snippets Groups Projects
Commit 4ca57277 authored by Attila Farkas's avatar Attila Farkas
Browse files

Install pywinrm on controller

parent 828c0c65
No related branches found
No related tags found
1 merge request!32Version 2.0.0
......@@ -53,6 +53,8 @@ class Preconfig:
all_vars: Dict = {"device_aliases": aliases}
if sandbox.border_router_present:
all_vars["border_router_name"] = sandbox.config["border_router_name"]
if sandbox.controller_present:
all_vars["controller_name"] = sandbox.config["controller_name"]
hosts_vars: Dict = {}
router_vars: Dict = {}
ssh_vars: Dict = {"ansible_python_interpreter": "python3"}
......
......@@ -26,6 +26,7 @@ class DeviceType(Enum):
def __str__(self):
return self.name.lower()
class NetworkType(Enum):
"""Type of network"""
PRIVATE = 1
......@@ -34,6 +35,7 @@ class NetworkType(Enum):
def __str__(self):
return f"{self.name.lower()}_network"
class DevicePurpose(Enum):
"""Function of a device - also determines building order"""
BORDER_ROUTER = 1
......@@ -143,7 +145,10 @@ class Sandbox:
self.flavors,
self.config,
border_router,
ansible_installed,
self.networks)
self.controller_present: bool =\
Sandbox._controller_needed(self.devices, ansible_installed)
@classmethod
def _create_network_list(cls, topology: Topology, border_router: bool,
......@@ -175,7 +180,10 @@ class Sandbox:
return flavors
@staticmethod
def _controller_needed(devices: List[Device]) -> bool:
def _controller_needed(devices: List[Device], ansible_installed: bool) \
-> bool:
if ansible_installed:
return False
for device in devices:
if device.protocol == Protocol.WINRM:
return True
......@@ -238,7 +246,7 @@ class Sandbox:
if net.name == config["border_router_network_name"]:
br_network: Network = net
br_ip: IPAddress = IPAddress(config["border_router_ip"])
device_networks.append(Interface(br_network, br_ip+router_n))
device_networks.append(Interface(br_network, br_ip + router_n))
if router.base_box.mgmt_protocol == kypo.Protocol.SSH:
protocol: Protocol = Protocol.SSH
......@@ -270,6 +278,7 @@ class Sandbox:
@staticmethod
def _create_device_list(topology: Topology, flavors: List[Flavor],
config: Dict, border_router: bool,
ansible_installed: bool,
networks: List[Network]) -> List[Device]:
"""Creates list of devices with all attributes"""
......@@ -288,8 +297,7 @@ class Sandbox:
flavors, config,
networks,
border_router, router_n))
if Sandbox._controller_needed(devices): # needs to be at the end
if Sandbox._controller_needed(devices, ansible_installed): # needs to be at the end
devices.append(Device(config["controller_name"],
DevicePurpose.CONTROLLER,
config["controller_box"],
......
......@@ -12,6 +12,7 @@
value: '1'
vars: {}
- name: Linux configuration
hosts: ssh
become: yes
......@@ -41,11 +42,13 @@
interface_static_ip: '{{ interface.interface_ip }}'
interface_static_netmask: '{{ interface.interface_netmask }}'
- name: Linux Host configuration
hosts: hosts:&ssh
become: yes
tasks: []
- name: Border router configuration
hosts: '{{ "border_router_name" | default("!all") }}'
become: yes
......@@ -58,4 +61,15 @@
jump: SNAT
out_interface: '{{ ansible_default_ipv4.interface }}'
to_source: '{{ ansible_default_ipv4.address }}'
- name: Controller configuration
hosts: '{{ "controller_name" | default("!all") }}'
become: yes
tasks:
- name: Install pywinrm
pip:
name: pywinrm
executable: "pip3"
...
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment