mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Split out various vars-related things to avoid merging too early
Fixes #9498
This commit is contained in:
parent
c9ecc51a5e
commit
9a0f8f0158
7 changed files with 88 additions and 43 deletions
|
@ -19,7 +19,7 @@ TMPDIR = $(shell mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir')
|
|||
|
||||
VAULT_PASSWORD_FILE = vault-password
|
||||
|
||||
all: non_destructive destructive includes unicode test_var_precedence check_mode test_hash test_handlers test_group_by test_vault parsing
|
||||
all: parsing test_var_precedence unicode non_destructive destructive includes check_mode test_hash test_handlers test_group_by test_vault
|
||||
|
||||
parsing:
|
||||
ansible-playbook bad_parsing.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -vvv $(TEST_FLAGS) --tags common,scenario1; [ $$? -eq 3 ]
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
- debug: var=extra_var
|
||||
- debug: var=vars_var
|
||||
- debug: var=vars_files_var
|
||||
- debug: var=vars_files_var_role
|
||||
- assert:
|
||||
that:
|
||||
- 'extra_var == "extra_var"'
|
||||
|
|
|
@ -82,8 +82,8 @@ class TestMe(unittest.TestCase):
|
|||
os.remove(temp_path)
|
||||
|
||||
# make sure the variable was loaded
|
||||
assert 'foo' in play.vars, "vars_file was not loaded into play.vars"
|
||||
assert play.vars['foo'] == 'bar', "foo was not set to bar in play.vars"
|
||||
assert 'foo' in play.vars_file_vars, "vars_file was not loaded into play.vars_file_vars"
|
||||
assert play.vars_file_vars['foo'] == 'bar', "foo was not set to bar in play.vars_file_vars"
|
||||
|
||||
def test_vars_file_nonlist_error(self):
|
||||
|
||||
|
@ -133,10 +133,10 @@ class TestMe(unittest.TestCase):
|
|||
os.remove(temp_path2)
|
||||
|
||||
# make sure the variables were loaded
|
||||
assert 'foo' in play.vars, "vars_file was not loaded into play.vars"
|
||||
assert play.vars['foo'] == 'bar', "foo was not set to bar in play.vars"
|
||||
assert 'baz' in play.vars, "vars_file2 was not loaded into play.vars"
|
||||
assert play.vars['baz'] == 'bang', "baz was not set to bang in play.vars"
|
||||
assert 'foo' in play.vars_file_vars, "vars_file was not loaded into play.vars_file_vars"
|
||||
assert play.vars_file_vars['foo'] == 'bar', "foo was not set to bar in play.vars_file_vars"
|
||||
assert 'baz' in play.vars_file_vars, "vars_file2 was not loaded into play.vars_file_vars"
|
||||
assert play.vars_file_vars['baz'] == 'bang', "baz was not set to bang in play.vars_file_vars"
|
||||
|
||||
def test_vars_files_first_found(self):
|
||||
|
||||
|
@ -160,8 +160,8 @@ class TestMe(unittest.TestCase):
|
|||
os.remove(temp_path)
|
||||
|
||||
# make sure the variable was loaded
|
||||
assert 'foo' in play.vars, "vars_file was not loaded into play.vars"
|
||||
assert play.vars['foo'] == 'bar', "foo was not set to bar in play.vars"
|
||||
assert 'foo' in play.vars_file_vars, "vars_file was not loaded into play.vars_file_vars"
|
||||
assert play.vars_file_vars['foo'] == 'bar', "foo was not set to bar in play.vars_file_vars"
|
||||
|
||||
def test_vars_files_multiple_found(self):
|
||||
|
||||
|
@ -187,9 +187,9 @@ class TestMe(unittest.TestCase):
|
|||
os.remove(temp_path2)
|
||||
|
||||
# make sure the variables were loaded
|
||||
assert 'foo' in play.vars, "vars_file was not loaded into play.vars"
|
||||
assert play.vars['foo'] == 'bar', "foo was not set to bar in play.vars"
|
||||
assert 'baz' not in play.vars, "vars_file2 was loaded after vars_file1 was loaded"
|
||||
assert 'foo' in play.vars_file_vars, "vars_file was not loaded into play.vars_file_vars"
|
||||
assert play.vars_file_vars['foo'] == 'bar', "foo was not set to bar in play.vars_file_vars"
|
||||
assert 'baz' not in play.vars_file_vars, "vars_file2 was loaded after vars_file1 was loaded"
|
||||
|
||||
def test_vars_files_assert_all_found(self):
|
||||
|
||||
|
@ -227,7 +227,7 @@ class TestMe(unittest.TestCase):
|
|||
# VARIABLE PRECEDENCE TESTS
|
||||
########################################
|
||||
|
||||
# On the first run vars_files are loaded into play.vars by host == None
|
||||
# On the first run vars_files are loaded into play.vars_file_vars by host == None
|
||||
# * only files with vars from host==None will work here
|
||||
# On the secondary run(s), a host is given and the vars_files are loaded into VARS_CACHE
|
||||
# * this only occurs if host is not None, filename2 has vars in the name, and filename3 does not
|
||||
|
@ -273,8 +273,8 @@ class TestMe(unittest.TestCase):
|
|||
|
||||
def test_vars_files_two_vars_in_name(self):
|
||||
|
||||
# self.vars = ds['vars']
|
||||
# self.vars += _get_vars() ... aka extra_vars
|
||||
# self.vars_file_vars = ds['vars']
|
||||
# self.vars_file_vars += _get_vars() ... aka extra_vars
|
||||
|
||||
# make a temp dir
|
||||
temp_dir = mkdtemp()
|
||||
|
@ -299,7 +299,7 @@ class TestMe(unittest.TestCase):
|
|||
# cleanup
|
||||
shutil.rmtree(temp_dir)
|
||||
|
||||
assert 'foo' in play.vars, "double var templated vars_files filename not loaded"
|
||||
assert 'foo' in play.vars_file_vars, "double var templated vars_files filename not loaded"
|
||||
|
||||
def test_vars_files_two_vars_different_scope(self):
|
||||
|
||||
|
@ -337,7 +337,7 @@ class TestMe(unittest.TestCase):
|
|||
# cleanup
|
||||
shutil.rmtree(temp_dir)
|
||||
|
||||
assert 'foo' not in play.vars, \
|
||||
assert 'foo' not in play.vars_file_vars, \
|
||||
"mixed scope vars_file loaded into play vars"
|
||||
assert 'foo' in play.playbook.VARS_CACHE['localhost'], \
|
||||
"differently scoped templated vars_files filename not loaded"
|
||||
|
@ -376,7 +376,7 @@ class TestMe(unittest.TestCase):
|
|||
# cleanup
|
||||
shutil.rmtree(temp_dir)
|
||||
|
||||
assert 'foo' not in play.vars, \
|
||||
assert 'foo' not in play.vars_file_vars, \
|
||||
"mixed scope vars_file loaded into play vars"
|
||||
assert 'foo' in play.playbook.VARS_CACHE['localhost'], \
|
||||
"differently scoped templated vars_files filename not loaded"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue