Packer: [BUG] Ansible 2.8.3 is not able to create directory on Windows ("amazon-ebs: Parameter format not correct - ;") when is used with Packer.

Created on 13 Aug 2019  ยท  13Comments  ยท  Source: hashicorp/packer

Bug description

Ansible 2.8.3 cannot create directory on Windows with (with Ansible 2.7.10 everything is fine) when is triggered by Packer.

Packer version

1.4.2
OS / ENVIRONMENT
NAME="Ubuntu"
VERSION="18.04.2 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.2 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

Reproduction

ansible 2.8.3
  config file = None
  configured module search path = ['/home/ubuntu/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.8 (default, Jan 14 2019, 11:02:34) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]

The command:

packer build template.json

ends in failure (packer logs)

When I install Ansible in the following versoin:

ansible 2.7.10
  config file = None
  configured module search path = ['/home/ubuntu/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.8 (default, Jan 14 2019, 11:02:34) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]

The command:

packer build template.json

ends in success (packer logs).

I also tried to run Ansible without packer and both versions (2.7.10 and 2.8.3) can create windows directory.

community-supported plugin provisioneansible-remote

Most helpful comment

@paxpacis Well, I've only tested with some basic modules like win_ping and win_command, so I couldn't say this workaround plugin should work for every supported module. What kind of errors did you get from it?

I used https://gist.github.com/yaegashi/8bab4a2708fb0af0f4f9d0cc2027e67f for connection_plugins/packer.py. Could you try again with this?

All 13 comments

Same here. I'm receiving the error Parameter format not correct - ; with googlecloud builder attempting to build Windows 2016 image. Resolved by downgrading Ansible to 2.7.10.

Hi,

I'm having the same issue, but I do not think it is specific to creating directories.

I created a playbook with only win_ping and got the same error.

- hosts:
    - tag_fe_www
  tasks:
    - name: Example from an Ansible Playbook
      win_ping:

This playbook will fail on setup module:

"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error"

When I add gather_facts: false

- hosts:
    - tag_fe_www
  gather_facts: false
  tasks:
    - name: Example from an Ansible Playbook
      win_ping:

It will fail with:

amazon-ebs: Parameter format not correct - ;

packer --version
1.4.2

Ansible <= 2.7.12 works without issues, Ansible >= 2.8.0 and the builds will fail.

Using this packer.py: https://gist.github.com/finarfin/d1547152bc13c84a6eeecb55bd406368

With this WinRM/Ansible config:

    "communicator": "winrm",
    "winrm_use_ssl": true,
    "winrm_insecure": true,
  "provisioners": [{
    "type": "ansible",
    "playbook_file": "ping.yml",
    "extra_arguments": ["-vvvvvv", "--connection", "packer", "--extra-vars", "ansible_shell_type=powershell ansible_shell_executable=None"]
  }]

Any resolution to this?

No; the ansible provisioner is one of our community-supported provisioners, which means that the HashiCorp maintainers don't spend much engineering time on it. The best way to see a fix make it into Packer is to open a PR.

Also ran into this issue, works by way of downgrading to 2.7.12.

Same here, ansible couldn't get past gathering facts. Had to downgrade to 2.7.14.

It works with Packer v1.4.5 and Ansible 2.9.0 by modifying Ansible 2.7's ssh connection plugin as follows and copying it to connection_plugins/packer.py:

diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py
index 9eca25b766..8ef8f63b32 100644
--- a/lib/ansible/plugins/connection/ssh.py
+++ b/lib/ansible/plugins/connection/ssh.py
@@ -443,9 +443,11 @@ def _ssh_retry(func):
 class Connection(ConnectionBase):
     ''' ssh based connections '''

-    transport = 'ssh'
+    transport = 'packer'
     has_pipelining = True
-    become_methods = frozenset(C.BECOME_METHODS).difference(['runas'])
+    become_methods = []
+    allow_executable = False
+    module_implementation_preferences = ('.ps1', '')

     def __init__(self, *args, **kwargs):
         super(Connection, self).__init__(*args, **kwargs)

We might have to maintain our own connection plugin which doesn't inherit the built-in ssh plugin.

Hi @yaegashi

I already had these changes in my packer.py and for me it did not work..

It works with Packer v1.4.5 and Ansible 2.9.0 by modifying Ansible 2.7's ssh connection plugin as follows and copying it to connection_plugins/packer.py:

I upgraded Ansible to 2.9.0 and packer to 1.4.5 and I still have this issue. When I change Ansible to 2.7.15 it works again..

@paxpacis Well, I've only tested with some basic modules like win_ping and win_command, so I couldn't say this workaround plugin should work for every supported module. What kind of errors did you get from it?

I used https://gist.github.com/yaegashi/8bab4a2708fb0af0f4f9d0cc2027e67f for connection_plugins/packer.py. Could you try again with this?

@yaegashi

Yes, this works!, I was using this version of packer.py

Plus one for:

We might have to maintain our own connection plugin which doesn't inherit the built-in ssh plugin.

I am using Packer version: 1.5.1 and Ansible version: 2.9.3.

Updating packer.py to use the version in @yaegashi's comment above https://github.com/hashicorp/packer/issues/7979#issuecomment-554938289 worked for me, thank you!

Since this is a plugin error, it is likely solved by removing the need for the plugin. We have a PR open at #8625 that will remove the localhost proxy, removing the need for --connection=packer in your extra-vars. There are builds and docs there for this new way of doing things, which will hopefully improve all of your experiences.

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mushon4 picture mushon4  ยท  3Comments

Nikoos picture Nikoos  ยท  3Comments

znerd picture znerd  ยท  3Comments

mwhooker picture mwhooker  ยท  3Comments

DanielBo picture DanielBo  ยท  3Comments