The ansible-local provisioner does not accept commas in the "extra_arguments" option

823 views
Skip to first unread message

Mike Titus

unread,
Dec 6, 2015, 5:27:56 PM12/6/15
to Packer
The "extra_arguments" option appears to be intended to accept --tags, --skip-tags, and --extra-vars command line arguments, but (legal) commas in --tags or --skip-tags cause errors during packer build.

This provisioner succeeds:
    "provisioners": [{
        "type": "ansible-local",
        "extra_arguments":  "--tags 'php5'",
        "inventory_file":   "../inventory/packer",
        "playbook_dir":     "..",
        "playbook_file":    "../example.yml"
    }]

This provisioner fails:
    "provisioners": [{
        "type": "ansible-local",
        "extra_arguments":  "--tags 'php5,php-config'",
        "inventory_file":   "../inventory/packer",
        "playbook_dir":     "..",
        "playbook_file":    "../example.yml"
    }]
with this error message:
    docker: Executing Ansible: cd /tmp/packer-provisioner-ansible-local && ANSIBLE_FORCE_COLOR=1 PYTHONUNBUFFERED=1 ansible-playbook /tmp/packer-provisioner-ansible-local/leadferret.yml --tags 'php5 php-config' -c local -i /tmp/packer-provisioner-ansible-local/packer
    docker: ERROR: tag(s) not found in playbook: php5 php-config.  possible values: application-env-config,build,common,crons,datadog-agent,deploy,leadferret,node_npm,php-config,php5,rsyslog,rundeck-common,rundeck-datadog-agent-restart,ssl-rds,user-accounts

It's clear that the "extra_arguments" parser is stripping out commas.  Is the best way forward to modify the "extra_arguments" parsing to leave commas in-place (possibly breaking option parsing elsewhere), or to add new "tags" and "skip-tags" options that can preserve commas without affecting other parsing?

Mike Michel

unread,
Dec 8, 2015, 2:43:43 PM12/8/15
to Packer
hi,

i am using

extra_arguments": [
                    "--skip-tags \"zabbix,zabbix-docker,logstash,scaleio\" -e \"tlscert=\""
                ]


works fine for me.

Jonathan Cremin

unread,
Dec 10, 2015, 12:02:19 PM12/10/15
to Packer
That's because you're wrapping it in brackets, turning it into a single element array.

If you use a string directly it tries to do some array/string magic and ends up removing commas.

Mike Titus

unread,
Dec 10, 2015, 8:14:23 PM12/10/15
to Packer
That was the problem, I overlooked that extra_arguments takes an array of strings.  Thanks for your help!
Reply all
Reply to author
Forward
0 new messages