ansible --version
2.5.x
molecule --version
2.17
Molecule installation method (one of):
Ansible installation method (one of):
Please give some details of the feature being requested or what
should happen if providing a bug report.
Please give some details of what is actually happening.
Include a minimum complete verifiable example with
output of running molecule --debug.
ERROR:
An error occurred during the test sequence action: 'create'. Cleaning up.
Traceback (most recent call last):
File "/usr/local/bin/molecule", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/molecule/command/test.py", line 141, in test
base.execute_subcommand(scenario.config, 'destroy')
File "/usr/local/lib/python2.7/dist-packages/molecule/command/base.py", line 100, in execute_subcommand
return command(config).execute()
File "/usr/local/lib/python2.7/dist-packages/molecule/command/base.py", line 51, in __init__
self._setup()
File "/usr/local/lib/python2.7/dist-packages/molecule/command/base.py", line 93, in _setup
self._config.provisioner.manage_inventory()
File "/usr/local/lib/python2.7/dist-packages/molecule/provisioner/ansible.py", line 628, in manage_inventory
self._write_inventory()
File "/usr/local/lib/python2.7/dist-packages/molecule/provisioner/ansible.py", line 679, in _write_inventory
self._verify_inventory()
File "/usr/local/lib/python2.7/dist-packages/molecule/provisioner/ansible.py", line 738, in _verify_inventory
if not self.inventory:
File "/usr/local/lib/python2.7/dist-packages/molecule/provisioner/ansible.py", line 467, in inventory
connection_options = self.connection_options(instance_name)
File "/usr/local/lib/python2.7/dist-packages/molecule/provisioner/ansible.py", line 518, in connection_options
d = self._config.driver.ansible_connection_options(instance_name)
File "/usr/local/lib/python2.7/dist-packages/molecule/driver/delegated.py", line 162, in ansible_connection_options
d['identity_file'],
KeyError: 'identity_file'
Hello, how could we connect to windows host using delegated driver via winrm connection?
Do you have any examples or ideas?
Now we try to connect using these params:
ansible_port: 5986
ansible_connection: winrm
ansible_winrm_transport: credssp
ansible_winrm_server_cert_validation: ignore
But I have no idea what should be in login_cmd_template:
driver:
name: delegated
options:
managed: False|True
login_cmd_template: '???'
ansible_connection_options:
connection: winrm
@retr0h Could you kindly look at this question?
@vutkin windows isn't a use case Molecule really handles. It may work, but it's not really supported.
@retr0h may we add PR with windows support?
Right now I am experimenting with this and this seems to work:
create.yml
- name: Create
hosts: localhost
connection: local
gather_facts: false
no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}"
tasks:
- name: HyperV host to inventory
add_host:
name: hyperv-host
ansible_host: 192.168.1.10
ansible_user: Administrator
ansible_password: Welcome01
ansible_connection: winrm
ansible_winrm_transport: ntlm
ansible_winrm_message_encryption: auto
ansible_port: 5985
- name: Create VMs
win_hyperv_guest:
name: "{{ item.name }}"
state: present
hostserver: "{{ molecule_yml.driver.hyperv_host | default(omit) }}"
generation: "{{ item.generation | default(omit) }}"
cpu: "{{ item.cpu | default(omit) }}"
memory: "{{ item.memory | default(omit) }}"
disks: "{{ item.disks | default(omit) }}"
network_adapters: "{{ item.network_adapters | default(omit) }}"
secure_boot: "{{ item.secure_boot | default(omit) }}"
secure_boot_template: "{{ item.secure_boot_template | default(omit) }}"
with_items: "{{ molecule_yml.platforms }}"
delegate_to: hyperv-host
The win_hyperv_guest module is custom module (for now, hoping to get it merged soon) so ignore that ;)
Still need to figure out how these created machines get picked up by molecule.
@watsonb Might have some more Windows with Molecule information for you guys?
Edit: I think the main problem is instance config which now only seems to support ssh. See #1292
I've published an example of how I accomplish mixed-mode support with Molecule for a particular Ansible role that I wrote that supports flavors of Linux and Windows.
https://github.com/watsonb/ar_jenkins_slave
The Molecule test for this role employs two scenarios: default (flavors of Linux) and windows (you know, for Windows). The default scenario uses the Molecule delegated driver to spin up new Virtual Machines on VMWare and, as these VMs are Linux-based everything works as expected once they are powered on and the instance config dictionary is populated with IPs and SSH parameters.
I was toying with using the delegated driver as well for spinning up new Windows VMs, but as @wilmardo mentioned, I couldn't figure out how to (in a native way) populate the instance config dictionary with WinRM things for Molecule to connect to these new instances once powered up. I resorted to using the Molecule vagrant driver to spin up a Windows VM in VirtualBox based on a custom Windows2016 Server vagrant.box I made with Packer. You can see the connection details specified under molecule/windows/molecule.yml and it works like a champ, albeit a bit slow since this VirtualBox capability is actually running within another Linux VM in VMWare and things start feeling a little Inception-y.
Is there any progress on this issue? @vutkin @kharkevich
I would like this as well and might take a stab at it :)
I'm closing this out since I personally do not support windows, and have no good way to verify, document, or tests PRs related to windows.
Could you please reopen this issue and mark it as enhancement?
Hi @gundalow , could you please review https://github.com/ansible/molecule/pull/1674?
TIA.
Here is an example how we use winrm on aws:
link to scenario folder
link to create/destroy files
Here also some templates for winrm scenarios:
ansible devkit
Since https://github.com/ansible/molecule/pull/1674 is merged, we can close this out?
Most helpful comment
Hello, how could we connect to windows host using
delegated drivervia winrm connection?Do you have any examples or ideas?
Now we try to connect using these params:
But I have no idea what should be in
login_cmd_template: