Packer version:
0.12.0
Description of problem:
I'm running packer inside a pipeline, so I believe the problem comes from packer.
The parsing of the skip-tags parameter seems incorrect, when entered --skip-tags="tag1,tag2"
it then becomes --skip-tags="tag1 tag2"
.
How reproducible:
Always with ansible-local as long as this extra-parameter includes skipping tag.
Steps to reproduce:
I believe could be done with such simple playbook as:
https://gist.github.com/xlr-8/0f1c729c17768c310612b6343a4db2d8
And a fairly basic template:
https://gist.github.com/xlr-8/7c524028de339277d1243ca8fb4da9f3
Expected output:
Of ansible-playbook play.yml -v --skip-tags='C,B'
:
Using /etc/ansible/ansible.cfg as config file
PLAY [localhost] ***************************************************************
TASK [setup] *******************************************************************
ok: [localhost]
TASK [command] *****************************************************************
changed: [localhost] => {"changed": true, "cmd": "echo 'A'", "delta": "0:00:00.005072", "end": "2016-11-18 18:36:02.183270", "rc": 0, "start": "2016-11-18 18:36:02.178198", "stderr": "", "stdout": "A", "stdout_lines": ["A"], "warnings": []}
PLAY RECAP *********************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0
Current output:
Of ansible-playbook play.yml -v --skip-tags='C,B'
when bad substitution:
Using /etc/ansible/ansible.cfg as config file
PLAY [localhost] ***************************************************************
TASK [setup] *******************************************************************
ok: [localhost]
TASK [command] *****************************************************************
changed: [localhost] => {"changed": true, "cmd": "echo 'A'", "delta": "0:00:00.005334", "end": "2016-11-18 18:36:07.074736", "rc": 0, "start": "2016-11-18 18:36:07.069402", "stderr": "", "stdout": "A", "stdout_lines": ["A"], "warnings": []}
TASK [command] *****************************************************************
changed: [localhost] => {"changed": true, "cmd": "echo 'B'", "delta": "0:00:00.004666", "end": "2016-11-18 18:36:07.260849", "rc": 0, "start": "2016-11-18 18:36:07.256183", "stderr": "", "stdout": "B", "stdout_lines": ["B"], "warnings": []}
TASK [command] *****************************************************************
changed: [localhost] => {"changed": true, "cmd": "echo 'C'", "delta": "0:00:00.005292", "end": "2016-11-18 18:36:07.449064", "rc": 0, "start": "2016-11-18 18:36:07.443772", "stderr": "", "stdout": "C", "stdout_lines": ["C"], "warnings": []}
PLAY RECAP *********************************************************************
localhost : ok=4 changed=3 unreachable=0 failed=0
Host platform:
EC2 IAM Jessie - ami-e079f893
I tried to find way of bypassing the problem, with multiple --skip-tags
, or with inhibitions, etc; but didn't manage to get it working. Sorry if the report is not as complete as you wish, if you need extra information please let me know.
looks to me like extra_arguments is a list https://www.packer.io/docs/provisioners/ansible-local.html#extra_arguments
try updating your config and let me know if that helps
extra_arguments is a list
That solves the problem. Reopen if it doesn't solves it for you.
Indeed solved the problem, sorry to haven't double check the documentation.
I am not sure it's possible, but would it be worth adding a type check in packer, so that it rejects object that does not look as explained in the documentation?
If I understood the problem, it came from the fact that the coma was interpreted as a second element in the array; but what I provided really was a string, so maybe is there a way to better parse the elements between json/golang?
Thanks for the quick help anyway, really appreciated!
but would it be worth adding a type check in packer
The reason to handle it this way is so you can pass arrays as user vars, example:
{
"variables": {
"extra_args": "",
},
"provisioners": [
{
"type": "ansible-local",
"playbook_file": "test.yml",
"extra_arguments": "{{ user `extra_args` }}"
}
]
}
packer build -var extra_args='[ "--diff", "-v", "--skip-tags=\'A,C\'" ]' template.json
Alright, I see it makes sense; thank you for the clarifications and trick.
Most helpful comment
The reason to handle it this way is so you can pass arrays as user vars, example:
packer build -var extra_args='[ "--diff", "-v", "--skip-tags=\'A,C\'" ]' template.json