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

Configure controller to be able to provision Windows hosts

parent fe68b34c
No related branches found
No related tags found
1 merge request!22Resolve "Support Windows boxes"
......@@ -99,6 +99,7 @@ def _create_commands(device_attributes):
def _create_ansible_commands(device_name, playbook_location, input_definitions, flags):
"""Create commands for running a playbook from the Vagrantfile."""
commands = []
windows_hosts = _find_windows_boxes(input_definitions);
playbook = dict()
playbook["type"] = "string"
......@@ -130,6 +131,8 @@ def _create_ansible_commands(device_name, playbook_location, input_definitions,
for router in input_definitions["routers"]:
router_names.append(router["name"])
groups["groups"]["routers"] = router_names
windows_hosts = _find_windows_boxes(input_definitions)
groups["groups"]["windows"] = windows_hosts
if "groups" in input_definitions:
for group in input_definitions["groups"]:
groups["groups"][group["name"]] = group["nodes"]
......@@ -157,8 +160,14 @@ def _create_ansible_commands(device_name, playbook_location, input_definitions,
extravars["type"] = "dictionary"
extravars["command"] = "extra_vars"
extravars["dictionary"] = dict()
extravars["dictionary"]["ansible_python_interpreter"] = \
"\"/usr/bin/python3\""
if device_name in windows_hosts:
extravars["dictionary"]["ansible_connection"] = "\"winrm\""
extravars["dictionary"]["ansible_user"] = "\"vagrant\""
extravars["dictionary"]["ansible_password"] = "\"vagrant\""
extravars["dictionary"]["ansible_winrm_transport"] = "\"basic\""
extravars["dictionary"]["ansible_winrm_server_cert_validation"] = "\"ignore\""
else:
extravars["dictionary"]["ansible_python_interpreter"] = "\"/usr/bin/python3\""
commands.append(extravars)
return commands
......
......@@ -19,18 +19,9 @@
loop_control:
loop_var: interface
- name: Prepare controller
hosts: controller
become: yes
tasks:
- name: Install pywinrm
pip:
name: pywinrm
executable: "/usr/bin/pip3"
- name: Add aliases
lineinfile:
path: /etc/hosts
line: '192.168.20.6 win'
...
\ No newline at end of file
- name: Install pywinrm
pip:
name: pywinrm
executable: "/usr/bin/pip3"
...
......@@ -19,9 +19,21 @@
name: routers
when: config.routers
- name: Configuring devices separately
hosts: all
- name: Configuring Linux devices separately
hosts: all:!windows
become: yes
tasks:
- name: include role
include_role:
name: "{{ inventory_hostname }}"
- name: Configuring Windows devices separately
hosts: windows
become: yes
become_method: runas
become_user: vagrant
vars:
ansible_become_pass: vagrant
tasks:
- name: include role
include_role:
......
......@@ -22,4 +22,4 @@
loop: "{{ routes }}"
loop_control:
loop_var: interface
...
\ No newline at end of file
...
---
- name: Hello world
hosts: all
tasks:
- name: print hello world
debug:
msg: "Hello World"
...
\ No newline at end of file
- name: print hello world
debug:
msg: "Hello World"
...
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