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

* 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>
(cherry picked from commit f77a1114fb)

Co-authored-by: Will Hegedus <will@wbhegedus.me>
This commit is contained in:
patchback[bot] 2022-01-30 21:40:07 +00:00 committed by GitHub
parent de5970d17a
commit db84ea4ab6
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