linode: Allow templating token for dynamic inventory (#4040)

* linode: Allow templating token for dynamic inventory

Template the value for the access_token if it's a Jinja template.

Allows for looking up tokens from files or pulling from secrets stores like Vault.

* add Linode changelog fragment

* Fix lookup example for newer versions of Ansible

Co-authored-by: Felix Fontein <felix@fontein.de>

* Rename test case for clarity

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Will Hegedus 2022-01-30 16:16:59 -05:00 committed by GitHub
parent 84124224ae
commit f77a1114fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 4 deletions

View file

@ -31,6 +31,7 @@ mandatory_py_version = pytest.mark.skipif(
from ansible.errors import AnsibleError, AnsibleParserError
from ansible.parsing.dataloader import DataLoader
from ansible_collections.community.general.plugins.inventory.linode import InventoryModule
@ -39,10 +40,11 @@ def inventory():
return InventoryModule()
def test_access_token_lookup(inventory):
def test_missing_access_token_lookup(inventory):
loader = DataLoader()
inventory._options = {'access_token': None}
with pytest.raises(AnsibleError) as error_message:
inventory._build_client()
inventory._build_client(loader)
assert 'Could not retrieve Linode access token' in error_message