mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix for v1 handling of unicode extra-vars
This commit is contained in:
parent
1ed1af6cb4
commit
5b279c1c15
3 changed files with 9 additions and 3 deletions
|
@ -47,6 +47,7 @@ import ansible.utils.template
|
||||||
from ansible import errors
|
from ansible import errors
|
||||||
from ansible import callbacks
|
from ansible import callbacks
|
||||||
from ansible import utils
|
from ansible import utils
|
||||||
|
from ansible.utils import to_unicode
|
||||||
from ansible.color import ANSIBLE_COLOR, stringc
|
from ansible.color import ANSIBLE_COLOR, stringc
|
||||||
from ansible.callbacks import display
|
from ansible.callbacks import display
|
||||||
|
|
||||||
|
@ -144,10 +145,11 @@ def main(args):
|
||||||
|
|
||||||
extra_vars = {}
|
extra_vars = {}
|
||||||
for extra_vars_opt in options.extra_vars:
|
for extra_vars_opt in options.extra_vars:
|
||||||
if extra_vars_opt.startswith("@"):
|
extra_vars_opt = to_unicode(extra_vars_opt)
|
||||||
|
if extra_vars_opt.startswith(u"@"):
|
||||||
# Argument is a YAML file (JSON is a subset of YAML)
|
# Argument is a YAML file (JSON is a subset of YAML)
|
||||||
extra_vars = utils.combine_vars(extra_vars, utils.parse_yaml_from_file(extra_vars_opt[1:], vault_password=vault_pass))
|
extra_vars = utils.combine_vars(extra_vars, utils.parse_yaml_from_file(extra_vars_opt[1:], vault_password=vault_pass))
|
||||||
elif extra_vars_opt and extra_vars_opt[0] in '[{':
|
elif extra_vars_opt and extra_vars_opt[0] in u'[{':
|
||||||
# Arguments as YAML
|
# Arguments as YAML
|
||||||
extra_vars = utils.combine_vars(extra_vars, utils.parse_yaml(extra_vars_opt))
|
extra_vars = utils.combine_vars(extra_vars, utils.parse_yaml(extra_vars_opt))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -33,7 +33,7 @@ includes:
|
||||||
ansible-playbook test_includes.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) $(TEST_FLAGS)
|
ansible-playbook test_includes.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) $(TEST_FLAGS)
|
||||||
|
|
||||||
unicode:
|
unicode:
|
||||||
ansible-playbook unicode.yml -i $(INVENTORY) -e @$(VARS_FILE) -v $(TEST_FLAGS)
|
ansible-playbook unicode.yml -i $(INVENTORY) -e @$(VARS_FILE) -v $(TEST_FLAGS) -e 'extra_var=café'
|
||||||
# Test the start-at-task flag #9571
|
# Test the start-at-task flag #9571
|
||||||
ansible-playbook unicode.yml -i $(INVENTORY) -e @$(VARS_FILE) -v --start-at-task '*¶' -e 'start_at_task=True' $(TEST_FLAGS)
|
ansible-playbook unicode.yml -i $(INVENTORY) -e @$(VARS_FILE) -v --start-at-task '*¶' -e 'start_at_task=True' $(TEST_FLAGS)
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,10 @@
|
||||||
host_id: '{{item}}'
|
host_id: '{{item}}'
|
||||||
with_sequence: start=1 end={{num_hosts}} format=%d
|
with_sequence: start=1 end={{num_hosts}} format=%d
|
||||||
|
|
||||||
|
- name: 'A task with unicode extra vars'
|
||||||
|
debug: var=extra_var
|
||||||
|
|
||||||
|
|
||||||
- name: 'A play for hosts in group: ĪīĬĭ'
|
- name: 'A play for hosts in group: ĪīĬĭ'
|
||||||
hosts: 'ĪīĬĭ'
|
hosts: 'ĪīĬĭ'
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
|
|
Loading…
Reference in a new issue