diff options
author | Brian Coca <brian.coca+git@gmail.com> | 2015-03-20 11:22:07 -0400 |
---|---|---|
committer | Brian Coca <brian.coca+git@gmail.com> | 2015-03-20 11:23:50 -0400 |
commit | e3e97f6e06a07ec3034ba76c449e01319a8690e7 (patch) | |
tree | 4f00f128f0f97c29edfaac1034f87b0121ed0015 | |
parent | 6dca95b309346e0187477252c265c29cf6395320 (diff) | |
download | ansible-e3e97f6e06a07ec3034ba76c449e01319a8690e7.tar.gz |
now correctly aplies add_host passed variables last to override existing vars.
-rw-r--r-- | lib/ansible/runner/action_plugins/add_host.py | 11 | ||||
-rw-r--r-- | test/integration/unicode.yml | 6 |
2 files changed, 11 insertions, 6 deletions
diff --git a/lib/ansible/runner/action_plugins/add_host.py b/lib/ansible/runner/action_plugins/add_host.py index 2fcea6cd5c..72172fcaec 100644 --- a/lib/ansible/runner/action_plugins/add_host.py +++ b/lib/ansible/runner/action_plugins/add_host.py @@ -69,12 +69,6 @@ class ActionModule(object): inventory._hosts_cache[new_name] = new_host allgroup.add_host(new_host) - # Add any variables to the new_host - for k in args.keys(): - if not k in [ 'name', 'hostname', 'groupname', 'groups' ]: - new_host.set_variable(k, args[k]) - - groupnames = args.get('groupname', args.get('groups', args.get('group', ''))) # add it to the group if that was specified if groupnames: @@ -100,6 +94,11 @@ class ActionModule(object): # actually load host vars new_host.vars = inventory.get_host_variables(new_name, update_cached=True, vault_password=inventory._vault_password) + # Add any passed variables to the new_host + for k in args.keys(): + if not k in [ 'name', 'hostname', 'groupname', 'groups' ]: + new_host.set_variable(k, args[k]) + result['new_host'] = new_name # clear pattern caching completely since it's unpredictable what diff --git a/test/integration/unicode.yml b/test/integration/unicode.yml index 2889155055..6dca7fe490 100644 --- a/test/integration/unicode.yml +++ b/test/integration/unicode.yml @@ -44,6 +44,12 @@ - name: 'A play for hosts in group: ĪīĬĭ' hosts: 'ĪīĬĭ' + gather_facts: false + tasks: + - debug: var=hostvars[inventory_hostname] + +- name: 'A play for hosts in group: ĪīĬĭ' + hosts: 'ĪīĬĭ' gather_facts: true tasks: - debug: msg='Unicode is a good thing ™' |