Update Ansible provisioner docs for WinRM
This commit is contained in:
parent
8658eaf1ac
commit
0c6e6ba637
|
@ -192,7 +192,8 @@ Building within a chroot (e.g. `amazon-chroot`) requires changing the Ansible co
|
||||||
|
|
||||||
### winrm communicator
|
### winrm communicator
|
||||||
|
|
||||||
Windows builds require a custom Ansible connection plugin and a particular configuration. Assuming a directory named `connection_plugins` is next to the playbook and contains a file named `packer.py` whose contents is
|
Windows builds require a custom Ansible connection plugin and a particular configuration. Assuming a directory named `connection_plugins` is next to the playbook and contains a file named `packer.py` which implements
|
||||||
|
the connection plugin. On versions of Ansible before 2.4.x, the following works as the connection plugin
|
||||||
|
|
||||||
``` python
|
``` python
|
||||||
from __future__ import (absolute_import, division, print_function)
|
from __future__ import (absolute_import, division, print_function)
|
||||||
|
@ -213,6 +214,43 @@ class Connection(SSHConnection):
|
||||||
super(Connection, self).__init__(*args, **kwargs)
|
super(Connection, self).__init__(*args, **kwargs)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Newer versions of Ansible require all plugins to have a documentation string. You will need to copy
|
||||||
|
the `options` from the `DOCUMENTATION` string from the [ssh.py Ansible connection plugin](https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/connection/ssh.py)
|
||||||
|
of the Ansible version you are using and add it to packer.py similar to as follows
|
||||||
|
|
||||||
|
``` python
|
||||||
|
from __future__ import (absolute_import, division, print_function)
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
from ansible.plugins.connection.ssh import Connection as SSHConnection
|
||||||
|
|
||||||
|
DOCUMENTATION = '''
|
||||||
|
connection: packer
|
||||||
|
short_description: ssh based connections for powershell via packer
|
||||||
|
description:
|
||||||
|
- This connection plugin allows ansible to communicate to the target packer
|
||||||
|
machines via ssh based connections for powershell.
|
||||||
|
author: Packer
|
||||||
|
version_added: na
|
||||||
|
options:
|
||||||
|
**** Copy the options from
|
||||||
|
https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/connection/ssh.py
|
||||||
|
for the version of Ansible you are using ****
|
||||||
|
'''
|
||||||
|
|
||||||
|
class Connection(SSHConnection):
|
||||||
|
''' ssh based connections for powershell via packer'''
|
||||||
|
|
||||||
|
transport = 'packer'
|
||||||
|
has_pipelining = True
|
||||||
|
become_methods = []
|
||||||
|
allow_executable = False
|
||||||
|
module_implementation_preferences = ('.ps1', '')
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(Connection, self).__init__(*args, **kwargs)
|
||||||
|
```
|
||||||
|
|
||||||
This template should build a Windows Server 2012 image on Google Cloud Platform:
|
This template should build a Windows Server 2012 image on Google Cloud Platform:
|
||||||
|
|
||||||
``` json
|
``` json
|
||||||
|
|
Loading…
Reference in New Issue