ansible-playbook: error: no such option: -o [packer 1.4.0 ansible 2.7.10]

423 views
Skip to first unread message

e.te...@arduino.cc

unread,
Apr 18, 2019, 9:36:10 AM4/18/19
to Packer
Hello,

I am trying to build an AMI on AWS EC2 using the ansible provisioner.
Unfortunately the provision step breaks due to an undefined option passed to ansible.

The error I get during the run is:
[...]
==> amazon-ebs: Executing Ansible: run-ansible-playbook.sh --extra-vars packer_build_name=amazon-ebs packer_builder_type=amazon-ebs -o IdentitiesOnly=yes -i /tmp/packer-provisioner-ansible639718942 /.../playbooks/bootstrap.yaml -e ansible_ssh_private_key_file=/tmp/ansible-key290956539 -vv
    amazon-ebs: Running: pipenv run ansible-playbook --extra-vars packer_build_name=amazon-ebs packer_builder_type=amazon-ebs -o IdentitiesOnly=yes -i /tmp/packer-provisioner-ansible639718942 /.../playbooks/bootstrap.yaml -e ansible_ssh_private_key_file=/tmp/ansible-key290956539 -vv
    amazon-ebs: Loading .env environment variables…
    amazon-ebs: Usage: ansible-playbook [options] playbook.yml [playbook2 ...]
    amazon-ebs:
    amazon-ebs: ansible-playbook: error: no such option: -o
[...]


Ansible version:
$ pipenv run ansible-playbook --version
Loading .env environment variables…
ansible-playbook 2.7.10
  config file = /.../ansible.cfg
  configured module search path = [u'/.../modules']
  ansible python module location = /.../.local/share/virtualenvs/operations-Xz-KgfLF/local/lib/python2.7/site-packages/ansible
  executable location = /.../.local/share/virtualenvs/operations-Xz-KgfLF/bin/ansible-playbook
  python version = 2.7.12 (default, Dec  4 2017, 14:50:18) [GCC 5.4.0 20160609]


Packer version:
$ packer version
Packer v1.4.0

Running ansible-playbook without -o works. Testing the entire cli command has proven very hard because I was not able to retain the inventory for further debugging (even with --debug).

As I was not able to find any reference to the -o option in the ansible reference (since ansible 2.5, the oldest doc available on https://docs.ansible.com/), is ansible 2.x expected to work with the packer ansible provisioner?

If it should, any idea how may I overcome or fix this issue?

Thank you for your time and help,
Edoardo

Rickard von Essen

unread,
Apr 18, 2019, 12:29:35 PM4/18/19
to packe...@googlegroups.com
Can you supply your template, at least the ansible provisioner section. 

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/ee91585e-d2c7-4a12-abc6-3772e2f81bf8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Edoardo Tenani

unread,
Apr 19, 2019, 2:37:10 AM4/19/19
to packe...@googlegroups.com

This is the template: https://pastebin.com/a5huLZQ2

For reference, the "run-ansible-playbook.sh" scripts contains:

#!/usr/bin/env bash

cd /.../packer-build-configurations/operations
echo "Running: pipenv run ansible-playbook $@"
pipenv run ansible-playbook $@

We are using pipenv to lock ansible version and its dependencies.


Thank you,
Edoardo

Rickard von Essen

unread,
Apr 21, 2019, 6:26:46 AM4/21/19
to packe...@googlegroups.com
You script doesn't properly pass arguments. Arguments that contains spaces are split. If you remove the script or fix it it will work. 

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.

Edoardo Tenani

unread,
Apr 30, 2019, 7:05:05 AM4/30/19
to packe...@googlegroups.com
> You script doesn't properly pass arguments.

T^T

Replacing $@ with a "$@" solved this issue. I was pretty sure I had
tried all passible bash expansions combinations, but obviously not.

Thank you for you help!

I also discovered that the ansible provisioner create a one-off keypair,
but (in my case at least) it does not get authorized on the server,
resulting in ssh authentication error through the ssh proxy. Is this
expected? How am I supposed to add the public key to the authorized key
on the server in this case?

I was expecting the provisioner to use the same settings specified for
the communicator in the builder, why it does not?

Thank you,
Edoardo

Rickard von Essen

unread,
Apr 30, 2019, 10:22:08 AM4/30/19
to packe...@googlegroups.com
The temporary ssh keypair should not be on the server, it's used for ansible to authorize against the local proxy that ansible runs towards. This local proxy marchals the traffic and forwards it to the normal packer communicator. 

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages